Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubectl apply silently fails if type is omitted from a condition spec (misleads the user) #96

Open
sanderblue opened this issue Jun 30, 2020 · 0 comments
Labels
bug Something isn't working kubernetes

Comments

@sanderblue
Copy link
Contributor

Description

When attempting to apply an AlertsPolicy configuration that includes an alert condition that omits the condition's type field, running kubectl apply silently fails and makes it seem like the apply was successful.

Example that causes a silent fail

apiVersion: nr.k8s.newrelic.com/v1
kind: AlertsPolicy
metadata:
  name: my-policy
spec:
  account_id: *******
  api_key: *******
  name: "my policy" 
  region: "us"

  conditions:
    - spec:
        # Note the omission of `type` in this condition spec
        name: "My NRQL Alert Condition"
        nrql:
          query: "SELECT average(duration) FROM Transaction WHERE appName = 'Dummy App'"
          evaluationOffset: 3
        enabled: true
        terms:
          - threshold: "5"
            threshold_occurrences: "ALL"
            threshold_duration: 180
            priority: "CRITICAL"
            operator: "ABOVE"
        violationTimeLimit: "ONE_HOUR"
        valueFunction: "SINGLE_VALUE"

Run kubectl apply for the above configuration and the user will still see the "success" output

alertspolicy.nr.k8s.newrelic.com/my-policy configured

Go Version

1.14.3

Expected behavior

With the provided invalid configuration mentioned above, kubectl apply should end up with a hard fail and kill the process, then display an error message letting the user know they are missing the required type field on the condition spec.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Use the config above.
  2. Run kubectl apply -f ./the_policy.yaml
  3. See error: which is that no error actually happens (this should actually display an error message since it's missing the type field)
@sanderblue sanderblue added the bug Something isn't working label Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working kubernetes
Projects
None yet
Development

No branches or pull requests

2 participants