diff --git a/components/operator/internal/state/registry.go b/components/operator/internal/state/registry.go index e805ff79f..9e546d03e 100644 --- a/components/operator/internal/state/registry.go +++ b/components/operator/internal/state/registry.go @@ -16,6 +16,9 @@ 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 = "Internal Docker Registry option configured" + internalRegistryEventMessage = "Be advised: 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) { @@ -67,6 +70,7 @@ func addRegistryConfigurationWarnings(s *systemState) { } func setInternalRegistryConfig(ctx context.Context, r *reconciler, s *systemState) error { + 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 c702af67a..079fd6aba 100644 --- a/components/operator/internal/state/registry_test.go +++ b/components/operator/internal/state/registry_test.go @@ -12,12 +12,14 @@ 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{ @@ -32,7 +34,10 @@ func Test_sFnRegistryConfiguration(t *testing.T) { flagsBuilder: chart.NewFlagsBuilder(), } r := &reconciler{ - k8s: k8s{client: fake.NewClientBuilder().Build()}, + k8s: k8s{ + client: fake.NewClientBuilder().Build(), + EventRecorder: eventRecorder, + }, log: zap.NewNop().Sugar(), } expectedFlags := map[string]interface{}{ @@ -52,6 +57,8 @@ 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) {