Skip to content

Commit

Permalink
Show Warning for internal docker registry
Browse files Browse the repository at this point in the history
  • Loading branch information
kwiatekus committed Apr 30, 2024
1 parent c367548 commit 6e988e6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
6 changes: 0 additions & 6 deletions components/operator/internal/state/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 1 addition & 6 deletions components/operator/internal/state/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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(),
}
Expand All @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions config/operator/base/ui-extensions/serverless/details
Original file line number Diff line number Diff line change
Expand Up @@ -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":""
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 @@ -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
Expand Down

0 comments on commit 6e988e6

Please sign in to comment.