Skip to content

Commit

Permalink
Merge branch 'release-1.4' into cherry/custom-v
Browse files Browse the repository at this point in the history
  • Loading branch information
0sewa0 authored Nov 28, 2024
2 parents c9bf53b + e43c74d commit 7b24dc4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 66 deletions.
10 changes: 1 addition & 9 deletions pkg/api/validation/dynakube/oneagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
}

Expand All @@ -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 {
Expand Down
57 changes: 0 additions & 57 deletions pkg/api/validation/dynakube/oneagent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7b24dc4

Please sign in to comment.