From 7f6c3eb212edd1a56652c02ca12d835843c4b971 Mon Sep 17 00:00:00 2001 From: "Kwiatosz, Krzysztof" Date: Wed, 27 Mar 2024 14:58:56 +0100 Subject: [PATCH] Rename to spec.dockerRegistry.persistence --- .../operator/api/v1alpha1/serverless_types.go | 8 +++---- .../operator/api/v1alpha1/validation_test.go | 24 +++++++++---------- .../api/v1alpha1/zz_generated.deepcopy.go | 14 +++++------ .../operator/internal/state/registry.go | 6 ++--- .../operator/internal/state/registry_test.go | 6 ++--- ...operator.kyma-project.io_serverlesses.yaml | 10 ++++---- .../base/ui-extensions/serverless/details | 2 +- .../base/ui-extensions/serverless/form | 2 +- docs/user/00-20-configure-serverless.md | 2 +- 9 files changed, 37 insertions(+), 37 deletions(-) diff --git a/components/operator/api/v1alpha1/serverless_types.go b/components/operator/api/v1alpha1/serverless_types.go index a513354e4..3223afcf9 100644 --- a/components/operator/api/v1alpha1/serverless_types.go +++ b/components/operator/api/v1alpha1/serverless_types.go @@ -27,11 +27,11 @@ type DockerRegistry struct { EnableInternal *bool `json:"enableInternal,omitempty"` // Secret used for configuration of the Docker registry SecretName *string `json:"secretName,omitempty"` - // PersistenceVolume configuration - PersistenceVolume *PersistenceVolume `json:"persistenceVolume,omitempty"` + // Persistence configuration + Persistence *Persistence `json:"persistence,omitempty"` } -type PersistenceVolume struct { +type Persistence struct { // Size of the Docker registry Persistence Volume Size resource.Quantity `json:"size"` } @@ -47,7 +47,7 @@ type ServerlessSpec struct { // Used Eventing endpoint Eventing *Endpoint `json:"eventing,omitempty"` - // +kubebuilder:validation:XValidation:message="Use dockerRegistry.persistenceVolume only in combination with dockerRegistry.enableInternal set to true",rule="!has(self.persistenceVolume) || self.enableInternal" + // +kubebuilder:validation:XValidation:message="Use dockerRegistry.persistence only in combination with dockerRegistry.enableInternal set to true",rule="!has(self.persistence) || self.enableInternal" DockerRegistry *DockerRegistry `json:"dockerRegistry,omitempty"` // Sets a custom CPU utilization threshold for scaling Function Pods TargetCPUUtilizationPercentage string `json:"targetCPUUtilizationPercentage,omitempty"` diff --git a/components/operator/api/v1alpha1/validation_test.go b/components/operator/api/v1alpha1/validation_test.go index 89ebebf80..393b90de2 100644 --- a/components/operator/api/v1alpha1/validation_test.go +++ b/components/operator/api/v1alpha1/validation_test.go @@ -33,7 +33,7 @@ func Test_XKubernetesValidations_Valid(t *testing.T) { testCases := map[string]struct { serverless *v1alpha1.Serverless }{ - "No PersistenceVolume explicit config": { + "No Persistence explicit config": { serverless: &v1alpha1.Serverless{ ObjectMeta: fixMetadata, Spec: v1alpha1.ServerlessSpec{ @@ -43,26 +43,26 @@ func Test_XKubernetesValidations_Valid(t *testing.T) { }, }, }, - "Explicit PersistenceVolume config": { + "Explicit Persistence config": { serverless: &v1alpha1.Serverless{ ObjectMeta: fixMetadata, Spec: v1alpha1.ServerlessSpec{ DockerRegistry: &v1alpha1.DockerRegistry{ EnableInternal: &enableInternal, - PersistenceVolume: &v1alpha1.PersistenceVolume{ + Persistence: &v1alpha1.Persistence{ Size: resource.MustParse("2Gi"), }, }, }, }, }, - "Empty PersistenceVolume config": { + "Empty Persistence config": { serverless: &v1alpha1.Serverless{ ObjectMeta: fixMetadata, Spec: v1alpha1.ServerlessSpec{ DockerRegistry: &v1alpha1.DockerRegistry{ - EnableInternal: &enableInternal, - PersistenceVolume: &v1alpha1.PersistenceVolume{}, + EnableInternal: &enableInternal, + Persistence: &v1alpha1.Persistence{}, }, }, }, @@ -100,35 +100,35 @@ func Test_XKubernetesValidations_Invalid(t *testing.T) { fieldPath string expectedCause metav1.CauseType }{ - "PersistenceVolume size config w/o enableInternal": { + "Persistence size config w/o enableInternal": { serverless: &v1alpha1.Serverless{ ObjectMeta: fixMetadata, Spec: v1alpha1.ServerlessSpec{ DockerRegistry: &v1alpha1.DockerRegistry{ - PersistenceVolume: &v1alpha1.PersistenceVolume{ + Persistence: &v1alpha1.Persistence{ Size: resource.MustParse("2Gi"), }, }, }, }, expectedCause: metav1.CauseTypeFieldValueInvalid, - expectedErrMsg: "Use dockerRegistry.persistenceVolume only in combination with dockerRegistry.enableInternal set to true", + expectedErrMsg: "Use dockerRegistry.persistence only in combination with dockerRegistry.enableInternal set to true", fieldPath: "spec.dockerRegistry", }, - "PersistenceVolume size config and enableInternal=false": { + "Persistence size config and enableInternal=false": { serverless: &v1alpha1.Serverless{ ObjectMeta: fixMetadata, Spec: v1alpha1.ServerlessSpec{ DockerRegistry: &v1alpha1.DockerRegistry{ EnableInternal: &enableInternal, - PersistenceVolume: &v1alpha1.PersistenceVolume{ + Persistence: &v1alpha1.Persistence{ Size: resource.MustParse("2Gi"), }, }, }, }, expectedCause: metav1.CauseTypeFieldValueInvalid, - expectedErrMsg: "Use dockerRegistry.persistenceVolume only in combination with dockerRegistry.enableInternal set to true", + expectedErrMsg: "Use dockerRegistry.persistence only in combination with dockerRegistry.enableInternal set to true", fieldPath: "spec.dockerRegistry", }, } diff --git a/components/operator/api/v1alpha1/zz_generated.deepcopy.go b/components/operator/api/v1alpha1/zz_generated.deepcopy.go index 1cf4ae8a0..27a652fb0 100644 --- a/components/operator/api/v1alpha1/zz_generated.deepcopy.go +++ b/components/operator/api/v1alpha1/zz_generated.deepcopy.go @@ -38,9 +38,9 @@ func (in *DockerRegistry) DeepCopyInto(out *DockerRegistry) { *out = new(string) **out = **in } - if in.PersistenceVolume != nil { - in, out := &in.PersistenceVolume, &out.PersistenceVolume - *out = new(PersistenceVolume) + if in.Persistence != nil { + in, out := &in.Persistence, &out.Persistence + *out = new(Persistence) (*in).DeepCopyInto(*out) } } @@ -71,17 +71,17 @@ func (in *Endpoint) DeepCopy() *Endpoint { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PersistenceVolume) DeepCopyInto(out *PersistenceVolume) { +func (in *Persistence) DeepCopyInto(out *Persistence) { *out = *in out.Size = in.Size.DeepCopy() } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistenceVolume. -func (in *PersistenceVolume) DeepCopy() *PersistenceVolume { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Persistence. +func (in *Persistence) DeepCopy() *Persistence { if in == nil { return nil } - out := new(PersistenceVolume) + out := new(Persistence) in.DeepCopyInto(out) return out } diff --git a/components/operator/internal/state/registry.go b/components/operator/internal/state/registry.go index 803f2df1e..cafae9157 100644 --- a/components/operator/internal/state/registry.go +++ b/components/operator/internal/state/registry.go @@ -18,7 +18,7 @@ const ( extRegSecDiffThanSpecFormat = "actual registry configuration comes from %s/%s and it is different from spec.dockerRegistry.secretName. Reflect the %s secret in the secretName field or delete it" extRegSecNotInSpecFormat = "actual registry configuration comes from %s/%s and it is different from spec.dockerRegistry.secretName. Reflect %s secret in the secretName field" internalEnabledAndSecretNameUsedMessage = "spec.dockerRegistry.enableInternal is true and spec.dockerRegistry.secretName is used. Delete the secretName field or set the enableInternal value to false" - customPVCSMissingInSpec = "actual internal registry size is %s and it is different from default value and from spec.dockerRegistry.persistenceVolume.size. Configure custom storage size in the spec.dockerRegistry.persistenceVolume.size" + customPVCSMissingInSpec = "actual internal registry size is %s and it is different from default value and from spec.dockerRegistry.persistence.size. Configure custom storage size in the spec.dockerRegistry.persistence.size" requestedPVCLessThanActual = "requested storage %s cannot be less than actual storage %s" ) @@ -158,8 +158,8 @@ func resolvePVCSize(ctx context.Context, r *reconciler, s *systemState) (*resour r.log.Debugf("PVC size : actual %s", actualStorage.String()) - if s.instance.Spec.DockerRegistry.PersistenceVolume != nil { - requestedStorage := s.instance.Spec.DockerRegistry.PersistenceVolume.Size + if s.instance.Spec.DockerRegistry.Persistence != nil { + requestedStorage := s.instance.Spec.DockerRegistry.Persistence.Size r.log.Debugf("PVC size : requested %s", requestedStorage.String()) if actualStorage != nil && requestedStorage.Cmp(*actualStorage) < 0 { diff --git a/components/operator/internal/state/registry_test.go b/components/operator/internal/state/registry_test.go index e67958c40..d7ab8b764 100644 --- a/components/operator/internal/state/registry_test.go +++ b/components/operator/internal/state/registry_test.go @@ -359,7 +359,7 @@ func Test_addRegistryConfigurationWarnings(t *testing.T) { Spec: v1alpha1.ServerlessSpec{ DockerRegistry: &v1alpha1.DockerRegistry{ EnableInternal: ptr.To[bool](true), - PersistenceVolume: &v1alpha1.PersistenceVolume{ + Persistence: &v1alpha1.Persistence{ Size: pvcQuantity, }, }, @@ -446,7 +446,7 @@ func Test_addRegistryConfigurationWarnings(t *testing.T) { require.Equal(t, "internal", s.instance.Status.DockerRegistry) require.Equal(t, v1alpha1.StateProcessing, s.instance.Status.State) - require.Equal(t, "Warning: actual internal registry size is 21Gi and it is different from default value and from spec.dockerRegistry.persistenceVolume.size. Configure custom storage size in the spec.dockerRegistry.persistenceVolume.size", s.warningBuilder.Build()) + require.Equal(t, "Warning: actual internal registry size is 21Gi and it is different from default value and from spec.dockerRegistry.persistence.size. Configure custom storage size in the spec.dockerRegistry.persistence.size", s.warningBuilder.Build()) }) t.Run("Requesting pvc size that is less than existing", func(t *testing.T) { @@ -460,7 +460,7 @@ func Test_addRegistryConfigurationWarnings(t *testing.T) { Spec: v1alpha1.ServerlessSpec{ DockerRegistry: &v1alpha1.DockerRegistry{ EnableInternal: ptr.To[bool](true), - PersistenceVolume: &v1alpha1.PersistenceVolume{ + Persistence: &v1alpha1.Persistence{ Size: resource.MustParse("19Gi"), }, }, diff --git a/config/operator/base/crd/bases/operator.kyma-project.io_serverlesses.yaml b/config/operator/base/crd/bases/operator.kyma-project.io_serverlesses.yaml index e389eb383..1bd5a18c9 100644 --- a/config/operator/base/crd/bases/operator.kyma-project.io_serverlesses.yaml +++ b/config/operator/base/crd/bases/operator.kyma-project.io_serverlesses.yaml @@ -67,8 +67,8 @@ spec: description: When set to true, the internal Docker registry is enabled type: boolean - persistenceVolume: - description: PersistenceVolume configuration + persistence: + description: Persistence configuration properties: size: anyOf: @@ -85,9 +85,9 @@ spec: type: string type: object x-kubernetes-validations: - - message: Use dockerRegistry.persistenceVolume only in combination - with dockerRegistry.enableInternal set to true - rule: '!has(self.persistenceVolume) || self.enableInternal' + - message: Use dockerRegistry.persistence only in combination with + dockerRegistry.enableInternal set to true + rule: '!has(self.persistence) || self.enableInternal' eventing: description: Used Eventing endpoint properties: diff --git a/config/operator/base/ui-extensions/serverless/details b/config/operator/base/ui-extensions/serverless/details index 82d58037f..9ae9d5abb 100644 --- a/config/operator/base/ui-extensions/serverless/details +++ b/config/operator/base/ui-extensions/serverless/details @@ -13,7 +13,7 @@ body: visibility: $root.spec.dockerRegistry.enableInternal = true source: spec.dockerRegistry.enableInternal?"INTERNAL":"" - name: Persistence Volume Size - source: spec.dockerRegistry.persistenceVolume.size + source: spec.dockerRegistry.persistence.size visibility: '$exists($value)' - name: Docker Registry visibility: '$exists($value)' diff --git a/config/operator/base/ui-extensions/serverless/form b/config/operator/base/ui-extensions/serverless/form index b5536b716..a02cc7adc 100644 --- a/config/operator/base/ui-extensions/serverless/form +++ b/config/operator/base/ui-extensions/serverless/form @@ -6,7 +6,7 @@ severity: warning alert: "'Internal Docker Registry is not recommended for production grade installations'" visibility: "$root.spec.dockerRegistry.enableInternal = true" -- path: spec.dockerRegistry.persistenceVolume.size +- path: spec.dockerRegistry.persistence.size simple: true visibility: "$root.spec.dockerRegistry.enableInternal = true" name: Persistence Volume Size diff --git a/docs/user/00-20-configure-serverless.md b/docs/user/00-20-configure-serverless.md index e5cc007b9..a0ba7bfd0 100644 --- a/docs/user/00-20-configure-serverless.md +++ b/docs/user/00-20-configure-serverless.md @@ -45,7 +45,7 @@ You can choose to change the default volume size by defining the requested size, spec: dockerRegistry: enableInternal: true - persistenceVolume: + persistence: size: 30Gi ```