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

Alert Policy: `region` does not have a default

Open sanderblue opened this issue 4 years ago • 0 comments

Description

Currently a user is required to supply the region field as part of the spec for the Policy configuration. This should be not required.

If the user does not explicitly set a region, the default value of US should be used.

Current behavior

When executing kubectl apply -f ./my-alert-policy.yaml, the operation appears to have succeeded, however the policy is not created and an error occurs under the hood.

Note: The command should also fail to execute which has been reported as a bug in issue #45.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Ensure the operator is installed and ready
  2. Use the following yaml to configure a minimal Alert Policy (my-alert-policy.yaml)
    apiVersion: nr.k8s.newrelic.com/v1
    kind: Policy
    metadata:
      name: my-policy
    spec:
      api_key: <your API key>
      name: "alert policy created with k8s"
    

    Note: Adding region: "US" to the spec will allow a successful apply.

  3. Tail the logs of your controller node - first get the node's full name, then tail those logs
    kubectl describe nodes -n newrelic-kubernetes-operator-system | grep controller-manager
    
    kubectl logs -f -n newrelic-kubernetes-operator-system -c manager newrelic-kubernetes-operator-controller-manager-<hash goes here>
    
  4. Open a new terminal in the current working directory and run the follow command.
    kubectl apply -f ./my-alert-policy.yaml
    
    The command "succeeds" with an output of policy.nr.k8s.newrelic.com/my-policy created, however an error occurred and the policy does not exist in New Relic.
  5. See error - kubernetes will continue to attempt to provision the resource over and over due to the error: "error":"unknown region"

Debug Output (if applicable)

{"level":"error", ... ... "msg":"Reconciler error","controller":"policy","request":"default/my-policy","error":"unknown region","stacktrace": ... etc etc

sanderblue avatar May 22 '20 01:05 sanderblue