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

[Bug]: Unable to refer the notificationChannels in GCP AlertPolicy using NotificationChannel name as documented #498

Closed
1 task done
avijitsarkar123 opened this issue Mar 26, 2024 · 6 comments

Comments

@avijitsarkar123
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Affected Resource(s)

  • monitoring.gcp.upbound.io/v1beta1 - NotificationChannel
  • monitoring.gcp.upbound.io/v1beta1 - AlertPolicy

Resource MRs required to reproduce the bug

NotificationChannel Manifest:

apiVersion: monitoring.gcp.upbound.io/v1beta1
kind: NotificationChannel
metadata:
  annotations:
    crossplane.io/external-create-pending: '2024-03-26T17:44:52Z'
    crossplane.io/external-create-succeeded: '2024-03-26T17:44:52Z'
    crossplane.io/external-name: >-
      projects/my-gcp-project/notificationChannels/10947831030092706776
    kubectl.kubernetes.io/last-applied-configuration: >
      {"apiVersion":"monitoring.gcp.upbound.io/v1beta1","kind":"NotificationChannel","metadata":{"annotations":{},"labels":{"app.kubernetes.io/instance":"my-sample-app","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"my-sample-app","app.kubernetes.io/version":"0.0.5","helm.sh/chart":"my-sample-app-0.0.4"},"name":"my-sample-app-notification-email-channel"},"spec":{"forProvider":{"displayName":"my-sample-app
      email notification
      channel","labels":{"email_address":"[email protected]"},"type":"email"}}}
    upjet.crossplane.io/provider-meta: >-
      {"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0":{"create":1200000000000,"delete":1200000000000,"update":1200000000000}}
  creationTimestamp: '2024-03-26T17:44:49Z'
  finalizers:
    - finalizer.managedresource.crossplane.io
  generation: 2
  labels:
    app.kubernetes.io/instance: my-sample-app
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: my-sample-app
    app.kubernetes.io/version: 0.0.5
    helm.sh/chart: my-sample-app-0.0.4
  managedFields:
    - apiVersion: monitoring.gcp.upbound.io/v1beta1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            .: {}
            f:kubectl.kubernetes.io/last-applied-configuration: {}
          f:labels:
            .: {}
            f:app.kubernetes.io/instance: {}
            f:app.kubernetes.io/managed-by: {}
            f:app.kubernetes.io/name: {}
            f:app.kubernetes.io/version: {}
            f:helm.sh/chart: {}
        f:spec:
          .: {}
          f:deletionPolicy: {}
          f:forProvider:
            .: {}
            f:displayName: {}
            f:labels:
              .: {}
              f:email_address: {}
            f:type: {}
          f:providerConfigRef:
            .: {}
            f:name: {}
      manager: kubectl-client-side-apply
      operation: Update
      time: '2024-03-26T17:44:49Z'
    - apiVersion: monitoring.gcp.upbound.io/v1beta1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            f:crossplane.io/external-create-pending: {}
            f:crossplane.io/external-create-succeeded: {}
            f:crossplane.io/external-name: {}
            f:upjet.crossplane.io/provider-meta: {}
          f:finalizers:
            .: {}
            v:"finalizer.managedresource.crossplane.io": {}
        f:spec:
          f:forProvider:
            f:enabled: {}
            f:project: {}
      manager: provider
      operation: Update
      time: '2024-03-26T17:45:06Z'
    - apiVersion: monitoring.gcp.upbound.io/v1beta1
      fieldsType: FieldsV1
      fieldsV1:
        f:status:
          .: {}
          f:atProvider:
            .: {}
            f:id: {}
            f:name: {}
            f:verificationStatus: {}
          f:conditions: {}
      manager: provider
      operation: Update
      subresource: status
      time: '2024-03-26T17:45:10Z'
  name: my-sample-app-notification-email-channel
  resourceVersion: '67126338'
  uid: cd775c5a-4434-4ec1-b9eb-1fad4fbd4318
  selfLink: >-
    /apis/monitoring.gcp.upbound.io/v1beta1/notificationchannels/my-sample-app-notification-email-channel
status:
  atProvider:
    id: >-
      projects/my-gcp-project/notificationChannels/10947831030092706776
    name: >-
      projects/my-gcp-project/notificationChannels/10947831030092706776
    verificationStatus: ''
  conditions:
    - lastTransitionTime: '2024-03-26T17:45:10Z'
      reason: Available
      status: 'True'
      type: Ready
    - lastTransitionTime: '2024-03-26T17:44:52Z'
      reason: ReconcileSuccess
      status: 'True'
      type: Synced
    - lastTransitionTime: '2024-03-26T17:44:58Z'
      reason: Success
      status: 'True'
      type: LastAsyncOperation
    - lastTransitionTime: '2024-03-26T17:44:58Z'
      reason: Finished
      status: 'True'
      type: AsyncOperation
spec:
  deletionPolicy: Delete
  forProvider:
    displayName: my-sample-app email notification channel
    enabled: true
    labels:
      email_address: [email protected]
    project: my-gcp-project
    type: email
  providerConfigRef:
    name: default

AlertPolicy Manifest

apiVersion: monitoring.gcp.upbound.io/v1beta1
kind: AlertPolicy
metadata:
  annotations:
    crossplane.io/external-create-failed: '2024-03-26T18:21:14Z'
    crossplane.io/external-create-pending: '2024-03-26T18:21:14Z'
    crossplane.io/external-create-succeeded: '2024-03-26T18:20:12Z'
    kubectl.kubernetes.io/last-applied-configuration: >
      {"apiVersion":"monitoring.gcp.upbound.io/v1beta1","kind":"AlertPolicy","metadata":{"annotations":{},"labels":{"app.kubernetes.io/instance":"my-sample-app","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"my-sample-app","app.kubernetes.io/version":"0.0.5","helm.sh/chart":"my-sample-app-0.0.4"},"name":"my-sample-app-job-alert-policy"},"spec":{"forProvider":{"combiner":"OR","conditions":[{"conditionThreshold":[{"aggregations":[{"alignmentPeriod":"900s","crossSeriesReducer":"REDUCE_SUM","perSeriesAligner":"ALIGN_MEAN"}],"comparison":"COMPARISON_GT","duration":"900s","filter":"metric.type=\"prometheus.googleapis.com/kube_job_status_failed/gauge\"
      AND resource.type=\"prometheus_target\" AND
      resource.label.namespace=ka-dev-my-sample-app","thresholdValue":1}],"displayName":"my-sample-app
      job alert"}],"displayName":"my-sample-app job alert
      policy","enabled":true,"notificationChannels":["my-sample-app-notification-email-channel"]}}}
  creationTimestamp: '2024-03-26T17:44:47Z'
  finalizers:
    - finalizer.managedresource.crossplane.io
  generation: 3
  labels:
    app.kubernetes.io/instance: my-sample-app
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: my-sample-app
    app.kubernetes.io/version: 0.0.5
    helm.sh/chart: my-sample-app-0.0.4
    k8slens-edit-resource-version: v1beta1
  managedFields:
    - apiVersion: monitoring.gcp.upbound.io/v1beta1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:labels:
            f:k8slens-edit-resource-version: {}
      manager: node-fetch
      operation: Update
      time: '2024-03-26T17:45:50Z'
    - apiVersion: monitoring.gcp.upbound.io/v1beta1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            .: {}
            f:kubectl.kubernetes.io/last-applied-configuration: {}
          f:labels:
            .: {}
            f:app.kubernetes.io/instance: {}
            f:app.kubernetes.io/managed-by: {}
            f:app.kubernetes.io/name: {}
            f:app.kubernetes.io/version: {}
            f:helm.sh/chart: {}
        f:spec:
          .: {}
          f:deletionPolicy: {}
          f:forProvider:
            .: {}
            f:combiner: {}
            f:conditions: {}
            f:displayName: {}
            f:enabled: {}
            f:notificationChannels: {}
          f:providerConfigRef:
            .: {}
            f:name: {}
      manager: kubectl-client-side-apply
      operation: Update
      time: '2024-03-26T18:05:24Z'
    - apiVersion: monitoring.gcp.upbound.io/v1beta1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            f:crossplane.io/external-create-failed: {}
            f:crossplane.io/external-create-pending: {}
            f:crossplane.io/external-create-succeeded: {}
          f:finalizers:
            .: {}
            v:"finalizer.managedresource.crossplane.io": {}
      manager: provider
      operation: Update
      time: '2024-03-26T18:21:14Z'
    - apiVersion: monitoring.gcp.upbound.io/v1beta1
      fieldsType: FieldsV1
      fieldsV1:
        f:status:
          .: {}
          f:atProvider: {}
          f:conditions: {}
      manager: provider
      operation: Update
      subresource: status
      time: '2024-03-26T18:21:14Z'
  name: my-sample-app-job-alert-policy
  resourceVersion: '67155187'
  uid: 0a3da036-5638-4963-942e-59d60616ee4c
  selfLink: >-
    /apis/monitoring.gcp.upbound.io/v1beta1/alertpolicies/my-sample-app-job-alert-policy
status:
  atProvider: {}
  conditions:
    - lastTransitionTime: '2024-03-26T17:44:49Z'
      reason: Creating
      status: 'False'
      type: Ready
    - lastTransitionTime: '2024-03-26T18:21:14Z'
      message: >-
        observe failed: cannot schedule a native provider during observe:
        0a3da036-5638-4963-942e-59d60616ee4c: cannot schedule native Terraform
        provider process: native provider reuse budget has been exceeded:
        invocationCount: 114, ttl: 100
      reason: ReconcileError
      status: 'False'
      type: Synced
    - lastTransitionTime: '2024-03-26T18:05:27Z'
      message: >-
        apply failed: Error creating AlertPolicy: googleapi: Error 400: Name
        must begin with
        'projects/{project_id}/notificationChannels/{channel_id}', got:
        my-sample-app-notification-email-channel:
      reason: ApplyFailure
      status: 'False'
      type: LastAsyncOperation
    - lastTransitionTime: '2024-03-26T18:11:29Z'
      reason: Finished
      status: 'True'
      type: AsyncOperation
spec:
  deletionPolicy: Delete
  forProvider:
    combiner: OR
    conditions:
      - conditionThreshold:
          - aggregations:
              - alignmentPeriod: 900s
                crossSeriesReducer: REDUCE_SUM
                perSeriesAligner: ALIGN_MEAN
            comparison: COMPARISON_GT
            duration: 900s
            filter: >-
              metric.type="prometheus.googleapis.com/kube_job_status_failed/gauge"
              AND resource.type="prometheus_target" AND
              resource.label.namespace=ka-dev-my-sample-app
            thresholdValue: 1
        displayName: my-sample-app job alert
    displayName: my-sample-app job alert policy
    enabled: true
    notificationChannels:
      - my-sample-app-notification-email-channel
  providerConfigRef:
    name: default

Steps to Reproduce

Create a GCP notificationChannel and then try to add it to the AlertPolicy

What happened?

The AlertPolicy is erroring out

Relevant Error Output Snippet

Error on the AlertPolicy

 apply failed: Error creating AlertPolicy: googleapi: Error 400: Name
        must begin with
        'projects/{project_id}/notificationChannels/{channel_id}', got:
        my-sample-app-notification-email-channel:


### Crossplane Version

https://github.com/upbound/universal-crossplane 	"universal-crossplane": "1.11.3-up.1",

### Provider Version

xpkg.upbound.io/upbound/provider-gcp:v0.30.0

### Kubernetes Version

Client Version: v1.27.1 | Kustomize Version: v5.0.1 | Server Version: v1.26.11-gke.1055000

### Kubernetes Distribution

GKE

### Additional Info

_No response_
@avijitsarkar123 avijitsarkar123 added the bug Something isn't working label Mar 26, 2024
@turkenf
Copy link
Collaborator

turkenf commented Mar 26, 2024

Hi @avijitsarkar123,

Thank you for bringing up this issue. As I understand independent of the NotificationChannel resource, you could not create the AlertPolicy resource successfully.

As I see, you are using an old version of the monolithic provider. I could not reproduce the bug with the latest version. Could you please try with v1.0.2 and let us know?

And please take note: The monolithic package is deprecated in favor of the family resource packages and will no longer be maintained after 12 June 2024

Copy link

github-actions bot commented Aug 6, 2024

This provider repo does not have enough maintainers to address every issue. Since there has been no activity in the last 90 days it is now marked as stale. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

@github-actions github-actions bot added the stale label Aug 6, 2024
Copy link

This issue is being closed since there has been no activity for 14 days since marking it as stale. If you still need help, feel free to comment or reopen the issue!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 20, 2024
@dhoeric-wu
Copy link

dhoeric-wu commented Aug 29, 2024

@turkenf I can reproduce the same error with upbound/provider-gcp-monitoring:v1.8.0 and xpkg.upbound.io/upbound/provider-family-gcp:v1.8.0.

Could you suggest how to reference the notification channel from alert policy?

Resource MRs required to reproduce the bug

apiVersion: monitoring.gcp.upbound.io/v1beta1
kind: AlertPolicy
metadata:
  annotations:
    meta.upbound.io/example-id: monitoring/v1beta1/alertpolicy
  labels:
    testing.upbound.io/example-name: example_alert_policy
  name: example-alert-policy
spec:
  forProvider:
    combiner: OR
    conditions:
      - conditionThreshold:
          - aggregations:
              - alignmentPeriod: 60s
                perSeriesAligner: ALIGN_RATE
            comparison: COMPARISON_GT
            duration: 60s
            filter: metric.type="compute.googleapis.com/instance/disk/write_bytes_count" AND
              resource.type="gce_instance"
        displayName: test condition
    displayName: My Alert Policy
    notificationChannels:
      - example-notification-channel
    userLabels:
      foo: bar
---
apiVersion: monitoring.gcp.upbound.io/v1beta1
kind: NotificationChannel
metadata:
  annotations:
    meta.upbound.io/example-id: monitoring/v1beta1/notificationchannel
  labels:
    testing.upbound.io/example-name: example_notification_channel
  name: example-notification-channel
spec:
  forProvider:
    displayName: Test Notification Channel
    labels:
      email_address: [email protected]
    type: email

@endoedgar
Copy link

endoedgar commented Oct 31, 2024

Do we have any updates here? seems like it is still a problem in the latest provider-gcp-monitoring:v1.8.3 provider.

@parak
Copy link

parak commented Dec 12, 2024

Interested in this as well. Is it possible to refer to the notification channel by NotificationChannel resource rather than the GCP name/path? Or is there no way to do this and the NotificationChannel resource has to be created first, then the status.id or status.name extracted, put into the AlertPolicy, after which the AlertPolicy can be applied?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants