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

.app.status.operationState.phase has value: "<no value>" sometimes #29

Open
ivi-vink opened this issue Mar 23, 2022 · 0 comments
Open

Comments

@ivi-vink
Copy link

ivi-vink commented Mar 23, 2022

Hi,

We're using an argocd notification trigger based on the last reconciliation time to make a callback to an Azure pipeline. This way we can trigger a notification/callback by refreshing the application.

Our pipeline job is getting falsely canceled by the following notification, because the is_finished boolean evaluates to true when phase is "<no value>". But in reality the sync is not yet finished and now the wait step has failed for no reason. I'm not sure why phase is being set to "<no value>" and mostly it doesn't happen and the pipeline runs as it should. The pipeline basically patches the pull request properties and waits, and then it calls the argocd api to refresh the application, which should trigger a notification in case there is no change in the health status or phase status.

{
  "commitid": "eeef473c8481d1bec7d06bae20eafbe95e567d1a",
  "repo": "https://dev.azure.com/stater-europe/Stater/_git/devops-pipelines-autotest-gitops",
  "phase": "<no value>",
  "sync_status": "OutOfSync",
  "health": "Healthy",
  "message": "<no value>",
  "resources": [
    {
      "health": {
        "status": "Healthy"
      },
      "kind": "Service",
      "name": "autotest",
      "namespace": "autotest",
      "status": "Synced",
      "version": "v1"
    },
    {
      "group": "apps",
      "health": {
        "status": "Healthy"
      },
      "kind": "Deployment",
      "name": "autotest",
      "namespace": "autotest",
      "status": "OutOfSync",
      "version": "v1"
    },
    {
      "group": "networking.k8s.io",
      "health": {
        "status": "Healthy"
      },
      "kind": "Ingress",
      "name": "autotest",
      "namespace": "autotest",
      "status": "Synced",
      "version": "v1beta1"
    }
  ]
}

Here is the notifications configmap I used:

argocd-notifications:
  logLevel: info
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true
  resources:
    limits:
      cpu: 1
      memory: 256Mi
    requests:
      cpu: 100m
      memory: 128Mi

  subscriptions:
    - triggers:
        - sync-operation-status-change
        - refresh-reconciled-at
      recipients:
        - azdo-gitops-connector

  triggers:
    trigger.sync-operation-status-change: |
      - description: "Sync could not be completed."
        when: app.status.operationState.phase in ['Error', 'Failed']
        send:
          - sync-operation-status-change
      - description: "Application sync status succeeded."
        when: app.status.operationState.phase in ['Succeeded']
        send:
          - sync-operation-status-change
      - description: "Sync operation started, manifest are being fetched and diffed."
        when: app.status.operationState.phase in ['Running']
        send:
          - sync-operation-status-change
      - description: "Kubernetes objects are being reconciled by controllers."
        when: app.status.health.status in ['Progressing']
        send:
          - sync-operation-status-change
      - description: "Healthy app"
        when: app.status.health.status in ['Healthy'] && app.status.operationState.phase in ['Succeeded']
        send:
          - sync-operation-status-change
      - description: "Sync and reconciliation resulted in unhealthy app"
        when: app.status.health.status in ['Unknown', 'Suspended', 'Degraded', 'Missing']
        send:
          - sync-operation-status-change
    trigger.refresh-reconciled-at: |
      - description: "Refreshed during the last minute."
        oncePer: app.status.reconciledAt
        when: time.Now().Sub(time.Parse(app.status.reconciledAt)).Minutes() <= 5
        send:
          - sync-operation-status-change

  templates:
    template.sync-operation-status-change: |
      webhook:
        azdo-gitops-connector:
          method: POST
          path: /gitopsphase
          body: |
            {
              "commitid": "{{.app.status.sync.revision}}",
              "repo": "{{.app.spec.source.repoURL}}",
              "phase": "{{.app.status.operationState.phase}}",
              "sync_status": "{{.app.status.sync.status}}",
              "health": "{{.app.status.health.status}}",
              "message": "{{.app.status.operationState.message}}",
              "resources": {{toJson .app.status.resources}}
            }

  notifiers:
    service.webhook.azdo-gitops-connector: |
      url: http://gitops-connector:8080
      headers:
      - name: Content-Type
        value: application/json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant