Skip to content

Commit

Permalink
Rename to spec.dockerRegistry.persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
kwiatekus committed Mar 27, 2024
1 parent 94d39ca commit 7f6c3eb
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions components/operator/api/v1alpha1/serverless_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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"`
Expand Down
24 changes: 12 additions & 12 deletions components/operator/api/v1alpha1/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{},
},
},
},
Expand Down Expand Up @@ -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",
},
}
Expand Down
14 changes: 7 additions & 7 deletions components/operator/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions components/operator/internal/state/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions components/operator/internal/state/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down Expand Up @@ -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) {
Expand All @@ -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"),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config/operator/base/ui-extensions/serverless/details
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down
2 changes: 1 addition & 1 deletion config/operator/base/ui-extensions/serverless/form
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/user/00-20-configure-serverless.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down

0 comments on commit 7f6c3eb

Please sign in to comment.