diff --git a/api/bases/cinder.openstack.org_cinderapis.yaml b/api/bases/cinder.openstack.org_cinderapis.yaml index 7b0538c0..262ed603 100644 --- a/api/bases/cinder.openstack.org_cinderapis.yaml +++ b/api/bases/cinder.openstack.org_cinderapis.yaml @@ -868,6 +868,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: diff --git a/api/bases/cinder.openstack.org_cinderbackups.yaml b/api/bases/cinder.openstack.org_cinderbackups.yaml index 2c26d1bc..a7b85932 100644 --- a/api/bases/cinder.openstack.org_cinderbackups.yaml +++ b/api/bases/cinder.openstack.org_cinderbackups.yaml @@ -842,6 +842,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: diff --git a/api/bases/cinder.openstack.org_cinders.yaml b/api/bases/cinder.openstack.org_cinders.yaml index 867f87a9..3647b3e7 100644 --- a/api/bases/cinder.openstack.org_cinders.yaml +++ b/api/bases/cinder.openstack.org_cinders.yaml @@ -93,6 +93,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: @@ -159,6 +160,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: @@ -225,6 +227,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: @@ -293,6 +296,7 @@ spec: default: 1 format: int32 maximum: 1 + minimum: 0 type: integer resources: properties: diff --git a/api/bases/cinder.openstack.org_cinderschedulers.yaml b/api/bases/cinder.openstack.org_cinderschedulers.yaml index c6bc087e..f5e8a77f 100644 --- a/api/bases/cinder.openstack.org_cinderschedulers.yaml +++ b/api/bases/cinder.openstack.org_cinderschedulers.yaml @@ -842,6 +842,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: diff --git a/api/bases/cinder.openstack.org_cindervolumes.yaml b/api/bases/cinder.openstack.org_cindervolumes.yaml index 61c21c49..4af40910 100644 --- a/api/bases/cinder.openstack.org_cindervolumes.yaml +++ b/api/bases/cinder.openstack.org_cindervolumes.yaml @@ -843,6 +843,7 @@ spec: default: 1 format: int32 maximum: 1 + minimum: 0 type: integer resources: properties: diff --git a/api/v1beta1/cinderapi_types.go b/api/v1beta1/cinderapi_types.go index d8d0dad1..3085665c 100644 --- a/api/v1beta1/cinderapi_types.go +++ b/api/v1beta1/cinderapi_types.go @@ -28,8 +28,9 @@ type CinderAPITemplate struct { // +kubebuilder:validation:Optional // +kubebuilder:default=1 + // +kubebuilder:validation:Minimum=0 // Replicas - Cinder API Replicas - Replicas int32 `json:"replicas"` + Replicas *int32 `json:"replicas"` // +kubebuilder:validation:Optional // ExternalEndpoints, expose a VIP via MetalLB on the pre-created address pool @@ -115,5 +116,5 @@ func init() { // IsReady - returns true if service is ready to serve requests func (instance CinderAPI) IsReady() bool { - return instance.Status.ReadyCount == instance.Spec.Replicas + return instance.Status.ReadyCount == *instance.Spec.Replicas } diff --git a/api/v1beta1/cinderbackup_types.go b/api/v1beta1/cinderbackup_types.go index 12b1946d..4dd1d948 100644 --- a/api/v1beta1/cinderbackup_types.go +++ b/api/v1beta1/cinderbackup_types.go @@ -28,8 +28,9 @@ type CinderBackupTemplate struct { // +kubebuilder:validation:Optional // +kubebuilder:default=1 + // +kubebuilder:validation:Minimum=0 // Replicas - Cinder Backup Replicas - Replicas int32 `json:"replicas"` + Replicas *int32 `json:"replicas"` } // CinderBackupSpec defines the desired state of CinderBackup @@ -102,5 +103,5 @@ func init() { // IsReady - returns true if service is ready to serve requests func (instance CinderBackup) IsReady() bool { - return instance.Status.ReadyCount == instance.Spec.Replicas + return instance.Status.ReadyCount == *instance.Spec.Replicas } diff --git a/api/v1beta1/cinderscheduler_types.go b/api/v1beta1/cinderscheduler_types.go index a2cf241d..5fe1851e 100644 --- a/api/v1beta1/cinderscheduler_types.go +++ b/api/v1beta1/cinderscheduler_types.go @@ -28,8 +28,9 @@ type CinderSchedulerTemplate struct { // +kubebuilder:validation:Optional // +kubebuilder:default=1 + // +kubebuilder:validation:Minimum=0 // Replicas - Cinder Scheduler Replicas - Replicas int32 `json:"replicas"` + Replicas *int32 `json:"replicas"` } // CinderSchedulerSpec defines the desired state of CinderScheduler @@ -102,5 +103,5 @@ func init() { // IsReady - returns true if service is ready to serve requests func (instance CinderScheduler) IsReady() bool { - return instance.Status.ReadyCount == instance.Spec.Replicas + return instance.Status.ReadyCount == *instance.Spec.Replicas } diff --git a/api/v1beta1/cindervolume_types.go b/api/v1beta1/cindervolume_types.go index 514ae4dd..3e4a4661 100644 --- a/api/v1beta1/cindervolume_types.go +++ b/api/v1beta1/cindervolume_types.go @@ -28,9 +28,10 @@ type CinderVolumeTemplate struct { // +kubebuilder:validation:Optional // +kubebuilder:default=1 + // +kubebuilder:validation:Minimum=0 // +kubebuilder:validation:Maximum=1 // Replicas - Cinder Volume Replicas - Replicas int32 `json:"replicas"` + Replicas *int32 `json:"replicas"` } // CinderVolumeSpec defines the desired state of CinderVolume @@ -103,5 +104,5 @@ func init() { // IsReady - returns true if service is ready to serve requests func (instance CinderVolume) IsReady() bool { - return instance.Status.ReadyCount == instance.Spec.Replicas + return instance.Status.ReadyCount == *instance.Spec.Replicas } diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 83d4bd80..b98eb476 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -209,6 +209,11 @@ func (in *CinderAPIStatus) DeepCopy() *CinderAPIStatus { func (in *CinderAPITemplate) DeepCopyInto(out *CinderAPITemplate) { *out = *in in.CinderServiceTemplate.DeepCopyInto(&out.CinderServiceTemplate) + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } if in.ExternalEndpoints != nil { in, out := &in.ExternalEndpoints, &out.ExternalEndpoints *out = make([]MetalLBConfig, len(*in)) @@ -359,6 +364,11 @@ func (in *CinderBackupStatus) DeepCopy() *CinderBackupStatus { func (in *CinderBackupTemplate) DeepCopyInto(out *CinderBackupTemplate) { *out = *in in.CinderServiceTemplate.DeepCopyInto(&out.CinderServiceTemplate) + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CinderBackupTemplate. @@ -586,6 +596,11 @@ func (in *CinderSchedulerStatus) DeepCopy() *CinderSchedulerStatus { func (in *CinderSchedulerTemplate) DeepCopyInto(out *CinderSchedulerTemplate) { *out = *in in.CinderServiceTemplate.DeepCopyInto(&out.CinderServiceTemplate) + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CinderSchedulerTemplate. @@ -909,6 +924,11 @@ func (in *CinderVolumeStatus) DeepCopy() *CinderVolumeStatus { func (in *CinderVolumeTemplate) DeepCopyInto(out *CinderVolumeTemplate) { *out = *in in.CinderServiceTemplate.DeepCopyInto(&out.CinderServiceTemplate) + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CinderVolumeTemplate. diff --git a/config/crd/bases/cinder.openstack.org_cinderapis.yaml b/config/crd/bases/cinder.openstack.org_cinderapis.yaml index 7b0538c0..262ed603 100644 --- a/config/crd/bases/cinder.openstack.org_cinderapis.yaml +++ b/config/crd/bases/cinder.openstack.org_cinderapis.yaml @@ -868,6 +868,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: diff --git a/config/crd/bases/cinder.openstack.org_cinderbackups.yaml b/config/crd/bases/cinder.openstack.org_cinderbackups.yaml index 2c26d1bc..a7b85932 100644 --- a/config/crd/bases/cinder.openstack.org_cinderbackups.yaml +++ b/config/crd/bases/cinder.openstack.org_cinderbackups.yaml @@ -842,6 +842,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: diff --git a/config/crd/bases/cinder.openstack.org_cinders.yaml b/config/crd/bases/cinder.openstack.org_cinders.yaml index 867f87a9..3647b3e7 100644 --- a/config/crd/bases/cinder.openstack.org_cinders.yaml +++ b/config/crd/bases/cinder.openstack.org_cinders.yaml @@ -93,6 +93,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: @@ -159,6 +160,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: @@ -225,6 +227,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: @@ -293,6 +296,7 @@ spec: default: 1 format: int32 maximum: 1 + minimum: 0 type: integer resources: properties: diff --git a/config/crd/bases/cinder.openstack.org_cinderschedulers.yaml b/config/crd/bases/cinder.openstack.org_cinderschedulers.yaml index c6bc087e..f5e8a77f 100644 --- a/config/crd/bases/cinder.openstack.org_cinderschedulers.yaml +++ b/config/crd/bases/cinder.openstack.org_cinderschedulers.yaml @@ -842,6 +842,7 @@ spec: replicas: default: 1 format: int32 + minimum: 0 type: integer resources: properties: diff --git a/config/crd/bases/cinder.openstack.org_cindervolumes.yaml b/config/crd/bases/cinder.openstack.org_cindervolumes.yaml index 61c21c49..4af40910 100644 --- a/config/crd/bases/cinder.openstack.org_cindervolumes.yaml +++ b/config/crd/bases/cinder.openstack.org_cindervolumes.yaml @@ -843,6 +843,7 @@ spec: default: 1 format: int32 maximum: 1 + minimum: 0 type: integer resources: properties: diff --git a/config/samples/cinder_v1beta1_cinder.yaml b/config/samples/cinder_v1beta1_cinder.yaml index e922acda..69b4e936 100644 --- a/config/samples/cinder_v1beta1_cinder.yaml +++ b/config/samples/cinder_v1beta1_cinder.yaml @@ -11,17 +11,9 @@ spec: databaseInstance: openstack databaseUser: cinder rabbitMqClusterName: rabbitmq - cinderAPI: - replicas: 1 - containerImage: quay.io/podified-antelope-centos9/openstack-cinder-api:current-podified - cinderScheduler: - replicas: 1 - containerImage: quay.io/podified-antelope-centos9/openstack-cinder-scheduler:current-podified - cinderBackup: - replicas: 1 - containerImage: quay.io/podified-antelope-centos9/openstack-cinder-backup:current-podified - secret: cinder-secret + cinderAPI: {} + cinderScheduler: {} + cinderBackup: {} cinderVolumes: - volume1: - containerImage: quay.io/podified-antelope-centos9/openstack-cinder-volume:current-podified - replicas: 1 + volume1: {} + secret: cinder-secret diff --git a/controllers/cinder_controller.go b/controllers/cinder_controller.go index 8d199c30..e32c1efa 100644 --- a/controllers/cinder_controller.go +++ b/controllers/cinder_controller.go @@ -661,7 +661,7 @@ func (r *CinderReconciler) reconcileNormal(ctx context.Context, instance *cinder // Many OpenStack deployments don't use the cinder-backup service (it's optional), // so there's no need to deploy it unless it's required. var backupCondition *condition.Condition - if instance.Spec.CinderBackup.Replicas > 0 { + if *instance.Spec.CinderBackup.Replicas > 0 { cinderBackup, op, err := r.backupDeploymentCreateOrUpdate(ctx, instance) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( diff --git a/controllers/cinderapi_controller.go b/controllers/cinderapi_controller.go index 85d6dace..a30d7134 100644 --- a/controllers/cinderapi_controller.go +++ b/controllers/cinderapi_controller.go @@ -638,7 +638,7 @@ func (r *CinderAPIReconciler) reconcileNormal(ctx context.Context, instance *cin // verify if network attachment matches expectations networkReady := false networkAttachmentStatus := map[string][]string{} - if instance.Spec.Replicas > 0 { + if *instance.Spec.Replicas > 0 { networkReady, networkAttachmentStatus, err = nad.VerifyNetworkStatusFromAnnotation( ctx, helper, diff --git a/controllers/cinderbackup_controller.go b/controllers/cinderbackup_controller.go index e14eccdf..52e1d275 100644 --- a/controllers/cinderbackup_controller.go +++ b/controllers/cinderbackup_controller.go @@ -435,7 +435,7 @@ func (r *CinderBackupReconciler) reconcileNormal(ctx context.Context, instance * // verify if network attachment matches expectations networkReady := false networkAttachmentStatus := map[string][]string{} - if instance.Spec.Replicas > 0 { + if *instance.Spec.Replicas > 0 { networkReady, networkAttachmentStatus, err = nad.VerifyNetworkStatusFromAnnotation( ctx, helper, diff --git a/controllers/cinderscheduler_controller.go b/controllers/cinderscheduler_controller.go index 1f5b88a3..556c7b61 100644 --- a/controllers/cinderscheduler_controller.go +++ b/controllers/cinderscheduler_controller.go @@ -434,7 +434,7 @@ func (r *CinderSchedulerReconciler) reconcileNormal(ctx context.Context, instanc // verify if network attachment matches expectations networkReady := false networkAttachmentStatus := map[string][]string{} - if instance.Spec.Replicas > 0 { + if *instance.Spec.Replicas > 0 { networkReady, networkAttachmentStatus, err = nad.VerifyNetworkStatusFromAnnotation( ctx, helper, diff --git a/controllers/cindervolume_controller.go b/controllers/cindervolume_controller.go index c49a81e9..dc543533 100644 --- a/controllers/cindervolume_controller.go +++ b/controllers/cindervolume_controller.go @@ -436,7 +436,7 @@ func (r *CinderVolumeReconciler) reconcileNormal(ctx context.Context, instance * // verify if network attachment matches expectations networkReady := false networkAttachmentStatus := map[string][]string{} - if instance.Spec.Replicas > 0 { + if *instance.Spec.Replicas > 0 { networkReady, networkAttachmentStatus, err = nad.VerifyNetworkStatusFromAnnotation( ctx, helper, diff --git a/pkg/cinderapi/deployment.go b/pkg/cinderapi/deployment.go index 8028f63c..e971fee8 100644 --- a/pkg/cinderapi/deployment.go +++ b/pkg/cinderapi/deployment.go @@ -91,7 +91,7 @@ func Deployment( Selector: &metav1.LabelSelector{ MatchLabels: labels, }, - Replicas: &instance.Spec.Replicas, + Replicas: instance.Spec.Replicas, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Annotations: annotations, diff --git a/pkg/cinderbackup/statefulset.go b/pkg/cinderbackup/statefulset.go index fa310732..3de730fe 100644 --- a/pkg/cinderbackup/statefulset.go +++ b/pkg/cinderbackup/statefulset.go @@ -116,7 +116,7 @@ func StatefulSet( Selector: &metav1.LabelSelector{ MatchLabels: labels, }, - Replicas: &instance.Spec.Replicas, + Replicas: instance.Spec.Replicas, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Annotations: annotations, diff --git a/pkg/cinderscheduler/statefulset.go b/pkg/cinderscheduler/statefulset.go index f9dc394f..f8712640 100644 --- a/pkg/cinderscheduler/statefulset.go +++ b/pkg/cinderscheduler/statefulset.go @@ -106,7 +106,7 @@ func StatefulSet( Selector: &metav1.LabelSelector{ MatchLabels: labels, }, - Replicas: &instance.Spec.Replicas, + Replicas: instance.Spec.Replicas, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Annotations: annotations, diff --git a/pkg/cindervolume/statefulset.go b/pkg/cindervolume/statefulset.go index 658e5821..e6eddf99 100644 --- a/pkg/cindervolume/statefulset.go +++ b/pkg/cindervolume/statefulset.go @@ -116,7 +116,7 @@ func StatefulSet( Selector: &metav1.LabelSelector{ MatchLabels: labels, }, - Replicas: &instance.Spec.Replicas, + Replicas: instance.Spec.Replicas, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Annotations: annotations,