newrelic-kubernetes-operator icon indicating copy to clipboard operation
newrelic-kubernetes-operator copied to clipboard

Bug: Removing `conditions` from Policy spec does not delete conditions

Open sanderblue opened this issue 4 years ago • 2 comments

Current behavior

Deleting lines 10-22 from code snippet below, then running kubectl apply does not delete the NRQL alert condition.

apiVersion: nr.k8s.newrelic.com/v1
kind: Policy
metadata:
  name: my-policy
spec:
  api_key: {{ NEW_RELIC_API_KEY }}
  name: "Alert Policy Created With k8s"
  region: "us"
  # Remove everything below here
  conditions:
    - spec:
        name: "NRQL Alert Condition Created With k8s"
        nrql:
          query: "SELECT average(duration) FROM Transaction WHERE appName = 'Dummy App'"
          since_value: "3"
        enabled: true
        terms:
          - threshold: "5"
            time_function: "all"
            duration: "3"
            priority: "critical"
            operator: "above"

But, if you leave conditions: there, but leave it empty, it will delete the conditions from the policy.

From an earlier note: Removing the conditions property after creating a condition does NOT delete the condition when running kubectl apply, however, leaving the conditions property and leaving it empty will delete any previously created conditions on the policy.

Expected behavior

Removing the conditions attribute (and its children) should delete the alert conditions.

sanderblue avatar May 27 '20 22:05 sanderblue

@sanderblue - I just tested after my most recent work on the policy controller and this appears to be resolved. Can you please confirm and if so, close this issue?

thande avatar Jun 02 '20 15:06 thande

Sure thing. Will take a look.

sanderblue avatar Jun 02 '20 16:06 sanderblue