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

failed to execute when condition: cannot fetch phase from <nil> (1:27) #21591

Open
linzehai0801 opened this issue Jan 21, 2025 · 2 comments
Open
Labels
bug Something isn't working component:notifications Related to notifications subsystem

Comments

@linzehai0801
Copy link

  • This is my configuration
---
apiVersion: v1
data:
  context: |
    argocdUrl: https://dev-argocd.evescn.com
  service.webhook.feishu: >
    url:
    https://open.feishu.cn/open-apis/bot/v2/hook/563216ea-1c64-4a9c-xxxx
  subscriptions: |
    - recipients: [feishu]  # 使用 Feishu 配置替代
      triggers: [on-sync-running, on-deployed, on-sync-failed, on-sync-succeeded]
  template.app-sync-change: |
    feishu:
      method: POST
      body: |
        {
            "msg_type": "interactive",
            "card": {
                "header": {
                    "template": "blue",  # 可以根据需求调整颜色
                    "title": {
                        "tag": "plain_text",
                        "content": "服务发版成功"
                    }
                },
                "elements": [
                    {
                        "tag": "column_set",
                        "flex_mode": "none",
                        "background_style": "grey",
                        "columns": [
                            {
                                "tag": "column",
                                "width": "weighted",
                                "weight": 1,
                                "vertical_align": "top",
                                "elements": [
                                    {
                                        "tag": "markdown",
                                        "content": "### 服务发版成功\n- **服务名称**: {{.app.metadata.name}}\n- **同步状态**: {{.app.status.operationState.phase}}\n- **服务状态**: {{.app.status.health.status}}\n- **发版时间**: {{.app.status.operationState.startedAt}}\n- **查看详情**: [点击跳转到 ArgoCD]({{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true)"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "tag": "action",
                        "actions": [
                            {
                                "tag": "button",
                                "text": {
                                    "tag": "plain_text",
                                    "content": "查看文档"
                                },
                                "url": "https://open.feishu.cn/document",
                                "type": "primary"
                            }
                        ]
                    }
                ]
            }
        }
  template.app-sync-degraded: |
    webhook:
      feishu:
        method: POST
        body: |
          {
              "msg_type": "interactive",
              "card": {
                  "header": {
                      "template": "red",  # 错误时使用红色
                      "title": {
                          "tag": "plain_text",
                          "content": "服务发版失败"
                      }
                  },
                  "elements": [
                      {
                          "tag": "column_set",
                          "flex_mode": "none",
                          "background_style": "grey",
                          "columns": [
                              {
                                  "tag": "column",
                                  "width": "weighted",
                                  "weight": 1,
                                  "vertical_align": "top",
                                  "elements": [
                                      {
                                          "tag": "markdown",
                                          "content": "### 服务发版失败\n- **服务名称**: {{.app.metadata.name}}\n- **同步状态**: {{.app.status.operationState.phase}}\n- **服务状态**: {{.app.status.health.status}}\n- **发版时间**: {{.app.status.operationState.startedAt}}\n- **查看详情**: [点击跳转到 ArgoCD]({{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true)"
                                      }
                                  ]
                              }
                          ]
                      },
                      {
                          "tag": "action",
                          "actions": [
                              {
                                  "tag": "button",
                                  "text": {
                                      "tag": "plain_text",
                                      "content": "查看文档"
                                  },
                                  "url": "https://open.feishu.cn/document",
                                  "type": "danger"
                              }
                          ]
                      }
                  ]
              }
          }
  trigger.on-deployed: |
    - description: Application is synced and healthy. Triggered once per commit.
      oncePer: app.status.sync.revision
      send: [app-sync-change]  # template names
      # trigger condition
      when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
  trigger.on-health-degraded: |
    - description: Application has degraded
      send: [app-sync-degraded]
      when: app.status.health.status == 'Degraded'
  trigger.on-sync-failed: |
    - description: Application syncing has failed
      send: [app-sync-degraded]  # template names
      when: app.status.operationState.phase in ['Error', 'Failed']
  trigger.on-sync-running: |
    - description: Application is being synced
      send: [app-sync-change]  # template names
      when: app.status.operationState.phase in ['Running']
  trigger.on-sync-status-unknown: |
    - description: Application status is 'Unknown'
      send: [app-sync-degraded]  # template names
      when: app.status.sync.status == 'Unknown'
  trigger.on-sync-succeeded: |
    - description: Application syncing has succeeded
      send: [app-sync-change]  # template names
      when: app.status.operationState.phase in ['Succeeded']
kind: ConfigMap
metadata:
  labels:
    app.kubernetes.io/component: notifications-controller
    app.kubernetes.io/name: argocd-notifications-controller
    app.kubernetes.io/part-of: argocd
  name: argocd-notifications-cm
  namespace: argocd


  • Here is the error message:

time="2025-01-21T08:23:41Z" level=info msg="Start processing" resource=argocd/git2consul-dev-a
time="2025-01-21T08:23:41Z" level=error msg="failed to execute when condition: cannot fetch phase from (1:27)\n | app.status.operationState.phase in ['Running']\n | ..........................^"
time="2025-01-21T08:23:41Z" level=info msg="Trigger on-sync-running result: [{[0].xGlbhcF_taGYrI3UsrQsINn2hl0 [app-sync-change] false}]" resource=argocd/git2consul-dev-a
time="2025-01-21T08:23:41Z" level=error msg="failed to execute when condition: cannot fetch phase from (1:27)\n | app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'\n | ..........................^"
time="2025-01-21T08:23:41Z" level=info msg="Trigger on-deployed result: [{[0].y7b5sbwa2Q329JYH755peeq-fBs [app-sync-change] false}]" resource=argocd/git2consul-dev-a
time="2025-01-21T08:23:41Z" level=error msg="failed to execute when condition: cannot fetch phase from (1:27)\n | app.status.operationState.phase in ['Error', 'Failed']\n | ..........................^"
time="2025-01-21T08:23:41Z" level=info msg="Trigger on-sync-failed result: [{[0].H9WjsqG1dKYm6njOZ7yUQYOA1Wk [app-sync-degraded] false}]" resource=argocd/git2consul-dev-a
time="2025-01-21T08:23:41Z" level=error msg="failed to execute when condition: cannot fetch phase from (1:27)\n | app.status.operationState.phase in ['Succeeded']\n | ..........................^"
time="2025-01-21T08:23:41Z" level=info msg="Trigger on-sync-succeeded result: [{[0].zxM90Et6k4Elb1-fHdjtDJq0xR0 [app-sync-change] false}]" resource=argocd/git2consul-dev-a
time="2025-01-21T08:23:41Z" level=info msg="Processing completed" resource=argocd/git2consul-dev-a
time="2025-01-21T08:23:41Z" level=info msg="Start processing" resource=argocd/git2consul-dev-a
time="2025-01-21T08:23:41Z" level=error msg="failed to execute when condition: cannot fetch phase from (1:27)\n | app.status.operationState.phase in ['Succeeded']\n | ..........................^"
time="2025-01-21T08:23:41Z" level=info msg="Trigger on-sync-succeeded result: [{[0].zxM90Et6k4Elb1-fHdjtDJq0xR0 [app-sync-change] false}]" resource=argocd/git2consul-dev-a
time="2025-01-21T08:23:41Z" level=error msg="failed to execute when condition: cannot fetch phase from (1:27)\n | app.status.operationState.phase in ['Running']\n | ..........................^"
time="2025-01-21T08:23:41Z" level=info msg="Trigger on-sync-running result: [{[0].xGlbhcF_taGYrI3UsrQsINn2hl0 [app-sync-change] false}]" resource=argocd/git2consul-dev-a
time="2025-01-21T08:23:41Z" level=error msg="failed to execute when condition: cannot fetch phase from (1:27)\n | app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'\n | ..........................^"
time="2025-01-21T08:23:41Z" level=info msg="Trigger on-deployed result: [{[0].y7b5sbwa2Q329JYH755peeq-fBs [app-sync-change] false}]" resource=argocd/git2consul-dev-a
time="2025-01-21T08:23:41Z" level=error msg="failed to execute when condition: cannot fetch phase from (1:27)\n | app.status.operationState.phase in ['Error', 'Failed']\n | ..........................^"

How do I fix this error

@linzehai0801 linzehai0801 added the bug Something isn't working label Jan 21, 2025
@reggie-k reggie-k added the component:notifications Related to notifications subsystem label Jan 21, 2025
@V0YD23
Copy link

V0YD23 commented Jan 27, 2025

@reggie-k can i work on this issue ?

@prashant231203
Copy link

I’ve created a pull request for this issue and am actively working on it. You can find the PR here. Looking forward to any feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component:notifications Related to notifications subsystem
Projects
None yet
Development

No branches or pull requests

4 participants