From 6e988e6a511bc4f60483eb4bbce08918ad79979d Mon Sep 17 00:00:00 2001 From: "Kwiatosz, Krzysztof" Date: Tue, 30 Apr 2024 10:08:15 +0200 Subject: [PATCH] Show Warning for internal docker registry --- components/operator/internal/state/registry.go | 6 ------ components/operator/internal/state/registry_test.go | 7 +------ config/operator/base/ui-extensions/serverless/details | 4 ++++ config/operator/base/ui-extensions/serverless/form | 2 +- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/components/operator/internal/state/registry.go b/components/operator/internal/state/registry.go index 6e6663e5c..e805ff79f 100644 --- a/components/operator/internal/state/registry.go +++ b/components/operator/internal/state/registry.go @@ -16,9 +16,6 @@ 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" - internalRegistryEventType = "Warning" - internalRegistryEventReason = "InternalDockerRegistryEnabled" - internalRegistryEventMessage = "Internal Docker Registry is not Highly Available registry and should be used for development purpose only" ) func sFnRegistryConfiguration(ctx context.Context, r *reconciler, s *systemState) (stateFn, *ctrl.Result, error) { @@ -70,9 +67,6 @@ func addRegistryConfigurationWarnings(s *systemState) { } func setInternalRegistryConfig(ctx context.Context, r *reconciler, s *systemState) error { - if s.statusSnapshot.DockerRegistry != "internal" { - r.Event(&s.instance, internalRegistryEventType, internalRegistryEventReason, internalRegistryEventMessage) - } s.instance.Status.DockerRegistry = "internal" s.flagsBuilder.WithRegistryEnableInternal( *s.instance.Spec.DockerRegistry.EnableInternal, diff --git a/components/operator/internal/state/registry_test.go b/components/operator/internal/state/registry_test.go index 079fd6aba..5f03b76ec 100644 --- a/components/operator/internal/state/registry_test.go +++ b/components/operator/internal/state/registry_test.go @@ -12,14 +12,12 @@ import ( "go.uber.org/zap" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/tools/record" "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) func Test_sFnRegistryConfiguration(t *testing.T) { t.Run("internal registry and update", func(t *testing.T) { - eventRecorder := record.NewFakeRecorder(5) s := &systemState{ instance: v1alpha1.Serverless{ Spec: v1alpha1.ServerlessSpec{ @@ -35,8 +33,7 @@ func Test_sFnRegistryConfiguration(t *testing.T) { } r := &reconciler{ k8s: k8s{ - client: fake.NewClientBuilder().Build(), - EventRecorder: eventRecorder, + client: fake.NewClientBuilder().Build(), }, log: zap.NewNop().Sugar(), } @@ -57,8 +54,6 @@ func Test_sFnRegistryConfiguration(t *testing.T) { require.EqualValues(t, expectedFlags, s.flagsBuilder.Build()) require.Equal(t, "internal", s.instance.Status.DockerRegistry) require.Equal(t, v1alpha1.StateProcessing, s.instance.Status.State) - - require.Len(t, eventRecorder.Events, 1) }) t.Run("external registry and go to next state", func(t *testing.T) { diff --git a/config/operator/base/ui-extensions/serverless/details b/config/operator/base/ui-extensions/serverless/details index d5cee36ca..ba7e1fc5e 100644 --- a/config/operator/base/ui-extensions/serverless/details +++ b/config/operator/base/ui-extensions/serverless/details @@ -9,6 +9,10 @@ body: - name: Desired Specification widget: Panel children: + - widget: Alert + severity: warning + alert: "'Internal Docker Registry is not a highly available registry and should be used for development purpose only'" + visibility: "$root.spec.dockerRegistry.enableInternal = true" - name: Docker Registry visibility: $root.spec.dockerRegistry.enableInternal = true source: spec.dockerRegistry.enableInternal?"INTERNAL":"" diff --git a/config/operator/base/ui-extensions/serverless/form b/config/operator/base/ui-extensions/serverless/form index 90e23e78a..2d3eb2d4c 100644 --- a/config/operator/base/ui-extensions/serverless/form +++ b/config/operator/base/ui-extensions/serverless/form @@ -4,7 +4,7 @@ - simple: true widget: Alert severity: warning - alert: "'Internal Docker Registry is not recommended for production grade installations'" + alert: "'Internal Docker Registry is not a highly available registry and should be used for development purpose only'" visibility: "$root.spec.dockerRegistry.enableInternal = true" - path: spec.dockerRegistry.secretName visibility: $root.spec.dockerRegistry.enableInternal != true