From 6c090db56dbd51131e79a5c1f660801e21107828 Mon Sep 17 00:00:00 2001 From: Muhammet Yazici Date: Mon, 12 Dec 2022 18:14:19 +0300 Subject: [PATCH] Update API fields with regards to: - Unify pointer and omitempty JSON tag usage - Add all default fields for struct with default values. With the exception of HZ anc MC spec. The change is done due to the issue in https://github.com/kubernetes-sigs/controller-tools/issues/622 - WanReplication Queue , Batch and Acknowledgment fields did not have struct default values but they were not pointers so those fields acted like they had default values. Added explicit struct default values. - Add enum kubebuilder tags - Add optional comment for forgotten fields - Add explicit required comment for required field --- api/v1alpha1/cache_types.go | 7 +- api/v1alpha1/cronhotbackup_types.go | 18 +- api/v1alpha1/data_structure.go | 12 +- api/v1alpha1/hazelcast_types.go | 190 ++++++++++-------- api/v1alpha1/hotbackup_types.go | 21 +- api/v1alpha1/managementcenter_types.go | 96 ++++----- api/v1alpha1/managementcenter_types_test.go | 3 +- api/v1alpha1/map_types.go | 44 ++-- api/v1alpha1/map_validation.go | 2 +- api/v1alpha1/multimap_types.go | 8 +- api/v1alpha1/queue_types.go | 10 +- api/v1alpha1/replicatedmap_types.go | 11 +- api/v1alpha1/topic_types.go | 9 +- api/v1alpha1/wanreplication_types.go | 31 ++- api/v1alpha1/zz_generated.deepcopy.go | 116 +++-------- bundle.yaml | 79 ++++++-- config/crd/bases/hazelcast.com_caches.yaml | 4 + .../bases/hazelcast.com_cronhotbackups.yaml | 4 +- .../crd/bases/hazelcast.com_hazelcasts.yaml | 25 +-- .../crd/bases/hazelcast.com_hotbackups.yaml | 10 +- .../hazelcast.com_managementcenters.yaml | 2 +- config/crd/bases/hazelcast.com_maps.yaml | 5 +- config/crd/bases/hazelcast.com_multimaps.yaml | 4 + config/crd/bases/hazelcast.com_queues.yaml | 4 + .../bases/hazelcast.com_replicatedmaps.yaml | 2 + .../bases/hazelcast.com_wanreplications.yaml | 17 +- config/manager/kustomization.yaml | 3 + ...atform-operator.clusterserviceversion.yaml | 5 + controllers/hazelcast/cache_controller.go | 2 +- controllers/hazelcast/hazelcast_resources.go | 51 ++--- .../hazelcast/hazelcast_resources_test.go | 2 +- controllers/hazelcast/hazelcast_status.go | 2 +- controllers/hazelcast/map_controller.go | 22 +- controllers/hazelcast/multimap_controller.go | 2 +- controllers/hazelcast/queue_controller.go | 4 +- .../hazelcast/replicatedmap_controller.go | 2 +- .../managementcenter_resources.go | 22 +- internal/config/hazelcast.go | 2 +- internal/phonehome/phonehome.go | 4 +- test/e2e/config/hazelcast/config.go | 8 +- test/e2e/config/managementcenter/config.go | 13 +- test/e2e/hazelcast_backup_slow_test.go | 18 +- test/e2e/hazelcast_cache_persistence_test.go | 2 +- test/e2e/hazelcast_cache_test.go | 2 +- test/e2e/hazelcast_map_persistence_test.go | 4 +- test/e2e/hazelcast_map_test.go | 20 +- test/e2e/hazelcast_queue_test.go | 2 +- test/e2e/hazelcast_replicatedmap_test.go | 5 +- test/e2e/hazelcast_test.go | 2 +- test/e2e/hazelcast_wan_slow_test.go | 16 +- test/e2e/helpers_test.go | 8 +- test/integration/hazelcast_controller_test.go | 32 ++- .../managementcenter_controller_test.go | 26 ++- test/ph/ph_suite_test.go | 2 +- 54 files changed, 550 insertions(+), 467 deletions(-) diff --git a/api/v1alpha1/cache_types.go b/api/v1alpha1/cache_types.go index f4cde4f6aef..ea228530f59 100644 --- a/api/v1alpha1/cache_types.go +++ b/api/v1alpha1/cache_types.go @@ -40,10 +40,13 @@ type CacheStatus struct { // Cache is the Schema for the caches API type Cache struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec CacheSpec `json:"spec,omitempty"` + // +required + Spec CacheSpec `json:"spec"` + // +optional Status CacheStatus `json:"status,omitempty"` } diff --git a/api/v1alpha1/cronhotbackup_types.go b/api/v1alpha1/cronhotbackup_types.go index a23a3281626..c0ff9c34f52 100644 --- a/api/v1alpha1/cronhotbackup_types.go +++ b/api/v1alpha1/cronhotbackup_types.go @@ -19,19 +19,21 @@ type CronHotBackupSpec struct { // @daily (or @midnight) | Run once a day, midnight | 0 0 * * * // @hourly | Run once an hour, beginning of hour | 0 * * * * // +kubebuilder:validation:MinLength:=1 + // +required Schedule string `json:"schedule"` // Specifies the hot backup that will be created when executing a CronHotBackup. + // +required HotBackupTemplate HotBackupTemplateSpec `json:"hotBackupTemplate"` // The number of successful finished hot backups to retain. - // This is a pointer to distinguish between explicit zero and not specified. + // +kubebuilder:validation:Minimum=0 // +kubebuilder:default:=5 // +optional SuccessfulHotBackupsHistoryLimit *int32 `json:"successfulHotBackupsHistoryLimit,omitempty"` // The number of failed finished hot backups to retain. - // This is a pointer to distinguish between explicit zero and not specified. + // +kubebuilder:validation:Minimum=0 // +kubebuilder:default:=3 // +optional FailedHotBackupsHistoryLimit *int32 `json:"failedHotBackupsHistoryLimit,omitempty"` @@ -39,16 +41,17 @@ type CronHotBackupSpec struct { // When true, CronHotBackup will stop creating HotBackup CRs until it is disabled // +kubebuilder:default:=false // +optional - Suspend bool `json:"suspend,omitempty"` + Suspend bool `json:"suspend"` } type HotBackupTemplateSpec struct { // Standard object's metadata of the hot backups created from this template. - // +optional // +kubebuilder:validation:XPreserveUnknownFields + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` // Specification of the desired behavior of the hot backup. + // +required Spec HotBackupSpec `json:"spec"` } @@ -61,10 +64,13 @@ type CronHotBackupStatus struct{} // CronHotBackup is the Schema for the cronhotbackups API // +kubebuilder:printcolumn:name="SUSPENDED",type="boolean",JSONPath=".spec.suspend",description="Suspention status of the CronHotBackup" type CronHotBackup struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec CronHotBackupSpec `json:"spec"` + // +required + Spec CronHotBackupSpec `json:"spec"` + // +optional Status CronHotBackupStatus `json:"status,omitempty"` } diff --git a/api/v1alpha1/data_structure.go b/api/v1alpha1/data_structure.go index e72817de5b3..1a9171663cb 100644 --- a/api/v1alpha1/data_structure.go +++ b/api/v1alpha1/data_structure.go @@ -8,22 +8,28 @@ type DataStructureSpec struct { // HazelcastResourceName defines the name of the Hazelcast resource. // +kubebuilder:validation:MinLength:=1 + // +required HazelcastResourceName string `json:"hazelcastResourceName"` // Number of synchronous backups. + // +kubebuilder:validation:Minimum=0 // +kubebuilder:default:=1 // +optional BackupCount *int32 `json:"backupCount,omitempty"` // Number of asynchronous backups. + // +kubebuilder:validation:Minimum=0 // +kubebuilder:default:=0 // +optional - AsyncBackupCount *int32 `json:"asyncBackupCount,omitempty"` + AsyncBackupCount int32 `json:"asyncBackupCount"` } type DataStructureStatus struct { - State DataStructureConfigState `json:"state,omitempty"` - Message string `json:"message,omitempty"` + // +optional + State DataStructureConfigState `json:"state,omitempty"` + // +optional + Message string `json:"message,omitempty"` + // +optional MemberStatuses map[string]DataStructureConfigState `json:"memberStatuses,omitempty"` } diff --git a/api/v1alpha1/hazelcast_types.go b/api/v1alpha1/hazelcast_types.go index 6c518b18a33..8fa199b8c70 100644 --- a/api/v1alpha1/hazelcast_types.go +++ b/api/v1alpha1/hazelcast_types.go @@ -73,8 +73,8 @@ type HazelcastSpec struct { LicenseKeySecret string `json:"licenseKeySecret,omitempty"` // Configuration to expose Hazelcast cluster to external clients. - // +optional // +kubebuilder:default:={} + // +optional ExposeExternally *ExposeExternallyConfiguration `json:"exposeExternally,omitempty"` // Name of the Hazelcast cluster. @@ -83,33 +83,34 @@ type HazelcastSpec struct { ClusterName string `json:"clusterName,omitempty"` // Scheduling details - // +optional // +kubebuilder:default:={} - Scheduling *SchedulingConfiguration `json:"scheduling,omitempty"` + // +optional + Scheduling SchedulingConfiguration `json:"scheduling,omitempty"` // Compute Resources required by the Hazelcast container. - // +optional // +kubebuilder:default:={} - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + // +optional + Resources corev1.ResourceRequirements `json:"resources,omitempty"` // Persistence configuration - //+optional //+kubebuilder:default:={} + //+optional Persistence *HazelcastPersistenceConfiguration `json:"persistence,omitempty"` // B&R Agent configurations - // +optional // +kubebuilder:default:={repository: "docker.io/hazelcast/platform-operator-agent", version: "0.1.11"} - Agent *AgentConfiguration `json:"agent,omitempty"` + // +optional + Agent AgentConfiguration `json:"agent,omitempty"` // Jet Engine configuration + // +kubebuilder:default:={enabled: true, resourceUploadEnabled: false} // +optional - // +kubebuilder:default:={enabled: true} - JetEngineConfiguration *JetEngineConfiguration `json:"jet,omitempty"` + JetEngineConfiguration JetEngineConfiguration `json:"jet,omitempty"` // User Codes to Download into CLASSPATH + //+kubebuilder:default:={} // +optional - UserCodeDeployment *UserCodeDeploymentConfig `json:"userCodeDeployment,omitempty"` + UserCodeDeployment UserCodeDeploymentConfig `json:"userCodeDeployment,omitempty"` // +optional ExecutorServices []ExecutorServiceConfiguration `json:"executorServices,omitempty"` @@ -123,22 +124,28 @@ type HazelcastSpec struct { // +optional Properties map[string]string `json:"properties,omitempty"` - // +optional // +kubebuilder:default:="INFO" + // +optional LoggingLevel LoggingLevel `json:"loggingLevel,omitempty"` } type JetEngineConfiguration struct { // When false, disables Jet Engine. // +kubebuilder:default:=true + // +optional Enabled *bool `json:"enabled,omitempty"` // When true, enables resource uploading for Jet jobs. - // +optional // +kubebuilder:default:=false + // +optional ResourceUploadEnabled bool `json:"resourceUploadEnabled"` } +// Returns true if Jet section is configured. +func (j *JetEngineConfiguration) IsConfigured() bool { + return j != nil +} + type ExecutorServiceConfiguration struct { // The name of the executor service // +kubebuilder:default:="default" @@ -225,10 +232,12 @@ const ( type BucketConfiguration struct { // Name of the secret with credentials for cloud providers. // +kubebuilder:validation:MinLength:=1 + // +required Secret string `json:"secret"` // Full path to blob storage bucket. // +kubebuilder:validation:MinLength:=6 + // +required BucketURI string `json:"bucketURI"` } @@ -236,7 +245,7 @@ type BucketConfiguration struct { type UserCodeDeploymentConfig struct { // When true, allows user code deployment from clients. // +optional - ClientEnabled bool `json:"clientEnabled,omitempty"` + ClientEnabled *bool `json:"clientEnabled,omitempty"` // Jar files in the bucket will be put under CLASSPATH. // +optional @@ -251,6 +260,16 @@ type UserCodeDeploymentConfig struct { ConfigMaps []string `json:"configMaps,omitempty"` } +// Returns true if userCodeDeployment.bucketConfiguration is specified. +func (c *UserCodeDeploymentConfig) IsBucketEnabled() bool { + return c != nil && c.BucketConfiguration != nil +} + +// Returns true if userCodeDeployment.configMaps configuration is specified. +func (c *UserCodeDeploymentConfig) IsConfigMapEnabled() bool { + return c != nil && (len(c.ConfigMaps) != 0) +} + type AgentConfiguration struct { // Repository to pull Hazelcast Platform Operator Agent(https://github.com/hazelcast/platform-operator-agent) // +kubebuilder:default:="docker.io/hazelcast/platform-operator-agent" @@ -258,7 +277,7 @@ type AgentConfiguration struct { Repository string `json:"repository,omitempty"` // Version of Hazelcast Platform Operator Agent. - // +kubebuilder:default:="0.1.10" + // +kubebuilder:default:="0.1.11" // +optional Version string `json:"version,omitempty"` } @@ -277,8 +296,8 @@ const ( // HazelcastPersistenceConfiguration contains the configuration for Hazelcast Persistence and K8s storage. type HazelcastPersistenceConfiguration struct { - // Persistence base directory. + // +required BaseDir string `json:"baseDir"` // Configuration of the cluster recovery strategy. @@ -297,21 +316,46 @@ type HazelcastPersistenceConfiguration struct { DataRecoveryTimeout int32 `json:"dataRecoveryTimeout,omitempty"` // Configuration of PersistenceVolumeClaim. + // +kubebuilder:default:={} // +optional - Pvc PersistencePvcConfiguration `json:"pvc"` + Pvc PersistencePvcConfiguration `json:"pvc,omitempty"` // Host Path directory. // +optional HostPath string `json:"hostPath,omitempty"` // Restore configuration - // +optional // +kubebuilder:default:={} - Restore *RestoreConfiguration `json:"restore,omitempty"` + // +optional + Restore RestoreConfiguration `json:"restore,omitempty"` +} + +// Returns true if ClusterDataRecoveryPolicy is not FullRecoveryOnly +func (p *HazelcastPersistenceConfiguration) AutoRemoveStaleData() bool { + return p.ClusterDataRecoveryPolicy != FullRecovery +} + +// Returns true if Persistence configuration is specified. +func (p *HazelcastPersistenceConfiguration) IsEnabled() bool { + return p != nil && p.BaseDir != "" +} + +// Returns true if hostPath is enabled. +func (p *HazelcastPersistenceConfiguration) UseHostPath() bool { + return p.HostPath != "" +} + +// IsRestoreEnabled returns true if Restore configuration is specified +func (p *HazelcastPersistenceConfiguration) IsRestoreEnabled() bool { + return p.IsEnabled() && !(p.Restore == (RestoreConfiguration{})) +} + +// RestoreFromHotBackupResourceName returns true if Restore is done from a HotBackup resource +func (p *HazelcastPersistenceConfiguration) RestoreFromHotBackupResourceName() bool { + return p.IsRestoreEnabled() && p.Restore.HotBackupResourceName != "" } // RestoreConfiguration contains the configuration for Restore operation -// +kubebuilder:validation:MinProperties=1 // +kubebuilder:validation:MaxProperties=1 type RestoreConfiguration struct { // Bucket Configuration from which the backup will be downloaded. @@ -390,13 +434,13 @@ type ExposeExternallyConfiguration struct { // Valid values are: // - "Smart" (default): each member pod is exposed with a separate external address // - "Unisocket": all member pods are exposed with one external address - // +optional // +kubebuilder:default:="Smart" + // +optional Type ExposeExternallyType `json:"type,omitempty"` // Type of the service used to discover Hazelcast cluster. - // +optional // +kubebuilder:default:="LoadBalancer" + // +optional DiscoveryServiceType corev1.ServiceType `json:"discoveryServiceType,omitempty"` // How each member is accessed from the external client. @@ -440,16 +484,6 @@ func (c *ExposeExternallyConfiguration) IsEnabled() bool { return c != nil && !(*c == (ExposeExternallyConfiguration{})) } -// Returns true if userCodeDeployment.bucketConfiguration is specified. -func (c *UserCodeDeploymentConfig) IsBucketEnabled() bool { - return c != nil && c.BucketConfiguration != nil -} - -// Returns true if userCodeDeployment.configMaps configuration is specified. -func (c *UserCodeDeploymentConfig) IsConfigMapEnabled() bool { - return c != nil && (len(c.ConfigMaps) != 0) -} - // Returns true if Smart configuration is specified and therefore each Hazelcast member needs to be exposed with a separate address. func (c *ExposeExternallyConfiguration) IsSmart() bool { return c != nil && c.Type == ExposeExternallyTypeSmart @@ -500,41 +534,11 @@ func (c *ExposeExternallyConfiguration) MemberAccessServiceType() corev1.Service } } -// Returns true if ClusterDataRecoveryPolicy is not FullRecoveryOnly -func (p *HazelcastPersistenceConfiguration) AutoRemoveStaleData() bool { - return p.ClusterDataRecoveryPolicy != FullRecovery -} - -// Returns true if Persistence configuration is specified. -func (p *HazelcastPersistenceConfiguration) IsEnabled() bool { - return p != nil && p.BaseDir != "" -} - -// Returns true if hostPath is enabled. -func (p *HazelcastPersistenceConfiguration) UseHostPath() bool { - return p.HostPath != "" -} - -// IsRestoreEnabled returns true if Restore configuration is specified -func (p *HazelcastPersistenceConfiguration) IsRestoreEnabled() bool { - return p.IsEnabled() && p.Restore != nil && !(*p.Restore == (RestoreConfiguration{})) -} - -// RestoreFromHotBackupResourceName returns true if Restore is done from a HotBackup resource -func (p *HazelcastPersistenceConfiguration) RestoreFromHotBackupResourceName() bool { - return p.IsRestoreEnabled() && p.Restore.HotBackupResourceName != "" -} - -// Returns true if Jet section is configured. -func (j *JetEngineConfiguration) IsConfigured() bool { - return j != nil -} - // HazelcastStatus defines the observed state of Hazelcast type HazelcastStatus struct { // Phase of the Hazelcast cluster // +optional - Phase Phase `json:"phase"` + Phase Phase `json:"phase,omitempty"` // Status of the Hazelcast cluster // +optional @@ -549,15 +553,16 @@ type HazelcastStatus struct { ExternalAddresses string `json:"externalAddresses,omitempty"` // Status of Hazelcast members - // + optional + // +optional Members []HazelcastMemberStatus `json:"members,omitempty"` // Status of restore process of the Hazelcast cluster - // +optional // +kubebuilder:default:={} - Restore *RestoreStatus `json:"restore,omitempty"` + // +optional + Restore RestoreStatus `json:"restore,omitempty"` } +// +kubebuilder:validation:Enum=Unknown;Failed;InProgress;Succeeded type RestoreState string const ( @@ -569,18 +574,20 @@ const ( type RestoreStatus struct { // State shows the current phase of the restore process of the cluster. - State RestoreState `json:"state"` + // +optional + State RestoreState `json:"state,omitempty"` // RemainingValidationTime show the time in seconds remained for the restore validation step. - RemainingValidationTime int64 `json:"remainingValidationTime"` + // +optional + RemainingValidationTime int64 `json:"remainingValidationTime,omitempty"` // RemainingDataLoadTime show the time in seconds remained for the restore data load step. - RemainingDataLoadTime int64 `json:"remainingDataLoadTime"` + // +optional + RemainingDataLoadTime int64 `json:"remainingDataLoadTime,omitempty"` } // HazelcastMemberStatus defines the observed state of the individual Hazelcast member. type HazelcastMemberStatus struct { - // PodName is the name of the Hazelcast member pod. // +optional PodName string `json:"podName,omitempty"` @@ -615,6 +622,7 @@ type HazelcastMemberStatus struct { // Ready is the flag that is set to true when the member is successfully started, // connected to cluster and ready to accept connections. + // +optional Ready bool `json:"connected"` // Message contains the optional message with the details of the cluster state. @@ -626,9 +634,11 @@ type HazelcastMemberStatus struct { Reason string `json:"reason,omitempty"` // RestartCount is the number of times the member has been restarted. + // +optional RestartCount int32 `json:"restartCount"` } +// +kubebuilder:validation:Enum=PASSIVE;ACTIVE;SHUT_DOWN;STARTING type NodeState string const ( @@ -642,7 +652,8 @@ const ( type HazelcastClusterStatus struct { // ReadyMembers represents the number of members that are connected to cluster from the desired number of members // in the format / - ReadyMembers string `json:"readyMembers"` + // +optional + ReadyMembers string `json:"readyMembers,omitempty"` } //+kubebuilder:object:root=true @@ -656,12 +667,15 @@ type HazelcastClusterStatus struct { // +kubebuilder:printcolumn:name="Message",type="string",priority=1,JSONPath=".status.message",description="Message for the current Hazelcast Config" // +kubebuilder:resource:shortName=hz type Hazelcast struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - // +optional + // Initial values will be filled with its fields' default values. // +kubebuilder:default:={"repository" : "docker.io/hazelcast/hazelcast"} + // +optional Spec HazelcastSpec `json:"spec,omitempty"` + // +optional Status HazelcastStatus `json:"status,omitempty"` } @@ -670,6 +684,19 @@ func (h *Hazelcast) DockerImage() string { return fmt.Sprintf("%s:%s", h.Spec.Repository, h.Spec.Version) } +func (h *Hazelcast) ClusterScopedName() string { + return fmt.Sprintf("%s-%d", h.Name, FNV32a(h.Namespace)) +} + +func (h *Hazelcast) ExternalAddressEnabled() bool { + return h.Spec.ExposeExternally.IsEnabled() && + h.Spec.ExposeExternally.DiscoveryServiceType == corev1.ServiceTypeLoadBalancer +} + +func (h *Hazelcast) AgentDockerImage() string { + return fmt.Sprintf("%s:%s", h.Spec.Agent.Repository, h.Spec.Agent.Version) +} + //+kubebuilder:object:root=true // HazelcastList contains a list of Hazelcast @@ -679,25 +706,12 @@ type HazelcastList struct { Items []Hazelcast `json:"items"` } -func init() { - SchemeBuilder.Register(&Hazelcast{}, &HazelcastList{}) -} - func FNV32a(txt string) uint32 { alg := fnv.New32a() alg.Write([]byte(txt)) return alg.Sum32() } -func (h *Hazelcast) ClusterScopedName() string { - return fmt.Sprintf("%s-%d", h.Name, FNV32a(h.Namespace)) -} - -func (h *Hazelcast) ExternalAddressEnabled() bool { - return h.Spec.ExposeExternally.IsEnabled() && - h.Spec.ExposeExternally.DiscoveryServiceType == corev1.ServiceTypeLoadBalancer -} - -func (h *Hazelcast) AgentDockerImage() string { - return fmt.Sprintf("%s:%s", h.Spec.Agent.Repository, h.Spec.Agent.Version) +func init() { + SchemeBuilder.Register(&Hazelcast{}, &HazelcastList{}) } diff --git a/api/v1alpha1/hotbackup_types.go b/api/v1alpha1/hotbackup_types.go index 202c2d95bae..e98026828e3 100644 --- a/api/v1alpha1/hotbackup_types.go +++ b/api/v1alpha1/hotbackup_types.go @@ -8,6 +8,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) +// +kubebuilder:validation:Enum=Unknown;Pending;NotStarted;InProgress;Failure;Success type HotBackupState string const ( @@ -31,9 +32,12 @@ func (s HotBackupState) IsRunning() bool { // HotBackupStatus defines the observed state of HotBackup type HotBackupStatus struct { - State HotBackupState `json:"state"` - Message string `json:"message"` - BackupUUIDs []string `json:"backupUUIDs,omitempty"` + // +optional + State HotBackupState `json:"state,omitempty"` + // +optional + Message string `json:"message,omitempty"` + // +optional + BackupUUIDs []string `json:"backupUUIDs,omitempty"` } func (hbs *HotBackupStatus) GetBucketURI() string { @@ -72,15 +76,16 @@ func (hbs *HotBackupStatus) GetBackupFolder() string { // HotBackupSpec defines the Spec of HotBackup type HotBackupSpec struct { // HazelcastResourceName defines the name of the Hazelcast resource + // +required HazelcastResourceName string `json:"hazelcastResourceName"` // URL of the bucket to download HotBackup folders. // +optional - BucketURI string `json:"bucketURI"` + BucketURI string `json:"bucketURI,omitempty"` // Name of the secret with credentials for cloud providers. // +optional - Secret string `json:"secret"` + Secret string `json:"secret,omitempty"` } func (hbs *HotBackupSpec) IsExternal() bool { @@ -95,12 +100,14 @@ func (hbs *HotBackupSpec) IsExternal() bool { // +kubebuilder:printcolumn:name="Message",type="string",priority=1,JSONPath=".status.message",description="Message for the current HotBackup Config" // +kubebuilder:resource:shortName=hb type HotBackup struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` + // +required + Spec HotBackupSpec `json:"spec"` // +optional Status HotBackupStatus `json:"status,omitempty"` - Spec HotBackupSpec `json:"spec"` } //+kubebuilder:object:root=true diff --git a/api/v1alpha1/managementcenter_types.go b/api/v1alpha1/managementcenter_types.go index 723dd401303..ec0961cc2b9 100644 --- a/api/v1alpha1/managementcenter_types.go +++ b/api/v1alpha1/managementcenter_types.go @@ -38,32 +38,35 @@ type ManagementCenterSpec struct { HazelcastClusters []HazelcastClusterConfig `json:"hazelcastClusters,omitempty"` // Configuration to expose Management Center to outside. - // +optional // +kubebuilder:default:={type: "LoadBalancer"} - ExternalConnectivity *ExternalConnectivityConfiguration `json:"externalConnectivity,omitempty"` + // +optional + ExternalConnectivity ExternalConnectivityConfiguration `json:"externalConnectivity,omitempty"` // Configuration for Management Center persistence. - // +optional // +kubebuilder:default:={enabled: true, size: "10Gi"} - Persistence *PersistenceConfiguration `json:"persistence,omitempty"` + // +optional + Persistence PersistenceConfiguration `json:"persistence,omitempty"` // Scheduling details + // +kubebuilder:default:={} // +optional - Scheduling *SchedulingConfiguration `json:"scheduling,omitempty"` + Scheduling SchedulingConfiguration `json:"scheduling,omitempty"` // Compute Resources required by the MC container. - // +optional // +kubebuilder:default:={} - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` + // +optional + Resources corev1.ResourceRequirements `json:"resources,omitempty"` } type HazelcastClusterConfig struct { // Name of the Hazelcast cluster that Management Center will connect to, default is dev. - // +optional // +kubebuilder:default:="dev" + // +optional Name string `json:"name,omitempty"` + // IP address or DNS name of the Hazelcast cluster. // If the cluster is exposed with a service name in a different namespace, use the following syntax ".". + // +required Address string `json:"address"` } @@ -74,11 +77,32 @@ type ExternalConnectivityConfiguration struct { // - "ClusterIP" // - "NodePort" // - "LoadBalancer" (default) - // +optional // +kubebuilder:default:="LoadBalancer" + // +optional Type ExternalConnectivityType `json:"type,omitempty"` } +// Returns service type that is used by Management Center (LoadBalancer by default). +func (ec *ExternalConnectivityConfiguration) ManagementCenterServiceType() corev1.ServiceType { + if ec == nil { + return corev1.ServiceTypeClusterIP + } + + switch ec.Type { + case ExternalConnectivityTypeClusterIP: + return corev1.ServiceTypeClusterIP + case ExternalConnectivityTypeNodePort: + return corev1.ServiceTypeNodePort + default: + return corev1.ServiceTypeLoadBalancer + } +} + +// IsEnabled returns true if external connectivity is enabled. +func (ec *ExternalConnectivityConfiguration) IsEnabled() bool { + return ec != nil && *ec != ExternalConnectivityConfiguration{} +} + // ExternalConnectivityType describes how Management Center is exposed. // +kubebuilder:validation:Enum=ClusterIP;NodePort;LoadBalancer type ExternalConnectivityType string @@ -96,9 +120,9 @@ const ( type PersistenceConfiguration struct { // When true, MC will use a PersistentVolumeClaim to store data. - // +optional // +kubebuilder:default:=true - Enabled bool `json:"enabled"` + // +optional + Enabled *bool `json:"enabled,omitempty"` // Name of the PersistentVolumeClaim MC will use for persistence. If not empty, // MC will use the existing claim instead of creating a new one. @@ -110,11 +134,16 @@ type PersistenceConfiguration struct { StorageClass *string `json:"storageClass,omitempty"` // Size of the created PersistentVolumeClaim. - // +optional // +kubebuilder:default:="10Gi" + // +optional Size *resource.Quantity `json:"size,omitempty"` } +// Returns true if persistence configuration is specified. +func (pc *PersistenceConfiguration) IsEnabled() bool { + return pc != nil && pc.Enabled != nil && *pc.Enabled +} + // ManagementCenterStatus defines the observed state of ManagementCenter. type ManagementCenterStatus struct { // Phase of the Management Center @@ -140,12 +169,15 @@ type ManagementCenterStatus struct { // +kubebuilder:printcolumn:name="Message",type="string",priority=1,JSONPath=".status.message",description="Message for the current ManagementCenter Config" // +kubebuilder:resource:shortName=mc type ManagementCenter struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - // +optional + // Initial values will be filled with its fields' default values. // +kubebuilder:default:={"repository" : "docker.io/hazelcast/management-center"} + // +optional Spec ManagementCenterSpec `json:"spec,omitempty"` + // +optional Status ManagementCenterStatus `json:"status,omitempty"` } @@ -154,6 +186,11 @@ func (mc *ManagementCenter) DockerImage() string { return fmt.Sprintf("%s:%s", mc.Spec.Repository, mc.Spec.Version) } +func (mc *ManagementCenter) ExternalAddressEnabled() bool { + return mc.Spec.ExternalConnectivity.IsEnabled() && + mc.Spec.ExternalConnectivity.Type == ExternalConnectivityTypeLoadBalancer +} + //+kubebuilder:object:root=true // ManagementCenterList contains a list of ManagementCenter @@ -166,34 +203,3 @@ type ManagementCenterList struct { func init() { SchemeBuilder.Register(&ManagementCenter{}, &ManagementCenterList{}) } - -// Returns service type that is used by Management Center (LoadBalancer by default). -func (ec *ExternalConnectivityConfiguration) ManagementCenterServiceType() corev1.ServiceType { - if ec == nil { - return corev1.ServiceTypeClusterIP - } - - switch ec.Type { - case ExternalConnectivityTypeClusterIP: - return corev1.ServiceTypeClusterIP - case ExternalConnectivityTypeNodePort: - return corev1.ServiceTypeNodePort - default: - return corev1.ServiceTypeLoadBalancer - } -} - -// IsEnabled returns true if external connectivity is enabled. -func (ec *ExternalConnectivityConfiguration) IsEnabled() bool { - return ec != nil && *ec != ExternalConnectivityConfiguration{} -} - -// Returns true if persistence configuration is specified. -func (pc *PersistenceConfiguration) IsEnabled() bool { - return pc != nil && pc.Enabled -} - -func (mc *ManagementCenter) ExternalAddressEnabled() bool { - return mc.Spec.ExternalConnectivity.IsEnabled() && - mc.Spec.ExternalConnectivity.Type == ExternalConnectivityTypeLoadBalancer -} diff --git a/api/v1alpha1/managementcenter_types_test.go b/api/v1alpha1/managementcenter_types_test.go index 2c6bd604319..ac8d8ce803a 100644 --- a/api/v1alpha1/managementcenter_types_test.go +++ b/api/v1alpha1/managementcenter_types_test.go @@ -4,6 +4,7 @@ import ( "testing" v1 "k8s.io/api/core/v1" + "k8s.io/utils/pointer" ) func TestExternalConnectivityConfigurationType(t *testing.T) { @@ -63,7 +64,7 @@ func TestPersistenceConfigurationIsEnabled(t *testing.T) { { name: "Enabled configuration", conf: PersistenceConfiguration{ - Enabled: true, + Enabled: pointer.Bool(true), }, want: true, }, diff --git a/api/v1alpha1/map_types.go b/api/v1alpha1/map_types.go index b3e25d6b845..8fc5d125dc8 100644 --- a/api/v1alpha1/map_types.go +++ b/api/v1alpha1/map_types.go @@ -14,20 +14,20 @@ type MapSpec struct { // It can be updated. // +kubebuilder:default:=0 // +optional - TimeToLiveSeconds *int32 `json:"timeToLiveSeconds,omitempty"` + TimeToLiveSeconds int32 `json:"timeToLiveSeconds"` // Maximum time in seconds for each entry to stay idle in the map. // Entries that are idle for more than this time are evicted automatically. // It can be updated. // +kubebuilder:default:=0 // +optional - MaxIdleSeconds *int32 `json:"maxIdleSeconds,omitempty"` + MaxIdleSeconds int32 `json:"maxIdleSeconds"` // Configuration for removing data from the map when it reaches its max size. // It can be updated. - // +kubebuilder:default:={maxSize: 0} + // +kubebuilder:default:={maxSize: 0, evictionPolicy: NONE, maxSizePolicy: PER_NODE} // +optional - Eviction *EvictionConfig `json:"eviction,omitempty"` + Eviction EvictionConfig `json:"eviction,omitempty"` // Indexes to be created for the map data. // You can learn more at https://docs.hazelcast.com/hazelcast/latest/query/indexing-maps. @@ -44,6 +44,7 @@ type MapSpec struct { // Configuration options when you want to load/store the map entries // from/to a persistent data store such as a relational database // You can learn more at https://docs.hazelcast.com/hazelcast/latest/data-structures/working-with-external-data + // +optional MapStore *MapStoreConfig `json:"mapStore,omitempty"` // InMemoryFormat specifies in which format data will be stored in your map @@ -61,6 +62,7 @@ type MapSpec struct { type EntryListenerConfiguration struct { // ClassName is the fully qualified name of the class that implements any of the Listener interface. // +kubebuilder:validation:MinLength:=1 + // +required ClassName string `json:"className"` // IncludeValues is an optional attribute that indicates whether the event will contain the map value. @@ -73,7 +75,7 @@ type EntryListenerConfiguration struct { // Defaults to false. // +kubebuilder:default:=false // +optional - Local bool `json:"local,omitempty"` + Local bool `json:"local"` } func (e *EntryListenerConfiguration) GetIncludedValue() bool { @@ -92,7 +94,7 @@ type EvictionConfig struct { // Max size of the map. // +kubebuilder:default:=0 // +optional - MaxSize *int32 `json:"maxSize,omitempty"` + MaxSize int32 `json:"maxSize"` // Policy for deciding if the maxSize is reached. // +kubebuilder:default:="PER_NODE" @@ -166,12 +168,15 @@ type IndexConfig struct { Name string `json:"name,omitempty"` // Type of the index. + // +required Type IndexType `json:"type"` // Attributes of the index. - Attributes []string `json:"attributes"` + // +optional + Attributes []string `json:"attributes,omitempty"` // Options for "BITMAP" index type. + // +kubebuilder:default:={} // +optional BitmapIndexOptions *BitmapIndexOptionsConfig `json:"bitMapIndexOptions,omitempty"` } @@ -186,8 +191,10 @@ const ( ) type BitmapIndexOptionsConfig struct { + // +required UniqueKey string `json:"uniqueKey"` + // +required UniqueKeyTransition UniqueKeyTransition `json:"uniqueKeyTransition"` } @@ -202,8 +209,11 @@ const ( // MapStatus defines the observed state of Map type MapStatus struct { - State MapConfigState `json:"state,omitempty"` - Message string `json:"message,omitempty"` + // +optional + State MapConfigState `json:"state,omitempty"` + // +optional + Message string `json:"message,omitempty"` + // +optional MemberStatuses map[string]MapConfigState `json:"memberStatuses,omitempty"` } @@ -226,6 +236,7 @@ type MapStoreConfig struct { InitialMode InitialModeType `json:"initialMode,omitempty"` // Name of your class implementing MapLoader and/or MapStore interface. + // +required ClassName string `json:"className"` // Number of seconds to delay the storing of entries. @@ -284,10 +295,13 @@ const ( // +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.state",description="Current state of the Map Config" // +kubebuilder:printcolumn:name="Message",type="string",priority=1,JSONPath=".status.message",description="Message for the current Map Config" type Map struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec MapSpec `json:"spec"` + // +required + Spec MapSpec `json:"spec"` + // +optional Status MapStatus `json:"status,omitempty"` } @@ -315,10 +329,6 @@ func (ml *MapList) GetItems() []client.Object { return l } -func init() { - SchemeBuilder.Register(&Map{}, &MapList{}) -} - var ( EncodeMaxSizePolicy = map[MaxSizePolicyType]int32{ MaxSizePolicyPerNode: 0, @@ -358,3 +368,7 @@ var ( InMemoryFormatNative: 2, } ) + +func init() { + SchemeBuilder.Register(&Map{}, &MapList{}) +} diff --git a/api/v1alpha1/map_validation.go b/api/v1alpha1/map_validation.go index a0fc2d9360c..367619afde3 100644 --- a/api/v1alpha1/map_validation.go +++ b/api/v1alpha1/map_validation.go @@ -11,7 +11,7 @@ func ValidateNotUpdatableFields(current *MapSpec, last *MapSpec) error { if *current.BackupCount != *last.BackupCount { return errors.New("backupCount cannot be updated") } - if *current.AsyncBackupCount != *last.AsyncBackupCount { + if current.AsyncBackupCount != last.AsyncBackupCount { return errors.New("asyncBackupCount cannot be updated") } if !indexConfigSliceEquals(current.Indexes, last.Indexes) { diff --git a/api/v1alpha1/multimap_types.go b/api/v1alpha1/multimap_types.go index e3ae7ab6507..1c7db34bf5f 100644 --- a/api/v1alpha1/multimap_types.go +++ b/api/v1alpha1/multimap_types.go @@ -3,6 +3,7 @@ package v1alpha1 import ( "encoding/json" "fmt" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -46,10 +47,13 @@ type MultiMapStatus struct { // +kubebuilder:printcolumn:name="Message",type="string",priority=1,JSONPath=".status.message",description="Message for the current MultiMap Config" // +kubebuilder:resource:shortName=mmap type MultiMap struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec MultiMapSpec `json:"spec,omitempty"` + // +required + Spec MultiMapSpec `json:"spec"` + // +optional Status MultiMapStatus `json:"status,omitempty"` } diff --git a/api/v1alpha1/queue_types.go b/api/v1alpha1/queue_types.go index 5a5d986bc06..9db06be6a0c 100644 --- a/api/v1alpha1/queue_types.go +++ b/api/v1alpha1/queue_types.go @@ -3,6 +3,7 @@ package v1alpha1 import ( "encoding/json" "fmt" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -15,7 +16,7 @@ type QueueSpec struct { // Max size of the queue. // +kubebuilder:default:=0 // +optional - MaxSize *int32 `json:"maxSize,omitempty"` + MaxSize int32 `json:"maxSize"` // Time in seconds after which the Queue will be destroyed if it stays empty or unused. // If the values is not provided the Queue will never be destroyed. @@ -43,10 +44,13 @@ type QueueStatus struct { // Queue is the Schema for the queues API type Queue struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec QueueSpec `json:"spec,omitempty"` + // +required + Spec QueueSpec `json:"spec"` + // +optional Status QueueStatus `json:"status,omitempty"` } diff --git a/api/v1alpha1/replicatedmap_types.go b/api/v1alpha1/replicatedmap_types.go index 4bba4229895..47665a0601f 100644 --- a/api/v1alpha1/replicatedmap_types.go +++ b/api/v1alpha1/replicatedmap_types.go @@ -3,6 +3,7 @@ package v1alpha1 import ( "encoding/json" "fmt" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -16,7 +17,7 @@ type ReplicatedMapSpec struct { // AsyncFillup specifies whether the ReplicatedMap is available for reads before the initial replication is completed // +kubebuilder:default:=true // +optional - AsyncFillup bool `json:"asyncFillup,omitempty"` + AsyncFillup *bool `json:"asyncFillup,omitempty"` // InMemoryFormat specifies in which format data will be stored in the ReplicatedMap // +kubebuilder:default:=OBJECT @@ -25,6 +26,7 @@ type ReplicatedMapSpec struct { // HazelcastResourceName defines the name of the Hazelcast resource. // +kubebuilder:validation:MinLength:=1 + // +required HazelcastResourceName string `json:"hazelcastResourceName"` } @@ -41,10 +43,13 @@ type ReplicatedMapStatus struct { // +kubebuilder:printcolumn:name="Message",type="string",priority=1,JSONPath=".status.message",description="Message for the current ReplicatedMap Config" // +kubebuilder:resource:shortName=rmap type ReplicatedMap struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec ReplicatedMapSpec `json:"spec,omitempty"` + // +required + Spec ReplicatedMapSpec `json:"spec"` + // +optional Status ReplicatedMapStatus `json:"status,omitempty"` } diff --git a/api/v1alpha1/topic_types.go b/api/v1alpha1/topic_types.go index 149ac7f5e1b..a03bc0e8170 100644 --- a/api/v1alpha1/topic_types.go +++ b/api/v1alpha1/topic_types.go @@ -3,6 +3,7 @@ package v1alpha1 import ( "encoding/json" "fmt" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -28,6 +29,7 @@ type TopicSpec struct { // HazelcastResourceName defines the name of the Hazelcast resource for which // topic config will be created // +kubebuilder:validation:MinLength:=1 + // +required HazelcastResourceName string `json:"hazelcastResourceName"` } @@ -43,10 +45,13 @@ type TopicStatus struct { // Topic is the Schema for the topics API type Topic struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec TopicSpec `json:"spec"` + // +required + Spec TopicSpec `json:"spec"` + // +optional Status TopicStatus `json:"status,omitempty"` } diff --git a/api/v1alpha1/wanreplication_types.go b/api/v1alpha1/wanreplication_types.go index 8d88fd24d31..c5fb04cb461 100644 --- a/api/v1alpha1/wanreplication_types.go +++ b/api/v1alpha1/wanreplication_types.go @@ -8,25 +8,31 @@ import ( type WanReplicationSpec struct { // Resources is the list of custom resources to which WAN replication applies. // +kubebuilder:validation:MinItems:=1 + // +required Resources []ResourceSpec `json:"resources"` // ClusterName is the clusterName field of the target Hazelcast resource. // +kubebuilder:validation:MinLength:=1 + // +required TargetClusterName string `json:"targetClusterName"` // Endpoints is the target cluster endpoints. // +kubebuilder:validation:MinLength:=1 + // +required Endpoints string `json:"endpoints"` // Queue is the configuration for WAN events queue. + // +kubebuilder:default:={capacity: 10000, fullBehavior: DISCARD_AFTER_MUTATION} // +optional Queue QueueSetting `json:"queue,omitempty"` // Batch is the configuration for WAN events batch. + // +kubebuilder:default:={size: 500, maximumDelay: 1000} // +optional Batch BatchSetting `json:"batch,omitempty"` // Acknowledgement is the configuration for the condition when the next batch of WAN events are sent. + // +kubebuilder:default:={type: ACK_ON_OPERATION_COMPLETE, timeout: 60000} // +optional Acknowledgement AcknowledgementSetting `json:"acknowledgement,omitempty"` } @@ -34,14 +40,16 @@ type WanReplicationSpec struct { type ResourceSpec struct { // Name is the name of custom resource to which WAN replication applies. // +kubebuilder:validation:MinLength:=1 + // +required Name string `json:"name"` // Kind is the kind of custom resource to which WAN replication applies. - // +kubebuilder:validation:Enum=Map;Hazelcast // +kubebuilder:default:=Map - Kind ResourceKind `json:"kind"` + // +optional + Kind ResourceKind `json:"kind,omitempty"` } +// +kubebuilder:validation:Enum=Map;Hazelcast type ResourceKind string const ( @@ -58,12 +66,12 @@ type QueueSetting struct { Capacity int32 `json:"capacity,omitempty"` // FullBehavior represents the behavior of the new arrival when the queue is full. - // +kubebuilder:validation:Enum=DISCARD_AFTER_MUTATION;THROW_EXCEPTION;THROW_EXCEPTION_ONLY_IF_REPLICATION_ACTIVE // +kubebuilder:default:=DISCARD_AFTER_MUTATION // +optional FullBehavior FullBehaviorSetting `json:"fullBehavior,omitempty"` } +// +kubebuilder:validation:Enum=DISCARD_AFTER_MUTATION;THROW_EXCEPTION;THROW_EXCEPTION_ONLY_IF_REPLICATION_ACTIVE type FullBehaviorSetting string const ( @@ -90,18 +98,18 @@ type BatchSetting struct { type AcknowledgementSetting struct { // Type represents how a batch of replication events is considered successfully replicated. - // +kubebuilder:validation:Enum=ACK_ON_OPERATION_COMPLETE;ACK_ON_RECEIPT // +kubebuilder:default:=ACK_ON_OPERATION_COMPLETE // +optional Type AcknowledgementType `json:"type,omitempty"` - // Timeout represents the time the source cluster waits for the acknowledgement. + // Timeout represents the time in milliseconds the source cluster waits for the acknowledgement. // After timeout, the events will be resent. // +kubebuilder:default:=60000 // +optional Timeout int32 `json:"timeout,omitempty"` } +// +kubebuilder:validation:Enum=ACK_ON_OPERATION_COMPLETE;ACK_ON_RECEIPT type AcknowledgementType string const ( @@ -122,22 +130,28 @@ const ( // WanReplicationStatus defines the observed state of WanReplication type WanReplicationStatus struct { // Status is the status of WAN replication + // +optional Status WanStatus `json:"status,omitempty"` // Message is the field to show detail information or error + // +optional Message string `json:"message,omitempty"` + // +optional WanReplicationMapsStatus map[string]WanReplicationMapStatus `json:"wanReplicationMapsStatus,omitempty"` } type WanReplicationMapStatus struct { // PublisherId is the ID used for WAN publisher ID + // +optional PublisherId string `json:"publisherId,omitempty"` // Status is the status of WAN replication + // +optional Status WanStatus `json:"status,omitempty"` // Message is the field to show detail information or error + // +optional Message string `json:"message,omitempty"` } @@ -148,10 +162,13 @@ type WanReplicationMapStatus struct { // +kubebuilder:printcolumn:name="Message",type="string",priority=1,JSONPath=".status.message",description="Message for the current WanReplication Config" // +kubebuilder:resource:shortName=wr type WanReplication struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +optional metav1.ObjectMeta `json:"metadata,omitempty"` - Spec WanReplicationSpec `json:"spec,omitempty"` + // +required + Spec WanReplicationSpec `json:"spec"` + // +optional Status WanReplicationStatus `json:"status,omitempty"` } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 952692d5220..47b44b312e8 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -284,11 +284,6 @@ func (in *DataStructureSpec) DeepCopyInto(out *DataStructureSpec) { *out = new(int32) **out = **in } - if in.AsyncBackupCount != nil { - in, out := &in.AsyncBackupCount, &out.AsyncBackupCount - *out = new(int32) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataStructureSpec. @@ -361,11 +356,6 @@ func (in *EntryListenerConfiguration) DeepCopy() *EntryListenerConfiguration { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EvictionConfig) DeepCopyInto(out *EvictionConfig) { *out = *in - if in.MaxSize != nil { - in, out := &in.MaxSize, &out.MaxSize - *out = new(int32) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EvictionConfig. @@ -531,11 +521,7 @@ func (in *HazelcastMemberStatus) DeepCopy() *HazelcastMemberStatus { func (in *HazelcastPersistenceConfiguration) DeepCopyInto(out *HazelcastPersistenceConfiguration) { *out = *in in.Pvc.DeepCopyInto(&out.Pvc) - if in.Restore != nil { - in, out := &in.Restore, &out.Restore - *out = new(RestoreConfiguration) - (*in).DeepCopyInto(*out) - } + in.Restore.DeepCopyInto(&out.Restore) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HazelcastPersistenceConfiguration. @@ -566,36 +552,16 @@ func (in *HazelcastSpec) DeepCopyInto(out *HazelcastSpec) { *out = new(ExposeExternallyConfiguration) **out = **in } - if in.Scheduling != nil { - in, out := &in.Scheduling, &out.Scheduling - *out = new(SchedulingConfiguration) - (*in).DeepCopyInto(*out) - } - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = new(v1.ResourceRequirements) - (*in).DeepCopyInto(*out) - } + in.Scheduling.DeepCopyInto(&out.Scheduling) + in.Resources.DeepCopyInto(&out.Resources) if in.Persistence != nil { in, out := &in.Persistence, &out.Persistence *out = new(HazelcastPersistenceConfiguration) (*in).DeepCopyInto(*out) } - if in.Agent != nil { - in, out := &in.Agent, &out.Agent - *out = new(AgentConfiguration) - **out = **in - } - if in.JetEngineConfiguration != nil { - in, out := &in.JetEngineConfiguration, &out.JetEngineConfiguration - *out = new(JetEngineConfiguration) - (*in).DeepCopyInto(*out) - } - if in.UserCodeDeployment != nil { - in, out := &in.UserCodeDeployment, &out.UserCodeDeployment - *out = new(UserCodeDeploymentConfig) - (*in).DeepCopyInto(*out) - } + out.Agent = in.Agent + in.JetEngineConfiguration.DeepCopyInto(&out.JetEngineConfiguration) + in.UserCodeDeployment.DeepCopyInto(&out.UserCodeDeployment) if in.ExecutorServices != nil { in, out := &in.ExecutorServices, &out.ExecutorServices *out = make([]ExecutorServiceConfiguration, len(*in)) @@ -639,11 +605,7 @@ func (in *HazelcastStatus) DeepCopyInto(out *HazelcastStatus) { *out = make([]HazelcastMemberStatus, len(*in)) copy(*out, *in) } - if in.Restore != nil { - in, out := &in.Restore, &out.Restore - *out = new(RestoreStatus) - **out = **in - } + out.Restore = in.Restore } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HazelcastStatus. @@ -661,8 +623,8 @@ func (in *HotBackup) DeepCopyInto(out *HotBackup) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Status.DeepCopyInto(&out.Status) out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HotBackup. @@ -884,26 +846,10 @@ func (in *ManagementCenterSpec) DeepCopyInto(out *ManagementCenterSpec) { *out = make([]HazelcastClusterConfig, len(*in)) copy(*out, *in) } - if in.ExternalConnectivity != nil { - in, out := &in.ExternalConnectivity, &out.ExternalConnectivity - *out = new(ExternalConnectivityConfiguration) - **out = **in - } - if in.Persistence != nil { - in, out := &in.Persistence, &out.Persistence - *out = new(PersistenceConfiguration) - (*in).DeepCopyInto(*out) - } - if in.Scheduling != nil { - in, out := &in.Scheduling, &out.Scheduling - *out = new(SchedulingConfiguration) - (*in).DeepCopyInto(*out) - } - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = new(v1.ResourceRequirements) - (*in).DeepCopyInto(*out) - } + out.ExternalConnectivity = in.ExternalConnectivity + in.Persistence.DeepCopyInto(&out.Persistence) + in.Scheduling.DeepCopyInto(&out.Scheduling) + in.Resources.DeepCopyInto(&out.Resources) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagementCenterSpec. @@ -994,21 +940,7 @@ func (in *MapList) DeepCopyObject() runtime.Object { func (in *MapSpec) DeepCopyInto(out *MapSpec) { *out = *in in.DataStructureSpec.DeepCopyInto(&out.DataStructureSpec) - if in.TimeToLiveSeconds != nil { - in, out := &in.TimeToLiveSeconds, &out.TimeToLiveSeconds - *out = new(int32) - **out = **in - } - if in.MaxIdleSeconds != nil { - in, out := &in.MaxIdleSeconds, &out.MaxIdleSeconds - *out = new(int32) - **out = **in - } - if in.Eviction != nil { - in, out := &in.Eviction, &out.Eviction - *out = new(EvictionConfig) - (*in).DeepCopyInto(*out) - } + out.Eviction = in.Eviction if in.Indexes != nil { in, out := &in.Indexes, &out.Indexes *out = make([]IndexConfig, len(*in)) @@ -1176,6 +1108,11 @@ func (in *MultiMapStatus) DeepCopy() *MultiMapStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PersistenceConfiguration) DeepCopyInto(out *PersistenceConfiguration) { *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } if in.StorageClass != nil { in, out := &in.StorageClass, &out.StorageClass *out = new(string) @@ -1306,11 +1243,6 @@ func (in *QueueSetting) DeepCopy() *QueueSetting { func (in *QueueSpec) DeepCopyInto(out *QueueSpec) { *out = *in in.DataStructureSpec.DeepCopyInto(&out.DataStructureSpec) - if in.MaxSize != nil { - in, out := &in.MaxSize, &out.MaxSize - *out = new(int32) - **out = **in - } if in.EmptyQueueTtlSeconds != nil { in, out := &in.EmptyQueueTtlSeconds, &out.EmptyQueueTtlSeconds *out = new(int32) @@ -1349,7 +1281,7 @@ func (in *ReplicatedMap) DeepCopyInto(out *ReplicatedMap) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec + in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) } @@ -1406,6 +1338,11 @@ func (in *ReplicatedMapList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ReplicatedMapSpec) DeepCopyInto(out *ReplicatedMapSpec) { *out = *in + if in.AsyncFillup != nil { + in, out := &in.AsyncFillup, &out.AsyncFillup + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReplicatedMapSpec. @@ -1633,6 +1570,11 @@ func (in *TopicStatus) DeepCopy() *TopicStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UserCodeDeploymentConfig) DeepCopyInto(out *UserCodeDeploymentConfig) { *out = *in + if in.ClientEnabled != nil { + in, out := &in.ClientEnabled, &out.ClientEnabled + *out = new(bool) + **out = **in + } if in.BucketConfiguration != nil { in, out := &in.BucketConfiguration, &out.BucketConfiguration *out = new(BucketConfiguration) diff --git a/bundle.yaml b/bundle.yaml index 4636b5f3928..456224bf99e 100644 --- a/bundle.yaml +++ b/bundle.yaml @@ -51,11 +51,13 @@ spec: default: 0 description: Number of asynchronous backups. format: int32 + minimum: 0 type: integer backupCount: default: 1 description: Number of synchronous backups. format: int32 + minimum: 0 type: integer hazelcastResourceName: description: HazelcastResourceName defines the name of the Hazelcast @@ -104,6 +106,8 @@ spec: - Terminating type: string type: object + required: + - spec type: object served: true storage: true @@ -156,8 +160,8 @@ spec: failedHotBackupsHistoryLimit: default: 3 description: The number of failed finished hot backups to retain. - This is a pointer to distinguish between explicit zero and not specified. format: int32 + minimum: 0 type: integer hotBackupTemplate: description: Specifies the hot backup that will be created when executing @@ -208,8 +212,8 @@ spec: successfulHotBackupsHistoryLimit: default: 5 description: The number of successful finished hot backups to retain. - This is a pointer to distinguish between explicit zero and not specified. format: int32 + minimum: 0 type: integer suspend: default: false @@ -287,7 +291,7 @@ spec: spec: default: repository: docker.io/hazelcast/hazelcast - description: HazelcastSpec defines the desired state of Hazelcast + description: Initial values will be filled with its fields' default values. properties: agent: default: @@ -300,7 +304,7 @@ spec: description: Repository to pull Hazelcast Platform Operator Agent(https://github.com/hazelcast/platform-operator-agent) type: string version: - default: 0.1.10 + default: 0.1.11 description: Version of Hazelcast Platform Operator Agent. type: string type: object @@ -412,6 +416,7 @@ spec: jet: default: enabled: true + resourceUploadEnabled: false description: Jet Engine configuration properties: enabled: @@ -492,7 +497,6 @@ spec: restore: description: Restore configuration maxProperties: 1 - minProperties: 1 properties: bucketConfig: description: Bucket Configuration from which the backup will @@ -1726,8 +1730,6 @@ spec: are connected to cluster from the desired number of members in the format / type: string - required: - - readyMembers type: object members: description: Status of Hazelcast members @@ -1773,6 +1775,11 @@ spec: type: integer state: description: State represents the observed state of the member. + enum: + - PASSIVE + - ACTIVE + - SHUT_DOWN + - STARTING type: string uid: description: Uid is the unique member identifier within the @@ -1782,9 +1789,6 @@ spec: description: Version represents the Hazelcast version of the member. type: string - required: - - connected - - restartCount type: object type: array message: @@ -1814,11 +1818,12 @@ spec: state: description: State shows the current phase of the restore process of the cluster. + enum: + - Unknown + - Failed + - InProgress + - Succeeded type: string - required: - - remainingDataLoadTime - - remainingValidationTime - - state type: object type: object type: object @@ -1898,10 +1903,14 @@ spec: message: type: string state: + enum: + - Unknown + - Pending + - NotStarted + - InProgress + - Failure + - Success type: string - required: - - message - - state type: object required: - spec @@ -1963,7 +1972,7 @@ spec: spec: default: repository: docker.io/hazelcast/management-center - description: ManagementCenterSpec defines the desired state of ManagementCenter. + description: Initial values will be filled with its fields' default values. properties: externalConnectivity: default: @@ -3250,11 +3259,13 @@ spec: default: 0 description: Number of asynchronous backups. format: int32 + minimum: 0 type: integer backupCount: default: 1 description: Number of synchronous backups. format: int32 + minimum: 0 type: integer entryListeners: description: EntryListeners contains the configuration for the map-level @@ -3285,7 +3296,9 @@ spec: type: array eviction: default: + evictionPolicy: NONE maxSize: 0 + maxSizePolicy: PER_NODE description: Configuration for removing data from the map when it reaches its max size. It can be updated. properties: @@ -3370,7 +3383,6 @@ spec: - BITMAP type: string required: - - attributes - type type: object type: array @@ -3525,11 +3537,13 @@ spec: default: 0 description: Number of asynchronous backups. format: int32 + minimum: 0 type: integer backupCount: default: 1 description: Number of synchronous backups. format: int32 + minimum: 0 type: integer binary: default: false @@ -3580,6 +3594,8 @@ spec: - Terminating type: string type: object + required: + - spec type: object served: true storage: true @@ -3639,11 +3655,13 @@ spec: default: 0 description: Number of asynchronous backups. format: int32 + minimum: 0 type: integer backupCount: default: 1 description: Number of synchronous backups. format: int32 + minimum: 0 type: integer emptyQueueTTLSeconds: default: -1 @@ -3699,6 +3717,8 @@ spec: - Terminating type: string type: object + required: + - spec type: object served: true storage: true @@ -3802,6 +3822,8 @@ spec: - Terminating type: string type: object + required: + - spec type: object served: true storage: true @@ -3957,13 +3979,17 @@ spec: description: WanReplicationSpec defines the desired state of WanReplication properties: acknowledgement: + default: + timeout: 60000 + type: ACK_ON_OPERATION_COMPLETE description: Acknowledgement is the configuration for the condition when the next batch of WAN events are sent. properties: timeout: default: 60000 - description: Timeout represents the time the source cluster waits - for the acknowledgement. After timeout, the events will be resent. + description: Timeout represents the time in milliseconds the source + cluster waits for the acknowledgement. After timeout, the events + will be resent. format: int32 type: integer type: @@ -3976,6 +4002,9 @@ spec: type: string type: object batch: + default: + maximumDelay: 1000 + size: 500 description: Batch is the configuration for WAN events batch. properties: maximumDelay: @@ -3996,6 +4025,9 @@ spec: minLength: 1 type: string queue: + default: + capacity: 10000 + fullBehavior: DISCARD_AFTER_MUTATION description: Queue is the configuration for WAN events queue. properties: capacity: @@ -4032,7 +4064,6 @@ spec: minLength: 1 type: string required: - - kind - name type: object minItems: 1 @@ -4072,6 +4103,8 @@ spec: type: object type: object type: object + required: + - spec type: object served: true storage: true @@ -4583,6 +4616,8 @@ spec: valueFrom: fieldRef: fieldPath: metadata.name + - name: DEVELOPER_MODE_ENABLED + value: "true" image: hazelcast/hazelcast-platform-operator:latest-snapshot imagePullPolicy: IfNotPresent livenessProbe: diff --git a/config/crd/bases/hazelcast.com_caches.yaml b/config/crd/bases/hazelcast.com_caches.yaml index 5443c0a8f60..3eba94ffd24 100644 --- a/config/crd/bases/hazelcast.com_caches.yaml +++ b/config/crd/bases/hazelcast.com_caches.yaml @@ -52,11 +52,13 @@ spec: default: 0 description: Number of asynchronous backups. format: int32 + minimum: 0 type: integer backupCount: default: 1 description: Number of synchronous backups. format: int32 + minimum: 0 type: integer hazelcastResourceName: description: HazelcastResourceName defines the name of the Hazelcast @@ -105,6 +107,8 @@ spec: - Terminating type: string type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/hazelcast.com_cronhotbackups.yaml b/config/crd/bases/hazelcast.com_cronhotbackups.yaml index af20d40f9fb..2168de4af4d 100644 --- a/config/crd/bases/hazelcast.com_cronhotbackups.yaml +++ b/config/crd/bases/hazelcast.com_cronhotbackups.yaml @@ -45,8 +45,8 @@ spec: failedHotBackupsHistoryLimit: default: 3 description: The number of failed finished hot backups to retain. - This is a pointer to distinguish between explicit zero and not specified. format: int32 + minimum: 0 type: integer hotBackupTemplate: description: Specifies the hot backup that will be created when executing @@ -97,8 +97,8 @@ spec: successfulHotBackupsHistoryLimit: default: 5 description: The number of successful finished hot backups to retain. - This is a pointer to distinguish between explicit zero and not specified. format: int32 + minimum: 0 type: integer suspend: default: false diff --git a/config/crd/bases/hazelcast.com_hazelcasts.yaml b/config/crd/bases/hazelcast.com_hazelcasts.yaml index 7a99ca30d08..2e5e534bbdc 100644 --- a/config/crd/bases/hazelcast.com_hazelcasts.yaml +++ b/config/crd/bases/hazelcast.com_hazelcasts.yaml @@ -55,7 +55,7 @@ spec: spec: default: repository: docker.io/hazelcast/hazelcast - description: HazelcastSpec defines the desired state of Hazelcast + description: Initial values will be filled with its fields' default values. properties: agent: default: @@ -68,7 +68,7 @@ spec: description: Repository to pull Hazelcast Platform Operator Agent(https://github.com/hazelcast/platform-operator-agent) type: string version: - default: 0.1.10 + default: 0.1.11 description: Version of Hazelcast Platform Operator Agent. type: string type: object @@ -180,6 +180,7 @@ spec: jet: default: enabled: true + resourceUploadEnabled: false description: Jet Engine configuration properties: enabled: @@ -260,7 +261,6 @@ spec: restore: description: Restore configuration maxProperties: 1 - minProperties: 1 properties: bucketConfig: description: Bucket Configuration from which the backup will @@ -1494,8 +1494,6 @@ spec: are connected to cluster from the desired number of members in the format / type: string - required: - - readyMembers type: object members: description: Status of Hazelcast members @@ -1541,6 +1539,11 @@ spec: type: integer state: description: State represents the observed state of the member. + enum: + - PASSIVE + - ACTIVE + - SHUT_DOWN + - STARTING type: string uid: description: Uid is the unique member identifier within the @@ -1550,9 +1553,6 @@ spec: description: Version represents the Hazelcast version of the member. type: string - required: - - connected - - restartCount type: object type: array message: @@ -1582,11 +1582,12 @@ spec: state: description: State shows the current phase of the restore process of the cluster. + enum: + - Unknown + - Failed + - InProgress + - Succeeded type: string - required: - - remainingDataLoadTime - - remainingValidationTime - - state type: object type: object type: object diff --git a/config/crd/bases/hazelcast.com_hotbackups.yaml b/config/crd/bases/hazelcast.com_hotbackups.yaml index b8f3c61818c..947d20b7eb9 100644 --- a/config/crd/bases/hazelcast.com_hotbackups.yaml +++ b/config/crd/bases/hazelcast.com_hotbackups.yaml @@ -70,10 +70,14 @@ spec: message: type: string state: + enum: + - Unknown + - Pending + - NotStarted + - InProgress + - Failure + - Success type: string - required: - - message - - state type: object required: - spec diff --git a/config/crd/bases/hazelcast.com_managementcenters.yaml b/config/crd/bases/hazelcast.com_managementcenters.yaml index 5eb3b70c5c9..40f363ab0e0 100644 --- a/config/crd/bases/hazelcast.com_managementcenters.yaml +++ b/config/crd/bases/hazelcast.com_managementcenters.yaml @@ -51,7 +51,7 @@ spec: spec: default: repository: docker.io/hazelcast/management-center - description: ManagementCenterSpec defines the desired state of ManagementCenter. + description: Initial values will be filled with its fields' default values. properties: externalConnectivity: default: diff --git a/config/crd/bases/hazelcast.com_maps.yaml b/config/crd/bases/hazelcast.com_maps.yaml index 8c03567a763..f733ad5974f 100644 --- a/config/crd/bases/hazelcast.com_maps.yaml +++ b/config/crd/bases/hazelcast.com_maps.yaml @@ -49,11 +49,13 @@ spec: default: 0 description: Number of asynchronous backups. format: int32 + minimum: 0 type: integer backupCount: default: 1 description: Number of synchronous backups. format: int32 + minimum: 0 type: integer entryListeners: description: EntryListeners contains the configuration for the map-level @@ -84,7 +86,9 @@ spec: type: array eviction: default: + evictionPolicy: NONE maxSize: 0 + maxSizePolicy: PER_NODE description: Configuration for removing data from the map when it reaches its max size. It can be updated. properties: @@ -169,7 +173,6 @@ spec: - BITMAP type: string required: - - attributes - type type: object type: array diff --git a/config/crd/bases/hazelcast.com_multimaps.yaml b/config/crd/bases/hazelcast.com_multimaps.yaml index 0aef3f1b8e4..4b236bc9ac9 100644 --- a/config/crd/bases/hazelcast.com_multimaps.yaml +++ b/config/crd/bases/hazelcast.com_multimaps.yaml @@ -51,11 +51,13 @@ spec: default: 0 description: Number of asynchronous backups. format: int32 + minimum: 0 type: integer backupCount: default: 1 description: Number of synchronous backups. format: int32 + minimum: 0 type: integer binary: default: false @@ -106,6 +108,8 @@ spec: - Terminating type: string type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/hazelcast.com_queues.yaml b/config/crd/bases/hazelcast.com_queues.yaml index fab4d6577de..1a72b3e97ac 100644 --- a/config/crd/bases/hazelcast.com_queues.yaml +++ b/config/crd/bases/hazelcast.com_queues.yaml @@ -52,11 +52,13 @@ spec: default: 0 description: Number of asynchronous backups. format: int32 + minimum: 0 type: integer backupCount: default: 1 description: Number of synchronous backups. format: int32 + minimum: 0 type: integer emptyQueueTTLSeconds: default: -1 @@ -112,6 +114,8 @@ spec: - Terminating type: string type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/hazelcast.com_replicatedmaps.yaml b/config/crd/bases/hazelcast.com_replicatedmaps.yaml index 7b564db55db..9c9b3b0c959 100644 --- a/config/crd/bases/hazelcast.com_replicatedmaps.yaml +++ b/config/crd/bases/hazelcast.com_replicatedmaps.yaml @@ -96,6 +96,8 @@ spec: - Terminating type: string type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/hazelcast.com_wanreplications.yaml b/config/crd/bases/hazelcast.com_wanreplications.yaml index 9b78cb7aea2..e917aa4763b 100644 --- a/config/crd/bases/hazelcast.com_wanreplications.yaml +++ b/config/crd/bases/hazelcast.com_wanreplications.yaml @@ -48,13 +48,17 @@ spec: description: WanReplicationSpec defines the desired state of WanReplication properties: acknowledgement: + default: + timeout: 60000 + type: ACK_ON_OPERATION_COMPLETE description: Acknowledgement is the configuration for the condition when the next batch of WAN events are sent. properties: timeout: default: 60000 - description: Timeout represents the time the source cluster waits - for the acknowledgement. After timeout, the events will be resent. + description: Timeout represents the time in milliseconds the source + cluster waits for the acknowledgement. After timeout, the events + will be resent. format: int32 type: integer type: @@ -67,6 +71,9 @@ spec: type: string type: object batch: + default: + maximumDelay: 1000 + size: 500 description: Batch is the configuration for WAN events batch. properties: maximumDelay: @@ -87,6 +94,9 @@ spec: minLength: 1 type: string queue: + default: + capacity: 10000 + fullBehavior: DISCARD_AFTER_MUTATION description: Queue is the configuration for WAN events queue. properties: capacity: @@ -123,7 +133,6 @@ spec: minLength: 1 type: string required: - - kind - name type: object minItems: 1 @@ -163,6 +172,8 @@ spec: type: object type: object type: object + required: + - spec type: object served: true storage: true diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index b2bd0331358..bc3299ddceb 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -9,6 +9,9 @@ images: newName: hazelcast/hazelcast-platform-operator newTag: latest-snapshot patches: +- path: enable_developer_mode.yaml + target: + kind: Deployment - path: remove_security_context.yaml target: kind: Deployment diff --git a/config/manifests/bases/hazelcast-platform-operator.clusterserviceversion.yaml b/config/manifests/bases/hazelcast-platform-operator.clusterserviceversion.yaml index 9dc144ad2b2..0118dafab96 100644 --- a/config/manifests/bases/hazelcast-platform-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/hazelcast-platform-operator.clusterserviceversion.yaml @@ -15,6 +15,11 @@ spec: apiservicedefinitions: {} customresourcedefinitions: owned: + - description: Cache is the Schema for the caches API + displayName: Cache + kind: Cache + name: caches.hazelcast.com + version: v1alpha1 - description: CronHotBackup is the Schema for the cronhotbackups API displayName: Cron Hot Backup kind: CronHotBackup diff --git a/controllers/hazelcast/cache_controller.go b/controllers/hazelcast/cache_controller.go index 4cfbde0deed..2b389976c85 100644 --- a/controllers/hazelcast/cache_controller.go +++ b/controllers/hazelcast/cache_controller.go @@ -120,7 +120,7 @@ func fillCacheConfigInput(cacheInput *codecTypes.CacheConfigInput, c *hazelcastv cacheInput.Name = c.GetDSName() cs := c.Spec cacheInput.BackupCount = *cs.BackupCount - cacheInput.AsyncBackupCount = *cs.AsyncBackupCount + cacheInput.AsyncBackupCount = cs.AsyncBackupCount cacheInput.KeyType = cs.KeyType cacheInput.ValueType = cs.ValueType cacheInput.HotRestartConfig.Enabled = cs.PersistenceEnabled diff --git a/controllers/hazelcast/hazelcast_resources.go b/controllers/hazelcast/hazelcast_resources.go index c9c28bb6e7e..008d798a802 100644 --- a/controllers/hazelcast/hazelcast_resources.go +++ b/controllers/hazelcast/hazelcast_resources.go @@ -599,6 +599,9 @@ func hazelcastConfigMapStruct(h *hazelcastv1alpha1.Hazelcast) config.Hazelcast { }, }, }, + UserCodeDeployment: config.UserCodeDeployment{ + Enabled: h.Spec.UserCodeDeployment.ClientEnabled, + }, } if h.Spec.JetEngineConfiguration.IsConfigured() { @@ -608,12 +611,6 @@ func hazelcastConfigMapStruct(h *hazelcastv1alpha1.Hazelcast) config.Hazelcast { } } - if h.Spec.UserCodeDeployment != nil { - cfg.UserCodeDeployment = config.UserCodeDeployment{ - Enabled: h.Spec.UserCodeDeployment.ClientEnabled, - } - } - if h.Spec.ExposeExternally.UsesNodeName() { cfg.Network.Join.Kubernetes.UseNodeNameAsExternalAddress = pointer.Bool(true) } @@ -806,11 +803,11 @@ func createMapConfig(ctx context.Context, c client.Client, hz *hazelcastv1alpha1 ms := m.Spec mc := config.Map{ BackupCount: *ms.BackupCount, - AsyncBackupCount: *ms.AsyncBackupCount, - TimeToLiveSeconds: *ms.TimeToLiveSeconds, + AsyncBackupCount: ms.AsyncBackupCount, + TimeToLiveSeconds: ms.TimeToLiveSeconds, ReadBackupData: false, Eviction: config.MapEviction{ - Size: *ms.Eviction.MaxSize, + Size: ms.Eviction.MaxSize, MaxSizePolicy: string(ms.Eviction.MaxSizePolicy), EvictionPolicy: string(ms.Eviction.EvictionPolicy), }, @@ -918,7 +915,7 @@ func createMultiMapConfig(mm *hazelcastv1alpha1.MultiMap) config.MultiMap { mms := mm.Spec return config.MultiMap{ BackupCount: *mms.BackupCount, - AsyncBackupCount: *mms.AsyncBackupCount, + AsyncBackupCount: mms.AsyncBackupCount, Binary: mms.Binary, CollectionType: string(mms.CollectionType), StatisticsEnabled: n.DefaultMultiMapStatisticsEnabled, @@ -933,9 +930,9 @@ func createQueueConfig(q *hazelcastv1alpha1.Queue) config.Queue { qs := q.Spec return config.Queue{ BackupCount: *qs.BackupCount, - AsyncBackupCount: *qs.AsyncBackupCount, + AsyncBackupCount: qs.AsyncBackupCount, EmptyQueueTtl: *qs.EmptyQueueTtlSeconds, - MaxSize: *qs.MaxSize, + MaxSize: qs.MaxSize, StatisticsEnabled: n.DefaultQueueStatisticsEnabled, PriorityComparatorClass: qs.PriorityComparatorClassName, MergePolicy: config.MergePolicy{ @@ -949,7 +946,7 @@ func createCacheConfig(c *hazelcastv1alpha1.Cache) config.Cache { cs := c.Spec cache := config.Cache{ BackupCount: *cs.BackupCount, - AsyncBackupCount: *cs.AsyncBackupCount, + AsyncBackupCount: cs.AsyncBackupCount, StatisticsEnabled: n.DefaultCacheStatisticsEnabled, ManagementEnabled: n.DefaultCacheManagementEnabled, ReadThrough: n.DefaultCacheReadThrough, @@ -991,7 +988,7 @@ func createReplicatedMapConfig(rm *hazelcastv1alpha1.ReplicatedMap) config.Repli rms := rm.Spec return config.ReplicatedMap{ InMemoryFormat: string(rms.InMemoryFormat), - AsyncFillup: rms.AsyncFillup, + AsyncFillup: *rms.AsyncFillup, StatisticsEnabled: n.DefaultReplicatedMapStatisticsEnabled, MergePolicy: config.MergePolicy{ ClassName: n.DefaultReplicatedMapMergePolicy, @@ -1086,24 +1083,12 @@ func (r *HazelcastReconciler) reconcileStatefulset(ctx context.Context, h *hazel sts.Spec.Template.Spec.Containers[0].Image = h.DockerImage() sts.Spec.Template.Spec.Containers[0].Env = env(h) sts.Spec.Template.Spec.Containers[0].ImagePullPolicy = h.Spec.ImagePullPolicy + sts.Spec.Template.Spec.Containers[0].Resources = h.Spec.Resources - if h.Spec.Scheduling != nil { - sts.Spec.Template.Spec.Affinity = h.Spec.Scheduling.Affinity - sts.Spec.Template.Spec.Tolerations = h.Spec.Scheduling.Tolerations - sts.Spec.Template.Spec.NodeSelector = h.Spec.Scheduling.NodeSelector - sts.Spec.Template.Spec.TopologySpreadConstraints = h.Spec.Scheduling.TopologySpreadConstraints - } else { - sts.Spec.Template.Spec.Affinity = nil - sts.Spec.Template.Spec.Tolerations = nil - sts.Spec.Template.Spec.NodeSelector = nil - sts.Spec.Template.Spec.TopologySpreadConstraints = nil - } - - if h.Spec.Resources != nil { - sts.Spec.Template.Spec.Containers[0].Resources = *h.Spec.Resources - } else { - sts.Spec.Template.Spec.Containers[0].Resources = v1.ResourceRequirements{} - } + sts.Spec.Template.Spec.Affinity = h.Spec.Scheduling.Affinity + sts.Spec.Template.Spec.Tolerations = h.Spec.Scheduling.Tolerations + sts.Spec.Template.Spec.NodeSelector = h.Spec.Scheduling.NodeSelector + sts.Spec.Template.Spec.TopologySpreadConstraints = h.Spec.Scheduling.TopologySpreadConstraints sts.Spec.Template.Spec.InitContainers, err = initContainers(ctx, h, r.Client) if err != nil { @@ -1545,8 +1530,8 @@ func (r *HazelcastReconciler) ensureClusterActive(ctx context.Context, client hz return nil } - // make sure restore was successfull - if h.Status.Restore == nil { + // make sure restore was successful + if h.Status.Restore == (hazelcastv1alpha1.RestoreStatus{}) { return nil } diff --git a/controllers/hazelcast/hazelcast_resources_test.go b/controllers/hazelcast/hazelcast_resources_test.go index 0a2c6ea4f5d..19f98bf6cce 100644 --- a/controllers/hazelcast/hazelcast_resources_test.go +++ b/controllers/hazelcast/hazelcast_resources_test.go @@ -38,7 +38,7 @@ func Test_hazelcastConfigMapData(t *testing.T) { DataStructureSpec: hazelcastv1alpha1.DataStructureSpec{ HazelcastResourceName: meta.Name, BackupCount: pointer.Int32(1), - AsyncBackupCount: pointer.Int32(0), + AsyncBackupCount: 0, }, } cacheStatus := hazelcastv1alpha1.CacheStatus{ diff --git a/controllers/hazelcast/hazelcast_status.go b/controllers/hazelcast/hazelcast_status.go index 7ff4065ed95..b01c9239c4d 100644 --- a/controllers/hazelcast/hazelcast_status.go +++ b/controllers/hazelcast/hazelcast_status.go @@ -164,7 +164,7 @@ func (r *HazelcastReconciler) update(ctx context.Context, h *hazelcastv1alpha1.H } } if rs := options.restoreState.RestoreState(); h.Spec.Persistence.IsEnabled() && rs != hazelcastv1alpha1.RestoreUnknown { - h.Status.Restore = &hazelcastv1alpha1.RestoreStatus{ + h.Status.Restore = hazelcastv1alpha1.RestoreStatus{ State: options.restoreState.RestoreState(), RemainingDataLoadTime: options.restoreState.RemainingDataLoadTimeSec(), RemainingValidationTime: options.restoreState.RemainingValidationTimeSec(), diff --git a/controllers/hazelcast/map_controller.go b/controllers/hazelcast/map_controller.go index 65f89a87616..2ee85dc4d73 100644 --- a/controllers/hazelcast/map_controller.go +++ b/controllers/hazelcast/map_controller.go @@ -233,11 +233,11 @@ func (r *MapReconciler) ReconcileMapConfig( if createdBefore { req = codec.EncodeMCUpdateMapConfigRequest( m.MapName(), - *m.Spec.TimeToLiveSeconds, - *m.Spec.MaxIdleSeconds, + m.Spec.TimeToLiveSeconds, + m.Spec.MaxIdleSeconds, hazelcastv1alpha1.EncodeEvictionPolicyType[m.Spec.Eviction.EvictionPolicy], false, - *m.Spec.Eviction.MaxSize, + m.Spec.Eviction.MaxSize, hazelcastv1alpha1.EncodeMaxSizePolicy[m.Spec.Eviction.MaxSizePolicy], ) } else { @@ -278,14 +278,14 @@ func fillAddMapConfigInput(ctx context.Context, c client.Client, mapInput *codec ms := m.Spec mapInput.BackupCount = *ms.BackupCount - mapInput.AsyncBackupCount = *ms.AsyncBackupCount - mapInput.TimeToLiveSeconds = *ms.TimeToLiveSeconds - mapInput.MaxIdleSeconds = *ms.MaxIdleSeconds - if ms.Eviction != nil { - mapInput.EvictionConfig.EvictionPolicy = string(ms.Eviction.EvictionPolicy) - mapInput.EvictionConfig.Size = *ms.Eviction.MaxSize - mapInput.EvictionConfig.MaxSizePolicy = string(ms.Eviction.MaxSizePolicy) - } + mapInput.AsyncBackupCount = ms.AsyncBackupCount + mapInput.TimeToLiveSeconds = ms.TimeToLiveSeconds + mapInput.MaxIdleSeconds = ms.MaxIdleSeconds + + mapInput.EvictionConfig.EvictionPolicy = string(ms.Eviction.EvictionPolicy) + mapInput.EvictionConfig.Size = ms.Eviction.MaxSize + mapInput.EvictionConfig.MaxSizePolicy = string(ms.Eviction.MaxSizePolicy) + mapInput.IndexConfigs = copyIndexes(ms.Indexes) mapInput.HotRestartConfig.Enabled = ms.PersistenceEnabled mapInput.WanReplicationRef = defaultWanReplicationRefCodec(hz, m) diff --git a/controllers/hazelcast/multimap_controller.go b/controllers/hazelcast/multimap_controller.go index 5aef90e7f6f..5be9f9e3927 100644 --- a/controllers/hazelcast/multimap_controller.go +++ b/controllers/hazelcast/multimap_controller.go @@ -100,7 +100,7 @@ func fillMultiMapConfigInput(multiMapInput *codecTypes.MultiMapConfig, mm *hazel mms := mm.Spec multiMapInput.BackupCount = *mms.BackupCount - multiMapInput.AsyncBackupCount = *mms.AsyncBackupCount + multiMapInput.AsyncBackupCount = mms.AsyncBackupCount multiMapInput.Binary = mms.Binary multiMapInput.CollectionType = string(mms.CollectionType) } diff --git a/controllers/hazelcast/queue_controller.go b/controllers/hazelcast/queue_controller.go index 4debfbadc3f..93c453815bd 100644 --- a/controllers/hazelcast/queue_controller.go +++ b/controllers/hazelcast/queue_controller.go @@ -116,9 +116,9 @@ func fillQueueConfigInput(queueInput *codecTypes.QueueConfigInput, q *hazelcastv queueInput.Name = q.GetDSName() qs := q.Spec queueInput.BackupCount = *qs.BackupCount - queueInput.AsyncBackupCount = *qs.AsyncBackupCount + queueInput.AsyncBackupCount = qs.AsyncBackupCount queueInput.EmptyQueueTtl = *qs.EmptyQueueTtlSeconds - queueInput.MaxSize = *qs.MaxSize + queueInput.MaxSize = qs.MaxSize queueInput.PriorityComparatorClassName = qs.PriorityComparatorClassName } diff --git a/controllers/hazelcast/replicatedmap_controller.go b/controllers/hazelcast/replicatedmap_controller.go index 42039b076fb..51ec55b44b0 100644 --- a/controllers/hazelcast/replicatedmap_controller.go +++ b/controllers/hazelcast/replicatedmap_controller.go @@ -100,7 +100,7 @@ func fillReplicatedConfigInput(replicatedMapInput *codecTypes.ReplicatedMapConfi rms := rm.Spec replicatedMapInput.InMemoryFormat = string(rms.InMemoryFormat) - replicatedMapInput.AsyncFillup = rms.AsyncFillup + replicatedMapInput.AsyncFillup = *rms.AsyncFillup } func (r *ReplicatedMapReconciler) validateReplicatedMapConfigPersistence(ctx context.Context, rm *hazelcastv1alpha1.ReplicatedMap) (bool, error) { diff --git a/controllers/managementcenter/managementcenter_resources.go b/controllers/managementcenter/managementcenter_resources.go index 7694cd60ad4..8b986695d37 100644 --- a/controllers/managementcenter/managementcenter_resources.go +++ b/controllers/managementcenter/managementcenter_resources.go @@ -279,23 +279,13 @@ func (r *ManagementCenterReconciler) reconcileStatefulset(ctx context.Context, m sts.Spec.Template.Spec.Containers[0].Image = mc.DockerImage() sts.Spec.Template.Spec.Containers[0].Env = env(mc) sts.Spec.Template.Spec.Containers[0].ImagePullPolicy = mc.Spec.ImagePullPolicy - if mc.Spec.Scheduling != nil { - sts.Spec.Template.Spec.Affinity = mc.Spec.Scheduling.Affinity - sts.Spec.Template.Spec.Tolerations = mc.Spec.Scheduling.Tolerations - sts.Spec.Template.Spec.NodeSelector = mc.Spec.Scheduling.NodeSelector - sts.Spec.Template.Spec.TopologySpreadConstraints = mc.Spec.Scheduling.TopologySpreadConstraints - } else { - sts.Spec.Template.Spec.Affinity = nil - sts.Spec.Template.Spec.Tolerations = nil - sts.Spec.Template.Spec.NodeSelector = nil - sts.Spec.Template.Spec.TopologySpreadConstraints = nil - } + sts.Spec.Template.Spec.Containers[0].Resources = mc.Spec.Resources + + sts.Spec.Template.Spec.Affinity = mc.Spec.Scheduling.Affinity + sts.Spec.Template.Spec.Tolerations = mc.Spec.Scheduling.Tolerations + sts.Spec.Template.Spec.NodeSelector = mc.Spec.Scheduling.NodeSelector + sts.Spec.Template.Spec.TopologySpreadConstraints = mc.Spec.Scheduling.TopologySpreadConstraints - if mc.Spec.Resources != nil { - sts.Spec.Template.Spec.Containers[0].Resources = *mc.Spec.Resources - } else { - sts.Spec.Template.Spec.Containers[0].Resources = v1.ResourceRequirements{} - } return nil }) if opResult != controllerutil.OperationResultNone { diff --git a/internal/config/hazelcast.go b/internal/config/hazelcast.go index a1c079bba48..d100c614171 100644 --- a/internal/config/hazelcast.go +++ b/internal/config/hazelcast.go @@ -158,7 +158,7 @@ type Topic struct { } type UserCodeDeployment struct { - Enabled bool `yaml:"enabled,omitempty"` + Enabled *bool `yaml:"enabled,omitempty"` ClassCacheMode string `yaml:"class-cache-mode,omitempty"` ProviderMode string `yaml:"provider-mode,omitempty"` BlacklistPrefixes string `yaml:"blacklist-prefixes,omitempty"` diff --git a/internal/phonehome/phonehome.go b/internal/phonehome/phonehome.go index b0217ca5653..1bc63e037e1 100644 --- a/internal/phonehome/phonehome.go +++ b/internal/phonehome/phonehome.go @@ -173,7 +173,7 @@ func (phm *PhoneHomeData) fillHazelcastMetrics(cl client.Client) { phm.ExposeExternally.addUsageMetrics(hz.Spec.ExposeExternally) phm.BackupAndRestore.addUsageMetrics(hz.Spec.Persistence) - phm.UserCodeDeployment.addUsageMetrics(hz.Spec.UserCodeDeployment) + phm.UserCodeDeployment.addUsageMetrics(&hz.Spec.UserCodeDeployment) createdMemberCount += int(*hz.Spec.ClusterSize) executorServiceCount += len(hz.Spec.ExecutorServices) + len(hz.Spec.DurableExecutorServices) + len(hz.Spec.ScheduledExecutorServices) } @@ -229,7 +229,7 @@ func (ucd *UserCodeDeployment) addUsageMetrics(hucd *hazelcastv1alpha1.UserCodeD if hucd == nil { return } - if hucd.ClientEnabled { + if hucd.ClientEnabled != nil && *hucd.ClientEnabled { ucd.ClientEnabled++ } if hucd.IsBucketEnabled() { diff --git a/test/e2e/config/hazelcast/config.go b/test/e2e/config/hazelcast/config.go index 89b8cf522f0..fb1a3ec85fd 100644 --- a/test/e2e/config/hazelcast/config.go +++ b/test/e2e/config/hazelcast/config.go @@ -156,7 +156,7 @@ var ( // multiNode case if nodeName == "" { - hz.Spec.Scheduling = &hazelcastv1alpha1.SchedulingConfiguration{ + hz.Spec.Scheduling = hazelcastv1alpha1.SchedulingConfiguration{ TopologySpreadConstraints: []corev1.TopologySpreadConstraint{ { MaxSkew: int32(1), @@ -176,7 +176,7 @@ var ( } // singleNode case - hz.Spec.Scheduling = &hazelcastv1alpha1.SchedulingConfiguration{ + hz.Spec.Scheduling = hazelcastv1alpha1.SchedulingConfiguration{ NodeSelector: map[string]string{ "kubernetes.io/hostname": nodeName, }, @@ -209,7 +209,7 @@ var ( } } - HazelcastRestore = func(hz *hazelcastv1alpha1.Hazelcast, restoreConfig *hazelcastv1alpha1.RestoreConfiguration) *hazelcastv1alpha1.Hazelcast { + HazelcastRestore = func(hz *hazelcastv1alpha1.Hazelcast, restoreConfig hazelcastv1alpha1.RestoreConfiguration) *hazelcastv1alpha1.Hazelcast { hzRestore := &hazelcastv1alpha1.Hazelcast{ ObjectMeta: v1.ObjectMeta{ Name: hz.Name, @@ -234,7 +234,7 @@ var ( Repository: repo(ee), Version: naming.HazelcastVersion, LicenseKeySecret: licenseKey(ee), - UserCodeDeployment: &hazelcastv1alpha1.UserCodeDeploymentConfig{ + UserCodeDeployment: hazelcastv1alpha1.UserCodeDeploymentConfig{ BucketConfiguration: &hazelcastv1alpha1.BucketConfiguration{ Secret: s, BucketURI: bkt, diff --git a/test/e2e/config/managementcenter/config.go b/test/e2e/config/managementcenter/config.go index ec7f6156f0b..f810f7955ca 100644 --- a/test/e2e/config/managementcenter/config.go +++ b/test/e2e/config/managementcenter/config.go @@ -4,6 +4,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/pointer" hazelcastv1alpha1 "github.com/hazelcast/hazelcast-platform-operator/api/v1alpha1" "github.com/hazelcast/hazelcast-platform-operator/internal/naming" @@ -21,11 +22,11 @@ var ( Repository: naming.MCRepo, Version: naming.MCVersion, LicenseKeySecret: licenseKey(ee), - ExternalConnectivity: &hazelcastv1alpha1.ExternalConnectivityConfiguration{ + ExternalConnectivity: hazelcastv1alpha1.ExternalConnectivityConfiguration{ Type: hazelcastv1alpha1.ExternalConnectivityTypeLoadBalancer, }, - Persistence: &hazelcastv1alpha1.PersistenceConfiguration{ - Enabled: true, + Persistence: hazelcastv1alpha1.PersistenceConfiguration{ + Enabled: pointer.Bool(true), Size: &[]resource.Quantity{resource.MustParse("10Gi")}[0], }, }, @@ -43,7 +44,7 @@ var ( Repository: naming.MCRepo, Version: naming.MCVersion, LicenseKeySecret: licenseKey(ee), - ExternalConnectivity: &hazelcastv1alpha1.ExternalConnectivityConfiguration{ + ExternalConnectivity: hazelcastv1alpha1.ExternalConnectivityConfiguration{ Type: hazelcastv1alpha1.ExternalConnectivityTypeLoadBalancer, }, HazelcastClusters: []hazelcastv1alpha1.HazelcastClusterConfig{ @@ -52,8 +53,8 @@ var ( Address: "hazelcast", }, }, - Persistence: &hazelcastv1alpha1.PersistenceConfiguration{ - Enabled: false, + Persistence: hazelcastv1alpha1.PersistenceConfiguration{ + Enabled: pointer.Bool(false), }, }, } diff --git a/test/e2e/hazelcast_backup_slow_test.go b/test/e2e/hazelcast_backup_slow_test.go index 1f1de77da05..1f494b86530 100644 --- a/test/e2e/hazelcast_backup_slow_test.go +++ b/test/e2e/hazelcast_backup_slow_test.go @@ -109,7 +109,7 @@ var _ = Describe("Hazelcast Backup", Label("backup_slow"), func() { DiscoveryServiceType: corev1.ServiceTypeLoadBalancer, MemberAccess: hazelcastcomv1alpha1.MemberAccessLoadBalancer, } - hazelcast.Spec.Resources = &corev1.ResourceRequirements{ + hazelcast.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(pvcSizeInGb) + "Gi")}, } @@ -135,7 +135,7 @@ var _ = Describe("Hazelcast Backup", Label("backup_slow"), func() { By("creating new Hazelcast cluster from the existing backup") hazelcast = hazelcastconfig.HazelcastPersistencePVC(hzLookupKey, clusterSize, labels) - hazelcast.Spec.Persistence.Restore = &hazelcastcomv1alpha1.RestoreConfiguration{ + hazelcast.Spec.Persistence.Restore = hazelcastcomv1alpha1.RestoreConfiguration{ HotBackupResourceName: hotBackup.Name, } hazelcast.Spec.ExposeExternally = &hazelcastcomv1alpha1.ExposeExternallyConfiguration{ @@ -143,7 +143,7 @@ var _ = Describe("Hazelcast Backup", Label("backup_slow"), func() { DiscoveryServiceType: corev1.ServiceTypeLoadBalancer, MemberAccess: hazelcastcomv1alpha1.MemberAccessLoadBalancer, } - hazelcast.Spec.Resources = &corev1.ResourceRequirements{ + hazelcast.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(pvcSizeInGb) + "Gi")}, } @@ -178,7 +178,7 @@ var _ = Describe("Hazelcast Backup", Label("backup_slow"), func() { DiscoveryServiceType: corev1.ServiceTypeLoadBalancer, MemberAccess: hazelcastcomv1alpha1.MemberAccessLoadBalancer, } - hazelcast.Spec.Resources = &corev1.ResourceRequirements{ + hazelcast.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(pvcSizeInGb) + "Gi")}, } @@ -209,14 +209,14 @@ var _ = Describe("Hazelcast Backup", Label("backup_slow"), func() { By("creating cluster from external backup") hazelcast = hazelcastconfig.HazelcastPersistencePVC(hzLookupKey, clusterSize, labels) - hazelcast.Spec.Persistence.Restore = &hazelcastcomv1alpha1.RestoreConfiguration{ + hazelcast.Spec.Persistence.Restore = hazelcastcomv1alpha1.RestoreConfiguration{ HotBackupResourceName: hotBackup.Name} hazelcast.Spec.ExposeExternally = &hazelcastcomv1alpha1.ExposeExternallyConfiguration{ Type: hazelcastcomv1alpha1.ExposeExternallyTypeSmart, DiscoveryServiceType: corev1.ServiceTypeLoadBalancer, MemberAccess: hazelcastcomv1alpha1.MemberAccessLoadBalancer, } - hazelcast.Spec.Resources = &corev1.ResourceRequirements{ + hazelcast.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(pvcSizeInGb) + "Gi")}, } @@ -249,7 +249,7 @@ var _ = Describe("Hazelcast Backup", Label("backup_slow"), func() { DiscoveryServiceType: corev1.ServiceTypeLoadBalancer, MemberAccess: hazelcastcomv1alpha1.MemberAccessLoadBalancer, } - hazelcast.Spec.Resources = &corev1.ResourceRequirements{ + hazelcast.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(pvcSizeInGb) + "Gi")}, } @@ -336,7 +336,7 @@ var _ = Describe("Hazelcast Backup", Label("backup_slow"), func() { By("creating cluster from from first backup") hazelcast = hazelcastconfig.HazelcastPersistencePVC(hzLookupKey, clusterSize, labels) - hazelcast.Spec.Persistence.Restore = &hazelcastcomv1alpha1.RestoreConfiguration{ + hazelcast.Spec.Persistence.Restore = hazelcastcomv1alpha1.RestoreConfiguration{ HotBackupResourceName: hotBackup.Name, } CreateHazelcastCR(hazelcast) @@ -351,7 +351,7 @@ var _ = Describe("Hazelcast Backup", Label("backup_slow"), func() { By("creating cluster from from second backup") hazelcast = hazelcastconfig.HazelcastPersistencePVC(hzLookupKey, clusterSize, labels) - hazelcast.Spec.Persistence.Restore = &hazelcastcomv1alpha1.RestoreConfiguration{ + hazelcast.Spec.Persistence.Restore = hazelcastcomv1alpha1.RestoreConfiguration{ HotBackupResourceName: hotBackup2.Name, } CreateHazelcastCR(hazelcast) diff --git a/test/e2e/hazelcast_cache_persistence_test.go b/test/e2e/hazelcast_cache_persistence_test.go index 8c0bcd9c4f4..eae63020077 100644 --- a/test/e2e/hazelcast_cache_persistence_test.go +++ b/test/e2e/hazelcast_cache_persistence_test.go @@ -99,7 +99,7 @@ var _ = Describe("Hazelcast Cache Config with Persistence", Label("cache_persist By("creating new Hazelcast cluster from existing backup") hazelcast = hazelcastconfig.HazelcastPersistencePVC(hzLookupKey, clusterSize, labels) - hazelcast.Spec.Persistence.Restore = &hazelcastv1alpha1.RestoreConfiguration{ + hazelcast.Spec.Persistence.Restore = hazelcastv1alpha1.RestoreConfiguration{ HotBackupResourceName: hotBackup.Name, } diff --git a/test/e2e/hazelcast_cache_test.go b/test/e2e/hazelcast_cache_test.go index 816c118680f..47bf5b5c3ec 100644 --- a/test/e2e/hazelcast_cache_test.go +++ b/test/e2e/hazelcast_cache_test.go @@ -93,7 +93,7 @@ var _ = Describe("Hazelcast Cache Config", Label("cache"), func() { By("failing to update cache config") q.Spec.BackupCount = pointer.Int32(5) - q.Spec.AsyncBackupCount = pointer.Int32(20) + q.Spec.AsyncBackupCount = 20 Expect(k8sClient.Update(context.Background(), q)).Should(Succeed()) assertDataStructureStatus(chLookupKey, hazelcastcomv1alpha1.DataStructureFailed, &hazelcastcomv1alpha1.Cache{}) }) diff --git a/test/e2e/hazelcast_map_persistence_test.go b/test/e2e/hazelcast_map_persistence_test.go index b9e8f32f871..05c08845068 100644 --- a/test/e2e/hazelcast_map_persistence_test.go +++ b/test/e2e/hazelcast_map_persistence_test.go @@ -92,7 +92,7 @@ var _ = Describe("Hazelcast Map Config with Persistence", Label("map_persistence By("creating new Hazelcast cluster from existing backup") hazelcast = hazelcastconfig.HazelcastPersistencePVC(hzLookupKey, clusterSize, labels) - hazelcast.Spec.Persistence.Restore = &hazelcastv1alpha1.RestoreConfiguration{ + hazelcast.Spec.Persistence.Restore = hazelcastv1alpha1.RestoreConfiguration{ HotBackupResourceName: hotBackup.Name, } @@ -119,7 +119,7 @@ var _ = Describe("Hazelcast Map Config with Persistence", Label("map_persistence By("creating the map configs") for i, mapp := range maps { m := hazelcastconfig.DefaultMap(types.NamespacedName{Name: mapp, Namespace: hazelcast.Namespace}, hazelcast.Name, labels) - m.Spec.Eviction = &hazelcastv1alpha1.EvictionConfig{MaxSize: pointer.Int32(int32(i) * 100)} + m.Spec.Eviction = hazelcastv1alpha1.EvictionConfig{MaxSize: int32(i) * 100} m.Spec.HazelcastResourceName = hazelcast.Name if mapp == "mapfail" { m.Spec.HazelcastResourceName = "failedHz" diff --git a/test/e2e/hazelcast_map_test.go b/test/e2e/hazelcast_map_test.go index db537f33f56..a8790f9550a 100644 --- a/test/e2e/hazelcast_map_test.go +++ b/test/e2e/hazelcast_map_test.go @@ -21,9 +21,9 @@ var _ = Describe("Hazelcast Map Config", Label("map"), func() { configEqualsSpec := func(mapSpec *hazelcastcomv1alpha1.MapSpec) func(config codecTypes.MapConfig) bool { return func(config codecTypes.MapConfig) bool { - return *mapSpec.TimeToLiveSeconds == config.TimeToLiveSeconds && - *mapSpec.MaxIdleSeconds == config.MaxIdleSeconds && - !config.ReadBackupData && *mapSpec.Eviction.MaxSize == config.MaxSize && + return mapSpec.TimeToLiveSeconds == config.TimeToLiveSeconds && + mapSpec.MaxIdleSeconds == config.MaxIdleSeconds && + !config.ReadBackupData && mapSpec.Eviction.MaxSize == config.MaxSize && config.MaxSizePolicy == hazelcastcomv1alpha1.EncodeMaxSizePolicy[mapSpec.Eviction.MaxSizePolicy] && config.EvictionPolicy == hazelcastcomv1alpha1.EncodeEvictionPolicyType[mapSpec.Eviction.EvictionPolicy] } @@ -81,9 +81,9 @@ var _ = Describe("Hazelcast Map Config", Label("map"), func() { Expect(mapConfig.InMemoryFormat).Should(Equal(hazelcastcomv1alpha1.EncodeInMemoryFormat[m.Spec.InMemoryFormat])) Expect(mapConfig.BackupCount).Should(Equal(n.DefaultMapBackupCount)) Expect(mapConfig.AsyncBackupCount).Should(Equal(int32(0))) - Expect(mapConfig.TimeToLiveSeconds).Should(Equal(*m.Spec.TimeToLiveSeconds)) - Expect(mapConfig.MaxIdleSeconds).Should(Equal(*m.Spec.MaxIdleSeconds)) - Expect(mapConfig.MaxSize).Should(Equal(*m.Spec.Eviction.MaxSize)) + Expect(mapConfig.TimeToLiveSeconds).Should(Equal(m.Spec.TimeToLiveSeconds)) + Expect(mapConfig.MaxIdleSeconds).Should(Equal(m.Spec.MaxIdleSeconds)) + Expect(mapConfig.MaxSize).Should(Equal(m.Spec.Eviction.MaxSize)) Expect(mapConfig.MaxSizePolicy).Should(Equal(hazelcastcomv1alpha1.EncodeMaxSizePolicy[m.Spec.Eviction.MaxSizePolicy])) Expect(mapConfig.ReadBackupData).Should(Equal(false)) Expect(mapConfig.EvictionPolicy).Should(Equal(hazelcastcomv1alpha1.EncodeEvictionPolicyType[m.Spec.Eviction.EvictionPolicy])) @@ -160,11 +160,11 @@ var _ = Describe("Hazelcast Map Config", Label("map"), func() { m = assertMapStatus(m, hazelcastcomv1alpha1.MapSuccess) By("updating the map config") - m.Spec.TimeToLiveSeconds = pointer.Int32(150) - m.Spec.MaxIdleSeconds = pointer.Int32(100) - m.Spec.Eviction = &hazelcastcomv1alpha1.EvictionConfig{ + m.Spec.TimeToLiveSeconds = 150 + m.Spec.MaxIdleSeconds = 100 + m.Spec.Eviction = hazelcastcomv1alpha1.EvictionConfig{ EvictionPolicy: hazelcastcomv1alpha1.EvictionPolicyLFU, - MaxSize: pointer.Int32(500), + MaxSize: 500, MaxSizePolicy: hazelcastcomv1alpha1.MaxSizePolicyFreeHeapSize, } Expect(k8sClient.Update(context.Background(), m)).Should(Succeed()) diff --git a/test/e2e/hazelcast_queue_test.go b/test/e2e/hazelcast_queue_test.go index beabc570642..fa23989bd52 100644 --- a/test/e2e/hazelcast_queue_test.go +++ b/test/e2e/hazelcast_queue_test.go @@ -86,7 +86,7 @@ var _ = Describe("Hazelcast Queue Config", Label("queue"), func() { BackupCount: pointer.Int32(3), }, EmptyQueueTtlSeconds: pointer.Int32(10), - MaxSize: pointer.Int32(100), + MaxSize: 100, } q := hazelcastconfig.Queue(qs, qLookupKey, labels) Expect(k8sClient.Create(context.Background(), q)).Should(Succeed()) diff --git a/test/e2e/hazelcast_replicatedmap_test.go b/test/e2e/hazelcast_replicatedmap_test.go index 390adfa2a80..5acf667a8ec 100644 --- a/test/e2e/hazelcast_replicatedmap_test.go +++ b/test/e2e/hazelcast_replicatedmap_test.go @@ -8,6 +8,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" appsv1 "k8s.io/api/apps/v1" + "k8s.io/utils/pointer" hazelcastcomv1alpha1 "github.com/hazelcast/hazelcast-platform-operator/api/v1alpha1" n "github.com/hazelcast/hazelcast-platform-operator/internal/naming" @@ -81,7 +82,7 @@ var _ = Describe("Hazelcast ReplicatedMap Config", Label("replicatedmap"), func( rms := hazelcastcomv1alpha1.ReplicatedMapSpec{ HazelcastResourceName: hzLookupKey.Name, InMemoryFormat: hazelcastcomv1alpha1.InMemoryFormatBinary, - AsyncFillup: false, + AsyncFillup: pointer.Bool(false), } rm := hazelcastconfig.ReplicatedMap(rms, rmLookupKey, labels) Expect(k8sClient.Create(context.Background(), rm)).Should(Succeed()) @@ -89,7 +90,7 @@ var _ = Describe("Hazelcast ReplicatedMap Config", Label("replicatedmap"), func( By("failing to update ReplicatedMap config") rm.Spec.InMemoryFormat = hazelcastcomv1alpha1.InMemoryFormatObject - rm.Spec.AsyncFillup = true + rm.Spec.AsyncFillup = pointer.Bool(true) Expect(k8sClient.Update(context.Background(), rm)).Should(Succeed()) assertDataStructureStatus(rmLookupKey, hazelcastcomv1alpha1.DataStructureFailed, &hazelcastcomv1alpha1.ReplicatedMap{}) }) diff --git a/test/e2e/hazelcast_test.go b/test/e2e/hazelcast_test.go index d05bf23b3b8..e4dff1ceb35 100644 --- a/test/e2e/hazelcast_test.go +++ b/test/e2e/hazelcast_test.go @@ -56,7 +56,7 @@ var _ = Describe("Hazelcast", Label("hz"), func() { }) Describe("Hazelcast cluster name", func() { - It("should create a Hazelcast cluster with Cluster name: development", Label("fast"), func() { + FIt("should create a Hazelcast cluster with Cluster name: development", Label("fast"), func() { setLabelAndCRName("h-2") hazelcast := hazelcastconfig.ClusterName(hzLookupKey, ee, labels) CreateHazelcastCR(hazelcast) diff --git a/test/e2e/hazelcast_wan_slow_test.go b/test/e2e/hazelcast_wan_slow_test.go index 8c88130b19b..6316dc189c1 100644 --- a/test/e2e/hazelcast_wan_slow_test.go +++ b/test/e2e/hazelcast_wan_slow_test.go @@ -62,7 +62,7 @@ var _ = Describe("Hazelcast WAN", Label("hz_wan_slow"), func() { By("creating source Hazelcast cluster") hazelcastSource := hazelcastconfig.ExposeExternallySmartLoadBalancer(sourceLookupKey, ee, labels) - hazelcastSource.Spec.Resources = &corev1.ResourceRequirements{ + hazelcastSource.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(mapSizeInGb) + "Gi")}, } @@ -73,7 +73,7 @@ var _ = Describe("Hazelcast WAN", Label("hz_wan_slow"), func() { By("creating target Hazelcast cluster") hazelcastTarget := hazelcastconfig.ExposeExternallySmartLoadBalancer(targetLookupKey, ee, labels) - hazelcastTarget.Spec.Resources = &corev1.ResourceRequirements{ + hazelcastTarget.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(mapSizeInGb) + "Gi")}, } @@ -128,7 +128,7 @@ var _ = Describe("Hazelcast WAN", Label("hz_wan_slow"), func() { By("creating source Hazelcast cluster") hazelcastSource := hazelcastconfig.ExposeExternallySmartLoadBalancer(sourceLookupKey, ee, labels) - hazelcastSource.Spec.Resources = &corev1.ResourceRequirements{ + hazelcastSource.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(mapSizeInGb*4) + "Gi")}, } @@ -139,7 +139,7 @@ var _ = Describe("Hazelcast WAN", Label("hz_wan_slow"), func() { By("creating target Hazelcast cluster") hazelcastTarget := hazelcastconfig.ExposeExternallySmartLoadBalancer(targetLookupKey, ee, labels) - hazelcastTarget.Spec.Resources = &corev1.ResourceRequirements{ + hazelcastTarget.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(mapSizeInGb*4) + "Gi")}, } @@ -262,7 +262,7 @@ var _ = Describe("Hazelcast WAN", Label("hz_wan_slow"), func() { SwitchContext(context1) setupEnv() hazelcastSource := hazelcastconfig.ExposeExternallySmartLoadBalancer(sourceLookupKey, ee, labels) - hazelcastSource.Spec.Resources = &corev1.ResourceRequirements{ + hazelcastSource.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(mapSizeInGb) + "Gi")}, } @@ -275,7 +275,7 @@ var _ = Describe("Hazelcast WAN", Label("hz_wan_slow"), func() { SwitchContext(context2) setupEnv() hazelcastTarget := hazelcastconfig.ExposeExternallySmartLoadBalancer(targetLookupKey, ee, labels) - hazelcastTarget.Spec.Resources = &corev1.ResourceRequirements{ + hazelcastTarget.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(mapSizeInGb) + "Gi")}, } @@ -337,7 +337,7 @@ var _ = Describe("Hazelcast WAN", Label("hz_wan_slow"), func() { SwitchContext(context1) setupEnv() hazelcastSource := hazelcastconfig.ExposeExternallySmartLoadBalancer(sourceLookupKey, ee, labels) - hazelcastSource.Spec.Resources = &corev1.ResourceRequirements{ + hazelcastSource.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(mapSizeInGb*4) + "Gi")}, } @@ -350,7 +350,7 @@ var _ = Describe("Hazelcast WAN", Label("hz_wan_slow"), func() { SwitchContext(context2) setupEnv() hazelcastTarget := hazelcastconfig.ExposeExternallySmartLoadBalancer(targetLookupKey, ee, labels) - hazelcastTarget.Spec.Resources = &corev1.ResourceRequirements{ + hazelcastTarget.Spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: resource.MustParse(strconv.Itoa(mapSizeInGb*4) + "Gi")}, } diff --git a/test/e2e/helpers_test.go b/test/e2e/helpers_test.go index 1fb7f5202ed..22afc84383e 100644 --- a/test/e2e/helpers_test.go +++ b/test/e2e/helpers_test.go @@ -549,7 +549,7 @@ func assertHazelcastRestoreStatus(h *hazelcastcomv1alpha1.Hazelcast, st hazelcas if err != nil { return "" } - if checkHz.Status.Restore == nil { + if checkHz.Status.Restore == (hazelcastcomv1alpha1.RestoreStatus{}) { return "" } return checkHz.Status.Restore.State @@ -794,16 +794,16 @@ func assertCorrectBackupStatus(hotBackup *hazelcastcomv1alpha1.HotBackup, seq st Expect("backup-" + seq).Should(Equal(backupSeqFolder)) } -func restoreConfig(hotBackup *hazelcastcomv1alpha1.HotBackup, useBucketConfig bool) *hazelcastcomv1alpha1.RestoreConfiguration { +func restoreConfig(hotBackup *hazelcastcomv1alpha1.HotBackup, useBucketConfig bool) hazelcastcomv1alpha1.RestoreConfiguration { if useBucketConfig { - return &hazelcastcomv1alpha1.RestoreConfiguration{ + return hazelcastcomv1alpha1.RestoreConfiguration{ BucketConfiguration: &hazelcastcomv1alpha1.BucketConfiguration{ BucketURI: hotBackup.Status.GetBucketURI(), Secret: hotBackup.Spec.Secret, }, } } - return &hazelcastcomv1alpha1.RestoreConfiguration{ + return hazelcastcomv1alpha1.RestoreConfiguration{ HotBackupResourceName: hotBackup.Name, } } diff --git a/test/integration/hazelcast_controller_test.go b/test/integration/hazelcast_controller_test.go index 07d1719fc3e..a9a08458569 100644 --- a/test/integration/hazelcast_controller_test.go +++ b/test/integration/hazelcast_controller_test.go @@ -542,7 +542,7 @@ var _ = Describe("Hazelcast controller", func() { When("NodeSelector is used", func() { It("should pass the values to StatefulSet spec", Label("fast"), func() { spec := test.HazelcastSpec(defaultSpecValues, ee) - spec.Scheduling = &hazelcastv1alpha1.SchedulingConfiguration{ + spec.Scheduling = hazelcastv1alpha1.SchedulingConfiguration{ NodeSelector: map[string]string{ "node.selector": "1", }, @@ -565,7 +565,7 @@ var _ = Describe("Hazelcast controller", func() { When("Affinity is used", func() { It("should pass the values to StatefulSet spec", Label("fast"), func() { spec := test.HazelcastSpec(defaultSpecValues, ee) - spec.Scheduling = &hazelcastv1alpha1.SchedulingConfiguration{ + spec.Scheduling = hazelcastv1alpha1.SchedulingConfiguration{ Affinity: &corev1.Affinity{ NodeAffinity: &corev1.NodeAffinity{ RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{ @@ -618,7 +618,7 @@ var _ = Describe("Hazelcast controller", func() { When("Toleration is used", func() { It("should pass the values to StatefulSet spec", Label("fast"), func() { spec := test.HazelcastSpec(defaultSpecValues, ee) - spec.Scheduling = &hazelcastv1alpha1.SchedulingConfiguration{ + spec.Scheduling = hazelcastv1alpha1.SchedulingConfiguration{ Tolerations: []corev1.Toleration{ { Key: "node.zone", @@ -809,10 +809,10 @@ var _ = Describe("Hazelcast controller", func() { By("checking the CR values with default ones") Expect(ms.Name).To(Equal("")) Expect(*ms.BackupCount).To(Equal(n.DefaultMapBackupCount)) - Expect(*ms.TimeToLiveSeconds).To(Equal(n.DefaultMapTimeToLiveSeconds)) - Expect(*ms.MaxIdleSeconds).To(Equal(n.DefaultMapMaxIdleSeconds)) + Expect(ms.TimeToLiveSeconds).To(Equal(n.DefaultMapTimeToLiveSeconds)) + Expect(ms.MaxIdleSeconds).To(Equal(n.DefaultMapMaxIdleSeconds)) Expect(ms.Eviction.EvictionPolicy).To(Equal(hazelcastv1alpha1.EvictionPolicyType(n.DefaultMapEvictionPolicy))) - Expect(*ms.Eviction.MaxSize).To(Equal(n.DefaultMapMaxSize)) + Expect(ms.Eviction.MaxSize).To(Equal(n.DefaultMapMaxSize)) Expect(ms.Eviction.MaxSizePolicy).To(Equal(hazelcastv1alpha1.MaxSizePolicyType(n.DefaultMapMaxSizePolicy))) Expect(ms.Indexes).To(BeNil()) Expect(ms.PersistenceEnabled).To(Equal(n.DefaultMapPersistenceEnabled)) @@ -827,7 +827,7 @@ var _ = Describe("Hazelcast controller", func() { When("Resources are used", func() { It("should be set to Container spec", Label("fast"), func() { spec := test.HazelcastSpec(defaultSpecValues, ee) - spec.Resources = &corev1.ResourceRequirements{ + spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceCPU: resource.MustParse("500m"), corev1.ResourceMemory: resource.MustParse("10Gi"), @@ -906,8 +906,6 @@ var _ = Describe("Hazelcast controller", func() { ImagePullSecrets: nil, ExposeExternally: nil, LicenseKeySecret: "key-secret", - Scheduling: nil, - Resources: nil, } secondSpec := hazelcastv1alpha1.HazelcastSpec{ ClusterSize: pointer.Int32(3), @@ -922,7 +920,7 @@ var _ = Describe("Hazelcast controller", func() { Type: hazelcastv1alpha1.ExposeExternallyTypeSmart, }, LicenseKeySecret: "", - Scheduling: &hazelcastv1alpha1.SchedulingConfiguration{ + Scheduling: hazelcastv1alpha1.SchedulingConfiguration{ Affinity: &corev1.Affinity{ NodeAffinity: &corev1.NodeAffinity{ RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{ @@ -937,7 +935,7 @@ var _ = Describe("Hazelcast controller", func() { }, }, }, - Resources: &corev1.ResourceRequirements{ + Resources: corev1.ResourceRequirements{ Requests: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceCPU: resource.MustParse("250m"), corev1.ResourceMemory: resource.MustParse("5Gi"), @@ -996,7 +994,7 @@ var _ = Describe("Hazelcast controller", func() { Expect(ss.Spec.Template.Spec.TopologySpreadConstraints).To(Equal(secondSpec.Scheduling.TopologySpreadConstraints)) By("Checking if StatefulSet Resources is updated") - Expect(ss.Spec.Template.Spec.Containers[0].Resources).To(Equal(*secondSpec.Resources)) + Expect(ss.Spec.Template.Spec.Containers[0].Resources).To(Equal(secondSpec.Resources)) Delete(hz) }) @@ -1013,7 +1011,7 @@ var _ = Describe("Hazelcast controller", func() { hz := &hazelcastv1alpha1.Hazelcast{ ObjectMeta: GetRandomObjectMeta(), Spec: hazelcastv1alpha1.HazelcastSpec{ - UserCodeDeployment: &hazelcastv1alpha1.UserCodeDeploymentConfig{ + UserCodeDeployment: hazelcastv1alpha1.UserCodeDeploymentConfig{ ConfigMaps: cms, TriggerSequence: ts, }, @@ -1259,7 +1257,7 @@ var _ = Describe("Hazelcast controller", func() { By("checking the CR values with default ones") Expect(rms.Name).To(Equal("")) Expect(string(rms.InMemoryFormat)).To(Equal(n.DefaultReplicatedMapInMemoryFormat)) - Expect(rms.AsyncFillup).To(Equal(n.DefaultReplicatedMapAsyncFillup)) + Expect(*rms.AsyncFillup).To(Equal(n.DefaultReplicatedMapAsyncFillup)) Expect(rms.HazelcastResourceName).To(Equal("hazelcast")) }) }) @@ -1309,10 +1307,10 @@ var _ = Describe("Hazelcast controller", func() { By("checking the CR values with default ones") Expect(qs.Name).To(Equal("")) Expect(*qs.BackupCount).To(Equal(n.DefaultQueueBackupCount)) - Expect(*qs.AsyncBackupCount).To(Equal(n.DefaultQueueAsyncBackupCount)) + Expect(qs.AsyncBackupCount).To(Equal(n.DefaultQueueAsyncBackupCount)) Expect(qs.HazelcastResourceName).To(Equal("hazelcast")) Expect(*qs.EmptyQueueTtlSeconds).To(Equal(n.DefaultQueueEmptyQueueTtl)) - Expect(*qs.MaxSize).To(Equal(n.DefaultMapMaxSize)) + Expect(qs.MaxSize).To(Equal(n.DefaultMapMaxSize)) Expect(qs.PriorityComparatorClassName).To(Equal("")) }) }) @@ -1345,7 +1343,7 @@ var _ = Describe("Hazelcast controller", func() { By("checking the CR values with default ones") Expect(qs.Name).To(Equal("")) Expect(*qs.BackupCount).To(Equal(n.DefaultCacheBackupCount)) - Expect(*qs.AsyncBackupCount).To(Equal(n.DefaultCacheAsyncBackupCount)) + Expect(qs.AsyncBackupCount).To(Equal(n.DefaultCacheAsyncBackupCount)) Expect(qs.HazelcastResourceName).To(Equal("hazelcast")) Expect(qs.KeyType).To(Equal("")) Expect(qs.ValueType).To(Equal("")) diff --git a/test/integration/managementcenter_controller_test.go b/test/integration/managementcenter_controller_test.go index 009bf09afce..629709fd703 100644 --- a/test/integration/managementcenter_controller_test.go +++ b/test/integration/managementcenter_controller_test.go @@ -92,13 +92,13 @@ var _ = Describe("ManagementCenter controller", func() { Expect(fetchedCR.Spec.HazelcastClusters).Should(BeNil()) - expectedExternalConnectivity := &hazelcastv1alpha1.ExternalConnectivityConfiguration{ + expectedExternalConnectivity := hazelcastv1alpha1.ExternalConnectivityConfiguration{ Type: hazelcastv1alpha1.ExternalConnectivityTypeLoadBalancer, } Expect(fetchedCR.Spec.ExternalConnectivity).Should(Equal(expectedExternalConnectivity)) - expectedPersistence := &hazelcastv1alpha1.PersistenceConfiguration{ - Enabled: true, + expectedPersistence := hazelcastv1alpha1.PersistenceConfiguration{ + Enabled: pointer.Bool(true), Size: &[]resource.Quantity{resource.MustParse("10Gi")}[0], } Expect(fetchedCR.Spec.Persistence).Should(Equal(expectedPersistence)) @@ -166,8 +166,8 @@ var _ = Describe("ManagementCenter controller", func() { mc := &hazelcastv1alpha1.ManagementCenter{ ObjectMeta: GetRandomObjectMeta(), Spec: hazelcastv1alpha1.ManagementCenterSpec{ - Persistence: &hazelcastv1alpha1.PersistenceConfiguration{ - Enabled: true, + Persistence: hazelcastv1alpha1.PersistenceConfiguration{ + Enabled: pointer.Bool(true), ExistingVolumeClaimName: "ClaimName", }, }, @@ -222,7 +222,7 @@ var _ = Describe("ManagementCenter controller", func() { When("NodeSelector is used", func() { It("should pass the values to StatefulSet spec", Label("fast"), func() { spec := test.ManagementCenterSpec(defaultSpecValues, ee) - spec.Scheduling = &hazelcastv1alpha1.SchedulingConfiguration{ + spec.Scheduling = hazelcastv1alpha1.SchedulingConfiguration{ NodeSelector: map[string]string{ "node.selector": "1", }, @@ -245,7 +245,7 @@ var _ = Describe("ManagementCenter controller", func() { When("Affinity is used", func() { It("should pass the values to StatefulSet spec", Label("fast"), func() { spec := test.ManagementCenterSpec(defaultSpecValues, ee) - spec.Scheduling = &hazelcastv1alpha1.SchedulingConfiguration{ + spec.Scheduling = hazelcastv1alpha1.SchedulingConfiguration{ Affinity: &corev1.Affinity{ NodeAffinity: &corev1.NodeAffinity{ RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{ @@ -298,7 +298,7 @@ var _ = Describe("ManagementCenter controller", func() { When("Toleration is used", func() { It("should pass the values to StatefulSet spec", Label("fast"), func() { spec := test.ManagementCenterSpec(defaultSpecValues, ee) - spec.Scheduling = &hazelcastv1alpha1.SchedulingConfiguration{ + spec.Scheduling = hazelcastv1alpha1.SchedulingConfiguration{ Tolerations: []corev1.Toleration{ { Key: "node.zone", @@ -326,7 +326,7 @@ var _ = Describe("ManagementCenter controller", func() { When("Resources are used", func() { It("should be set to Container spec", Label("fast"), func() { spec := test.ManagementCenterSpec(defaultSpecValues, ee) - spec.Resources = &corev1.ResourceRequirements{ + spec.Resources = corev1.ResourceRequirements{ Limits: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceCPU: resource.MustParse("500m"), corev1.ResourceMemory: resource.MustParse("10Gi"), @@ -371,8 +371,6 @@ var _ = Describe("ManagementCenter controller", func() { ImagePullSecrets: nil, LicenseKeySecret: "key-secret", HazelcastClusters: nil, - Scheduling: nil, - Resources: nil, } secondSpec := hazelcastv1alpha1.ManagementCenterSpec{ Repository: "hazelcast/management-center", @@ -388,7 +386,7 @@ var _ = Describe("ManagementCenter controller", func() { {Name: "dev", Address: "cluster-address"}, }, - Scheduling: &hazelcastv1alpha1.SchedulingConfiguration{ + Scheduling: hazelcastv1alpha1.SchedulingConfiguration{ Affinity: &corev1.Affinity{ NodeAffinity: &corev1.NodeAffinity{ RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{ @@ -403,7 +401,7 @@ var _ = Describe("ManagementCenter controller", func() { }, }, }, - Resources: &corev1.ResourceRequirements{ + Resources: corev1.ResourceRequirements{ Requests: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceCPU: resource.MustParse("250m"), corev1.ResourceMemory: resource.MustParse("5Gi"), @@ -461,7 +459,7 @@ var _ = Describe("ManagementCenter controller", func() { Expect(ss.Spec.Template.Spec.TopologySpreadConstraints).To(Equal(secondSpec.Scheduling.TopologySpreadConstraints)) By("checking if StatefulSet Resources is updated") - Expect(ss.Spec.Template.Spec.Containers[0].Resources).To(Equal(*secondSpec.Resources)) + Expect(ss.Spec.Template.Spec.Containers[0].Resources).To(Equal(secondSpec.Resources)) Delete(mc) }) diff --git a/test/ph/ph_suite_test.go b/test/ph/ph_suite_test.go index f2191fad1d2..5d1c165b1e8 100644 --- a/test/ph/ph_suite_test.go +++ b/test/ph/ph_suite_test.go @@ -1,11 +1,11 @@ package ph import ( - "k8s.io/apimachinery/pkg/types" "testing" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" "sigs.k8s.io/controller-runtime/pkg/client"