From e43c74d319153ff570654868b81dc37f91b8a728 Mon Sep 17 00:00:00 2001 From: Marcell Sevcsik <31651557+0sewa0@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:39:21 +0100 Subject: [PATCH] Remove standalone logMonitoring nodeSelector validation (#4109) (#4118) --- pkg/api/validation/dynakube/oneagent.go | 10 +--- pkg/api/validation/dynakube/oneagent_test.go | 57 -------------------- 2 files changed, 1 insertion(+), 66 deletions(-) diff --git a/pkg/api/validation/dynakube/oneagent.go b/pkg/api/validation/dynakube/oneagent.go index 7eb441404a..e78f015591 100644 --- a/pkg/api/validation/dynakube/oneagent.go +++ b/pkg/api/validation/dynakube/oneagent.go @@ -60,7 +60,7 @@ func conflictingOneAgentConfiguration(_ context.Context, _ *Validator, dk *dynak } func conflictingOneAgentNodeSelector(ctx context.Context, dv *Validator, dk *dynakube.DynaKube) string { - if !dk.LogMonitoring().IsStandalone() && !dk.NeedsOneAgent() { + if !dk.NeedsOneAgent() { return "" } @@ -86,14 +86,6 @@ func conflictingOneAgentNodeSelector(ctx context.Context, dv *Validator, dk *dyn conflictingDynakubes[item.Name] = true } } - - if item.LogMonitoring().IsStandalone() { - if hasConflictingMatchLabels(oneAgentNodeSelector, item.OneAgentNodeSelector()) { - log.Info("requested dynakube has conflicting LogMonitoring nodeSelector", "name", dk.Name, "namespace", dk.Namespace) - - conflictingDynakubes[item.Name] = true - } - } } if len(conflictingDynakubes) > 0 { diff --git a/pkg/api/validation/dynakube/oneagent_test.go b/pkg/api/validation/dynakube/oneagent_test.go index 3461b07137..a526d35a2e 100644 --- a/pkg/api/validation/dynakube/oneagent_test.go +++ b/pkg/api/validation/dynakube/oneagent_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/Dynatrace/dynatrace-operator/pkg/api/v1beta3/dynakube" - "github.com/Dynatrace/dynatrace-operator/pkg/api/v1beta3/dynakube/logmonitoring" "github.com/Dynatrace/dynatrace-operator/pkg/util/installconfig" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -76,28 +75,6 @@ func TestConflictingOneAgentConfiguration(t *testing.T) { } func TestConflictingNodeSelector(t *testing.T) { - newCloudNativeDynakube := func(name string, annotations map[string]string, nodeSelectorValue string) *dynakube.DynaKube { - return &dynakube.DynaKube{ - ObjectMeta: metav1.ObjectMeta{ - Name: name, - Namespace: testNamespace, - Annotations: annotations, - }, - Spec: dynakube.DynaKubeSpec{ - APIURL: testApiUrl, - OneAgent: dynakube.OneAgentSpec{ - CloudNativeFullStack: &dynakube.CloudNativeFullStackSpec{ - HostInjectSpec: dynakube.HostInjectSpec{ - NodeSelector: map[string]string{ - "node": nodeSelectorValue, - }, - }, - }, - }, - }, - } - } - t.Run("valid dynakube specs", func(t *testing.T) { assertAllowedWithoutWarnings(t, &dynakube.DynaKube{ @@ -162,20 +139,6 @@ func TestConflictingNodeSelector(t *testing.T) { }, }, }) - - assertAllowedWithoutWarnings(t, newCloudNativeDynakube("dk1", map[string]string{}, "1"), - &dynakube.DynaKube{ - ObjectMeta: defaultDynakubeObjectMeta, - Spec: dynakube.DynaKubeSpec{ - APIURL: testApiUrl, - LogMonitoring: &logmonitoring.Spec{}, - Templates: dynakube.TemplatesSpec{ - LogMonitoring: &logmonitoring.TemplateSpec{ - NodeSelector: map[string]string{"node": "12"}, - }, - }, - }, - }) }) t.Run(`invalid dynakube specs`, func(t *testing.T) { assertDenied(t, @@ -212,26 +175,6 @@ func TestConflictingNodeSelector(t *testing.T) { }, }) }) - t.Run(`invalid dynakube specs with existing log module`, func(t *testing.T) { - assertDenied(t, []string{fmt.Sprintf(errorNodeSelectorConflict, "dk-lm")}, - newCloudNativeDynakube("dk-cm", map[string]string{}, "1"), - createStandaloneLogMonitoringDynakube("dk-lm", "1")) - - assertDenied(t, []string{fmt.Sprintf(errorNodeSelectorConflict, ""), "dk-lm", "dk-cm2"}, - newCloudNativeDynakube("dk-cm1", map[string]string{}, "1"), - createStandaloneLogMonitoringDynakube("dk-lm", ""), - newCloudNativeDynakube("dk-cm2", map[string]string{}, "1")) - - assertDenied(t, []string{fmt.Sprintf(errorNodeSelectorConflict, "dk-lm")}, - newCloudNativeDynakube("dk-cn", map[string]string{}, "1"), - createStandaloneLogMonitoringDynakube("dk-lm", "1")) - assertDenied(t, []string{fmt.Sprintf(errorNodeSelectorConflict, "dk-cn")}, - createStandaloneLogMonitoringDynakube("dk-lm", "1"), - newCloudNativeDynakube("dk-cn", map[string]string{}, "1")) - assertDenied(t, []string{fmt.Sprintf(errorNodeSelectorConflict, "dk-lm2")}, - createStandaloneLogMonitoringDynakube("dk-lm1", "1"), - createStandaloneLogMonitoringDynakube("dk-lm2", "1")) - }) } func setupDisabledCSIEnv(t *testing.T) {