|
| 1 | +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json |
| 2 | +apiVersion: chainsaw.kyverno.io/v1alpha1 |
| 3 | +kind: Test |
| 4 | +metadata: |
| 5 | + name: instrumentation-blocked-upgrade |
| 6 | +spec: |
| 7 | + # This test modifies the operator deployment to verify upgrade blocking behavior. |
| 8 | + steps: |
| 9 | + - name: Create instrumentation with blocked dotnet version and verify webhook warning |
| 10 | + try: |
| 11 | + - script: |
| 12 | + timeout: 30s |
| 13 | + content: | |
| 14 | + kubectl apply -n $NAMESPACE -f 00-install-instrumentation-blocked.yaml 2>&1 |
| 15 | + check: |
| 16 | + (contains($stdout, 'cannot be automatically upgraded')): true |
| 17 | + - assert: |
| 18 | + file: 00-assert.yaml |
| 19 | + - name: Patch operator to use old dotnet version as default |
| 20 | + try: |
| 21 | + - script: |
| 22 | + timeout: 5m |
| 23 | + shell: /bin/bash |
| 24 | + content: | |
| 25 | + #!/bin/bash |
| 26 | + set -eo pipefail |
| 27 | + NS=opentelemetry-operator-system |
| 28 | + DEPLOY=opentelemetry-operator-controller-manager |
| 29 | + OLD_IMG="ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-dotnet:1.2.0" |
| 30 | +
|
| 31 | + # Add the dotnet image arg to override the compiled-in default |
| 32 | + ARGS=$(kubectl get deploy -n $NS $DEPLOY -o json | jq -c '.spec.template.spec.containers[0].args') |
| 33 | + NEW_ARGS=$(echo "$ARGS" | jq -c --arg img "$OLD_IMG" \ |
| 34 | + '[.[] | select(startswith("--auto-instrumentation-dotnet-image=") | not)] + ["--auto-instrumentation-dotnet-image=" + $img]') |
| 35 | +
|
| 36 | + kubectl patch deploy -n $NS $DEPLOY --type='json' \ |
| 37 | + -p="[{\"op\":\"replace\",\"path\":\"/spec/template/spec/containers/0/args\",\"value\":$NEW_ARGS}]" |
| 38 | +
|
| 39 | + kubectl rollout status deploy/$DEPLOY -n $NS --timeout=120s |
| 40 | + - name: Create instrumentation that will be subject to upgrade |
| 41 | + try: |
| 42 | + - apply: |
| 43 | + file: 01-install-instrumentation-upgrade-test.yaml |
| 44 | + - assert: |
| 45 | + file: 01-assert.yaml |
| 46 | + - name: Restore operator to default dotnet version and trigger upgrade |
| 47 | + try: |
| 48 | + - script: |
| 49 | + timeout: 5m |
| 50 | + shell: /bin/bash |
| 51 | + content: | |
| 52 | + #!/bin/bash |
| 53 | + set -eo pipefail |
| 54 | + NS=opentelemetry-operator-system |
| 55 | + DEPLOY=opentelemetry-operator-controller-manager |
| 56 | +
|
| 57 | + # Remove the override arg so the operator uses its compiled-in default (1.15.0) |
| 58 | + ARGS=$(kubectl get deploy -n $NS $DEPLOY -o json | jq -c '.spec.template.spec.containers[0].args') |
| 59 | + NEW_ARGS=$(echo "$ARGS" | jq -c '[.[] | select(startswith("--auto-instrumentation-dotnet-image=") | not)]') |
| 60 | +
|
| 61 | + kubectl patch deploy -n $NS $DEPLOY --type='json' \ |
| 62 | + -p="[{\"op\":\"replace\",\"path\":\"/spec/template/spec/containers/0/args\",\"value\":$NEW_ARGS}]" |
| 63 | +
|
| 64 | + kubectl rollout status deploy/$DEPLOY -n $NS --timeout=120s |
| 65 | + # Give the upgrade mechanism time to process existing Instrumentation CRs |
| 66 | + sleep 5 |
| 67 | + - name: Assert upgrade was blocked with status and event |
| 68 | + try: |
| 69 | + # DotNet image should still be 1.2.0 (not upgraded to 1.15.0) |
| 70 | + # and the status should reflect the blocked upgrade |
| 71 | + - assert: |
| 72 | + file: 02-assert.yaml |
0 commit comments