Skip to content

Commit

Permalink
chore: rename dash0.com/opt-out=true to dash0.com/enable=false
Browse files Browse the repository at this point in the history
  • Loading branch information
basti1302 committed Jun 14, 2024
1 parent d389ed2 commit 316d7c3
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion helm-chart/dash0-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ opentelemetry-collector:
# enabled: true

additionalLabels:
dash0.com/opt-out: "true"
dash0.com/enable: "false"

resources:
limits:
Expand Down
8 changes: 4 additions & 4 deletions internal/util/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
// or when the label is missing entirely.
instrumentedLabelValueUnknown instrumentedState = "unknown"

optOutLabelKey = "dash0.com/opt-out"
dash0EnableLabelKey = "dash0.com/enable"
operatorImageLabelKey = "dash0.com/operator-image"
initContainerImageLabelKey = "dash0.com/init-container-image"
instrumentedByLabelKey = "dash0.com/instrumented-by"
Expand All @@ -33,10 +33,10 @@ const (

var (
WorkloadsWithoutDash0InstrumentedLabelFilter = metav1.ListOptions{
LabelSelector: fmt.Sprintf("!%s,%s != true", instrumentedLabelKey, optOutLabelKey),
LabelSelector: fmt.Sprintf("!%s,%s != false", instrumentedLabelKey, dash0EnableLabelKey),
}
WorkloadsWithDash0InstrumentedLabelFilter = metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s,%s != true", instrumentedLabelKey, optOutLabelKey),
LabelSelector: fmt.Sprintf("%s,%s != false", instrumentedLabelKey, dash0EnableLabelKey),
}
)

Expand Down Expand Up @@ -105,7 +105,7 @@ func HasOptedOutOfInstrumenationForWorkload(meta *metav1.ObjectMeta) bool {
if meta.Labels == nil {
return false
}
if value, ok := meta.Labels[optOutLabelKey]; ok && value == "true" {
if value, ok := meta.Labels[dash0EnableLabelKey]; ok && value == "false" {
return true
}
return false
Expand Down
2 changes: 1 addition & 1 deletion internal/webhook/dash0_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type resourceHandler func(h *Handler, request admission.Request, gvkLabel string
type routing map[string]map[string]map[string]resourceHandler

const (
optOutAdmissionAllowedMessage = "not instrumenting this resource due to dash0.com/opt-out=true"
optOutAdmissionAllowedMessage = "not instrumenting this resource due to dash0.com/enable=false"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion test-resources/collector/e2e.values.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ presets:
# kubeletMetrics:
# enabled: true
additionalLabels:
dash0.com/opt-out: "true"
dash0.com/enable: "false"
resources:
limits:
memory: 500Mi
Expand Down
2 changes: 1 addition & 1 deletion test-resources/collector/manual.values.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ presets:
# kubeletMetrics:
# enabled: true
additionalLabels:
dash0.com/opt-out: "true"
dash0.com/enable: "false"
resources:
limits:
memory: 500Mi
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/e2e_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,8 @@ func VerifyLabels(g Gomega, namespace string, kind string, successful bool, inst
g.ExpectWithOffset(1, initContainerImageVersion).To(MatchRegexp("dash0-instrumentation_\\d+\\.\\d+\\.\\d+"))
instrumentedBy := readLabel(g, namespace, kind, "dash0.com/instrumented-by")
g.ExpectWithOffset(1, instrumentedBy).To(Equal(instrumentationBy))
optOut := readLabel(g, namespace, kind, "dash0.com/opt-out")
g.ExpectWithOffset(1, optOut).To(Equal(""))
dash0Enable := readLabel(g, namespace, kind, "dash0.com/enable")
g.ExpectWithOffset(1, dash0Enable).To(Equal(""))
}

func verifyLabelsHaveBeenRemoved(g Gomega, namespace string, kind string) {
Expand All @@ -729,8 +729,8 @@ func verifyLabelsHaveBeenRemoved(g Gomega, namespace string, kind string) {
g.ExpectWithOffset(1, initContainerImageVersion).To(Equal(""))
instrumentedBy := readLabel(g, namespace, kind, "dash0.com/instrumented-by")
g.ExpectWithOffset(1, instrumentedBy).To(Equal(""))
optOut := readLabel(g, namespace, kind, "dash0.com/opt-out")
g.ExpectWithOffset(1, optOut).To(Equal(""))
dash0Enable := readLabel(g, namespace, kind, "dash0.com/enable")
g.ExpectWithOffset(1, dash0Enable).To(Equal(""))
}

func readLabel(g Gomega, namespace string, kind string, labelKey string) string {
Expand Down
2 changes: 1 addition & 1 deletion test/util/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ func addInstrumentationLabels(meta *metav1.ObjectMeta, successful bool) {
}

func addOptOutLabel(meta *metav1.ObjectMeta) {
AddLabel(meta, "dash0.com/opt-out", "true")
AddLabel(meta, "dash0.com/enable", "false")
}

func AddLabel(meta *metav1.ObjectMeta, key string, value string) {
Expand Down
8 changes: 4 additions & 4 deletions test/util/verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func verifyLabelsAfterSuccessfulModification(meta metav1.ObjectMeta) {
Expect(meta.Labels["dash0.com/operator-image"]).To(Equal("some-registry.com_1234_dash0-operator-controller_1.2.3"))
Expect(meta.Labels["dash0.com/init-container-image"]).To(Equal("some-registry.com_1234_dash0-instrumentation_4.5.6"))
Expect(meta.Labels["dash0.com/instrumented-by"]).NotTo(Equal(""))
Expect(meta.Labels["dash0.com/opt-out"]).To(Equal(""))
Expect(meta.Labels["dash0.com/enable"]).To(Equal(""))
}

func verifyLabelsAfterFailureToModify(meta metav1.ObjectMeta) {
Expand All @@ -266,15 +266,15 @@ func verifyLabelsAfterFailureToModify(meta metav1.ObjectMeta) {
Expect(meta.Labels["dash0.com/init-container-image"]).To(Equal("some-registry.com_1234_dash0-instrumentation_4.5.6"))
Expect(meta.Labels["dash0.com/instrumented-by"]).NotTo(Equal(""))
Expect(meta.Labels["dash0.com/webhook-ignore-once"]).To(Equal(""))
Expect(meta.Labels["dash0.com/opt-out"]).To(Equal(""))
Expect(meta.Labels["dash0.com/enable"]).To(Equal(""))
}

func verifyNoDash0Labels(meta metav1.ObjectMeta) {
Expect(meta.Labels["dash0.com/instrumented"]).To(Equal(""))
Expect(meta.Labels["dash0.com/operator-image"]).To(Equal(""))
Expect(meta.Labels["dash0.com/init-container-image"]).To(Equal(""))
Expect(meta.Labels["dash0.com/instrumented-by"]).To(Equal(""))
Expect(meta.Labels["dash0.com/opt-out"]).To(Equal(""))
Expect(meta.Labels["dash0.com/enable"]).To(Equal(""))
}

func verifyLabelsForOptOutWorkload(meta metav1.ObjectMeta) {
Expand All @@ -283,7 +283,7 @@ func verifyLabelsForOptOutWorkload(meta metav1.ObjectMeta) {
Expect(meta.Labels["dash0.com/init-container-image"]).To(Equal(""))
Expect(meta.Labels["dash0.com/instrumented-by"]).To(Equal(""))
Expect(meta.Labels["dash0.com/webhook-ignore-once"]).To(Equal(""))
Expect(meta.Labels["dash0.com/opt-out"]).To(Equal("true"))
Expect(meta.Labels["dash0.com/enable"]).To(Equal("false"))
}

func VerifyWebhookIgnoreOnceLabelIsPresent(objectMeta *metav1.ObjectMeta) bool {
Expand Down

0 comments on commit 316d7c3

Please sign in to comment.