Skip to content

Commit

Permalink
fix(workloads): remove pre-0.6.0 --require from NODE_OPTIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
basti1302 committed Jul 4, 2024
1 parent 5e48776 commit 300a765
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 63 deletions.
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ they deploy in their `AfterAll`/`AfterEach` hooks. The scripts in `test-resource
Run `make help` for more information on all potential `make` targets.
More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)
## Migration Strategy When Updating Instrumentation Values
When a new release of the operator changes the instrumentation values (new or changed environment variables, new labels,
new volumes etc.), we need to make sure that previously instrumented workloads are updated correctly. This should always
be accompanied by corresponding tests (for example new test cases in `workload_modifier_test.go`, see the test suite
`"when updating instrumentation from 0.5.1 to 0.6.0"` for an example).
## Contributing
No contribution guidelines are available at this point.
2 changes: 2 additions & 0 deletions internal/controller/dash0_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,8 @@ func (r *Dash0Reconciler) instrumentWorkload(
} else if util.HasBeenInstrumentedSuccessfully(objectMeta) {
// No change necessary, this workload has already been instrumented and an opt-out label (which would need to
// trigger uninstrumentation) has not been added since it has been instrumented.
// This check likely needs to change, see
// https://linear.app/dash0/issue/ENG-1955/updating-the-operator-should-run-a-first-reconcile-on-all-workloads-to
return false
} else if util.HasOptedOutOfInstrumenationAndIsUninstrumented(workload.getObjectMeta()) {
logger.Info("not instrumenting this workload due to dash0.com/enable=false")
Expand Down
26 changes: 13 additions & 13 deletions internal/controller/dash0_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
triggerReconcileRequest(ctx, reconciler, "")

verifyStatusConditionAndSuccessfulInstrumentationEvent(ctx, namespace, name)
VerifyModifiedCronJob(GetCronJob(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedCronJob(GetCronJob(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations())
})

It("should instrument an existing daemon set", func() {
Expand All @@ -186,7 +186,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
triggerReconcileRequest(ctx, reconciler, "")

verifyStatusConditionAndSuccessfulInstrumentationEvent(ctx, namespace, name)
VerifyModifiedDaemonSet(GetDaemonSet(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedDaemonSet(GetDaemonSet(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations())
})

It("should instrument an existing deployment", func() {
Expand Down Expand Up @@ -251,7 +251,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
triggerReconcileRequest(ctx, reconciler, "")

verifyStatusConditionAndSuccessfulInstrumentationEvent(ctx, namespace, name)
VerifyModifiedReplicaSet(GetReplicaSet(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedReplicaSet(GetReplicaSet(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations())
})

It("should not instrument an existing replicaset owned by a deployment", func() {
Expand All @@ -275,7 +275,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
triggerReconcileRequest(ctx, reconciler, "")

verifyStatusConditionAndSuccessfulInstrumentationEvent(ctx, namespace, name)
VerifyModifiedStatefulSet(GetStatefulSet(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedStatefulSet(GetStatefulSet(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations())
})
})

Expand Down Expand Up @@ -445,7 +445,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
workload := CreateInstrumentedCronJob(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
triggerReconcileRequest(ctx, reconciler, "")
VerifyModifiedCronJob(GetCronJob(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedCronJob(GetCronJob(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations())
VerifyNoEvents(ctx, clientset, TestNamespaceName)
})

Expand All @@ -454,7 +454,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
workload := CreateInstrumentedDaemonSet(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
triggerReconcileRequest(ctx, reconciler, "")
VerifyModifiedDaemonSet(GetDaemonSet(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedDaemonSet(GetDaemonSet(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations())
VerifyNoEvents(ctx, clientset, TestNamespaceName)
})

Expand All @@ -463,7 +463,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
workload := CreateInstrumentedDeployment(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
triggerReconcileRequest(ctx, reconciler, "")
VerifyModifiedDeployment(GetDeployment(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedDeployment(GetDeployment(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations())
VerifyNoEvents(ctx, clientset, TestNamespaceName)
})

Expand All @@ -472,7 +472,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
workload := CreateInstrumentedJob(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
triggerReconcileRequest(ctx, reconciler, "")
VerifyModifiedJob(GetJob(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedJob(GetJob(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations())
VerifyNoEvents(ctx, clientset, TestNamespaceName)
})

Expand All @@ -481,7 +481,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
workload := CreateInstrumentedReplicaSet(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
triggerReconcileRequest(ctx, reconciler, "")
VerifyModifiedReplicaSet(GetReplicaSet(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedReplicaSet(GetReplicaSet(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations())
VerifyNoEvents(ctx, clientset, TestNamespaceName)
})

Expand All @@ -490,7 +490,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
workload := CreateInstrumentedStatefulSet(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
triggerReconcileRequest(ctx, reconciler, "")
VerifyModifiedStatefulSet(GetStatefulSet(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedStatefulSet(GetStatefulSet(ctx, k8sClient, TestNamespaceName, name), BasicInstrumentedPodSpecExpectations())
VerifyNoEvents(ctx, clientset, TestNamespaceName)
})
})
Expand Down Expand Up @@ -595,7 +595,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
"been successful. Error message: Dash0 cannot remove the instrumentation from the existing job "+
"test-namespace/%s, since this type of workload is immutable.", name),
)
VerifyModifiedJob(GetJob(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedJob(GetJob(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations())
})

It("should remove instrumentation labels from an existing job for which an instrumentation attempt has failed", func() {
Expand Down Expand Up @@ -639,7 +639,7 @@ var _ = Describe("The Dash0 controller", Ordered, func() {
triggerReconcileRequest(ctx, reconciler, "Trigger a reconcile request to revert the instrumented workload")

VerifyNoEvents(ctx, clientset, namespace)
VerifyModifiedPod(GetPod(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedPod(GetPod(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations())
})

It("should leave existing uninstrumented pod owned by a replica set alone", func() {
Expand Down Expand Up @@ -946,7 +946,7 @@ func verifyDeploymentIsBeingInstrumented(ctx context.Context, reconciler *Dash0R
triggerReconcileRequest(ctx, reconciler, "")

verifyStatusConditionAndSuccessfulInstrumentationEvent(ctx, namespace, name)
VerifyModifiedDeployment(GetDeployment(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations)
VerifyModifiedDeployment(GetDeployment(ctx, k8sClient, namespace, name), BasicInstrumentedPodSpecExpectations())

return createdObjects
}
Expand Down
34 changes: 17 additions & 17 deletions internal/webhook/dash0_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ var _ = Describe("The Dash0 webhook", func() {
workload := CreateBasicCronJob(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
workload = GetCronJob(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedCronJob(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedCronJob(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -127,7 +127,7 @@ var _ = Describe("The Dash0 webhook", func() {
workload := CreateBasicDaemonSet(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
workload = GetDaemonSet(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedDaemonSet(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedDaemonSet(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -136,7 +136,7 @@ var _ = Describe("The Dash0 webhook", func() {
workload := CreateBasicJob(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
workload = GetJob(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedJob(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedJob(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -145,7 +145,7 @@ var _ = Describe("The Dash0 webhook", func() {
workload := CreateBasicPod(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
workload = GetPod(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedPod(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedPod(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -163,7 +163,7 @@ var _ = Describe("The Dash0 webhook", func() {
workload := CreateBasicReplicaSet(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
workload = GetReplicaSet(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedReplicaSet(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedReplicaSet(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -181,7 +181,7 @@ var _ = Describe("The Dash0 webhook", func() {
workload := CreateBasicStatefulSet(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
workload = GetStatefulSet(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedStatefulSet(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedStatefulSet(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})
})
Expand Down Expand Up @@ -332,7 +332,7 @@ var _ = Describe("The Dash0 webhook", func() {
RemoveOptOutLabel(&workload.ObjectMeta)
UpdateWorkload(ctx, k8sClient, workload)
workload = GetCronJob(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedCronJob(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedCronJob(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -344,7 +344,7 @@ var _ = Describe("The Dash0 webhook", func() {
RemoveOptOutLabel(&workload.ObjectMeta)
UpdateWorkload(ctx, k8sClient, workload)
workload = GetDaemonSet(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedDaemonSet(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedDaemonSet(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -356,7 +356,7 @@ var _ = Describe("The Dash0 webhook", func() {
RemoveOptOutLabel(&workload.ObjectMeta)
UpdateWorkload(ctx, k8sClient, workload)
workload = GetDeployment(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedDeployment(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedDeployment(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -371,7 +371,7 @@ var _ = Describe("The Dash0 webhook", func() {
RemoveOptOutLabel(&workload.ObjectMeta)
UpdateWorkload(ctx, k8sClient, workload)
workload = GetReplicaSet(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedReplicaSet(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedReplicaSet(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -383,7 +383,7 @@ var _ = Describe("The Dash0 webhook", func() {
RemoveOptOutLabel(&workload.ObjectMeta)
UpdateWorkload(ctx, k8sClient, workload)
workload = GetStatefulSet(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedStatefulSet(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedStatefulSet(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})
})
Expand All @@ -397,7 +397,7 @@ var _ = Describe("The Dash0 webhook", func() {
UpdateLabel(&workload.ObjectMeta, "dash0.com/enable", "true")
UpdateWorkload(ctx, k8sClient, workload)
workload = GetCronJob(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedCronJob(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedCronJob(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -409,7 +409,7 @@ var _ = Describe("The Dash0 webhook", func() {
UpdateLabel(&workload.ObjectMeta, "dash0.com/enable", "true")
UpdateWorkload(ctx, k8sClient, workload)
workload = GetDaemonSet(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedDaemonSet(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedDaemonSet(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -421,7 +421,7 @@ var _ = Describe("The Dash0 webhook", func() {
UpdateLabel(&workload.ObjectMeta, "dash0.com/enable", "true")
UpdateWorkload(ctx, k8sClient, workload)
workload = GetDeployment(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedDeployment(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedDeployment(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -436,7 +436,7 @@ var _ = Describe("The Dash0 webhook", func() {
UpdateLabel(&workload.ObjectMeta, "dash0.com/enable", "true")
UpdateWorkload(ctx, k8sClient, workload)
workload = GetReplicaSet(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedReplicaSet(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedReplicaSet(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})

Expand All @@ -448,7 +448,7 @@ var _ = Describe("The Dash0 webhook", func() {
UpdateLabel(&workload.ObjectMeta, "dash0.com/enable", "true")
UpdateWorkload(ctx, k8sClient, workload)
workload = GetStatefulSet(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedStatefulSet(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedStatefulSet(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
})
})
Expand Down Expand Up @@ -614,7 +614,7 @@ func verifyDeploymentIsBeingInstrumented(createdObjects []client.Object) []clien
workload := CreateBasicDeployment(ctx, k8sClient, TestNamespaceName, name)
createdObjects = append(createdObjects, workload)
workload = GetDeployment(ctx, k8sClient, TestNamespaceName, name)
VerifyModifiedDeployment(workload, BasicInstrumentedPodSpecExpectations)
VerifyModifiedDeployment(workload, BasicInstrumentedPodSpecExpectations())
VerifySuccessfulInstrumentationEvent(ctx, clientset, TestNamespaceName, name, "webhook")
return createdObjects
}
Expand Down
Loading

0 comments on commit 300a765

Please sign in to comment.