mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
feat(health): Implement AnsibleJob CRD health checks (#14483)
Signed-off-by: Mike Ng <ming@redhat.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
hs = {}
|
||||
if obj.status ~= nil then
|
||||
if obj.status.ansibleJobResult ~= nil then
|
||||
jobstatus = obj.status.ansibleJobResult.status
|
||||
if jobstatus == "successful" then
|
||||
hs.status = "Healthy"
|
||||
hs.message = jobstatus .. " job - " .. obj.status.ansibleJobResult.url
|
||||
return hs
|
||||
end
|
||||
if jobstatus == "failed" or jobstatus == "error" or jobstatus == "canceled" then
|
||||
hs.status = "Degraded"
|
||||
hs.message = jobstatus .. " job - " .. obj.status.ansibleJobResult.url
|
||||
return hs
|
||||
end
|
||||
if jobstatus == "new" or jobstatus == "pending" or jobstatus == "waiting" or jobstatus == "running" then
|
||||
hs.status = "Progressing"
|
||||
hs.message = jobstatus .. " job - " .. obj.status.ansibleJobResult.url
|
||||
return hs
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Waiting for AnsibleJob"
|
||||
return hs
|
||||
@@ -0,0 +1,37 @@
|
||||
tests:
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: Waiting for AnsibleJob
|
||||
inputPath: testdata/progressing_noStatus.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'new job - https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1'
|
||||
inputPath: testdata/progressing_new.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'pending job - https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1'
|
||||
inputPath: testdata/progressing_pending.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'running job - https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1'
|
||||
inputPath: testdata/progressing_running.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'waiting job - https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1'
|
||||
inputPath: testdata/progressing_waiting.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: 'canceled job - https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1'
|
||||
inputPath: testdata/degraded_canceled.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: 'error job - https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1'
|
||||
inputPath: testdata/degraded_error.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: 'failed job - https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1'
|
||||
inputPath: testdata/degraded_failed.yaml
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: 'successful job - https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1'
|
||||
inputPath: testdata/healthy.yaml
|
||||
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/degraded_canceled.yaml
vendored
Normal file
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/degraded_canceled.yaml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
apiVersion: tower.ansible.com/v1alpha1
|
||||
kind: AnsibleJob
|
||||
metadata:
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PreSync
|
||||
creationTimestamp: "2023-06-27T20:22:22Z"
|
||||
generateName: prehook-test-
|
||||
generation: 1
|
||||
labels:
|
||||
app.kubernetes.io/instance: ansible-hooks
|
||||
tower_job_id: "1"
|
||||
name: prehook-test-dfcff01-presync-1687897341
|
||||
namespace: argocd
|
||||
resourceVersion: "6536518"
|
||||
uid: 09fa0d39-a170-4c37-a3b0-6e140e029868
|
||||
spec:
|
||||
job_template_name: Demo Job Template
|
||||
tower_auth_secret: toweraccess
|
||||
status:
|
||||
ansibleJobResult:
|
||||
changed: true
|
||||
elapsed: "5.21"
|
||||
failed: false
|
||||
finished: "2023-06-27T20:22:40.116381Z"
|
||||
started: "2023-06-27T20:22:34.906399Z"
|
||||
status: canceled
|
||||
url: https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1
|
||||
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/degraded_error.yaml
vendored
Normal file
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/degraded_error.yaml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
apiVersion: tower.ansible.com/v1alpha1
|
||||
kind: AnsibleJob
|
||||
metadata:
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PreSync
|
||||
creationTimestamp: "2023-06-27T20:22:22Z"
|
||||
generateName: prehook-test-
|
||||
generation: 1
|
||||
labels:
|
||||
app.kubernetes.io/instance: ansible-hooks
|
||||
tower_job_id: "1"
|
||||
name: prehook-test-dfcff01-presync-1687897341
|
||||
namespace: argocd
|
||||
resourceVersion: "6536518"
|
||||
uid: 09fa0d39-a170-4c37-a3b0-6e140e029868
|
||||
spec:
|
||||
job_template_name: Demo Job Template
|
||||
tower_auth_secret: toweraccess
|
||||
status:
|
||||
ansibleJobResult:
|
||||
changed: true
|
||||
elapsed: "5.21"
|
||||
failed: true
|
||||
finished: "2023-06-27T20:22:40.116381Z"
|
||||
started: "2023-06-27T20:22:34.906399Z"
|
||||
status: error
|
||||
url: https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1
|
||||
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/degraded_failed.yaml
vendored
Normal file
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/degraded_failed.yaml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
apiVersion: tower.ansible.com/v1alpha1
|
||||
kind: AnsibleJob
|
||||
metadata:
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PreSync
|
||||
creationTimestamp: "2023-06-27T20:22:22Z"
|
||||
generateName: prehook-test-
|
||||
generation: 1
|
||||
labels:
|
||||
app.kubernetes.io/instance: ansible-hooks
|
||||
tower_job_id: "1"
|
||||
name: prehook-test-dfcff01-presync-1687897341
|
||||
namespace: argocd
|
||||
resourceVersion: "6536518"
|
||||
uid: 09fa0d39-a170-4c37-a3b0-6e140e029868
|
||||
spec:
|
||||
job_template_name: Demo Job Template
|
||||
tower_auth_secret: toweraccess
|
||||
status:
|
||||
ansibleJobResult:
|
||||
changed: true
|
||||
elapsed: "5.21"
|
||||
failed: true
|
||||
finished: "2023-06-27T20:22:40.116381Z"
|
||||
started: "2023-06-27T20:22:34.906399Z"
|
||||
status: failed
|
||||
url: https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1
|
||||
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/healthy.yaml
vendored
Normal file
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/healthy.yaml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
apiVersion: tower.ansible.com/v1alpha1
|
||||
kind: AnsibleJob
|
||||
metadata:
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PreSync
|
||||
creationTimestamp: "2023-06-27T20:22:22Z"
|
||||
generateName: prehook-test-
|
||||
generation: 1
|
||||
labels:
|
||||
app.kubernetes.io/instance: ansible-hooks
|
||||
tower_job_id: "1"
|
||||
name: prehook-test-dfcff01-presync-1687897341
|
||||
namespace: argocd
|
||||
resourceVersion: "6536518"
|
||||
uid: 09fa0d39-a170-4c37-a3b0-6e140e029868
|
||||
spec:
|
||||
job_template_name: Demo Job Template
|
||||
tower_auth_secret: toweraccess
|
||||
status:
|
||||
ansibleJobResult:
|
||||
changed: true
|
||||
elapsed: "5.21"
|
||||
failed: false
|
||||
finished: "2023-06-27T20:22:40.116381Z"
|
||||
started: "2023-06-27T20:22:34.906399Z"
|
||||
status: successful
|
||||
url: https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1
|
||||
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_new.yaml
vendored
Normal file
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_new.yaml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
apiVersion: tower.ansible.com/v1alpha1
|
||||
kind: AnsibleJob
|
||||
metadata:
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PreSync
|
||||
creationTimestamp: "2023-06-27T20:22:22Z"
|
||||
generateName: prehook-test-
|
||||
generation: 1
|
||||
labels:
|
||||
app.kubernetes.io/instance: ansible-hooks
|
||||
tower_job_id: "1"
|
||||
name: prehook-test-dfcff01-presync-1687897341
|
||||
namespace: argocd
|
||||
resourceVersion: "6536518"
|
||||
uid: 09fa0d39-a170-4c37-a3b0-6e140e029868
|
||||
spec:
|
||||
job_template_name: Demo Job Template
|
||||
tower_auth_secret: toweraccess
|
||||
status:
|
||||
ansibleJobResult:
|
||||
changed: true
|
||||
failed: false
|
||||
started: "2023-06-27T20:22:34.906399Z"
|
||||
status: new
|
||||
url: https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1
|
||||
17
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_noStatus.yaml
vendored
Normal file
17
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_noStatus.yaml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
apiVersion: tower.ansible.com/v1alpha1
|
||||
kind: AnsibleJob
|
||||
metadata:
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PreSync
|
||||
creationTimestamp: "2023-06-27T20:22:22Z"
|
||||
generateName: prehook-test-
|
||||
generation: 1
|
||||
labels:
|
||||
app.kubernetes.io/instance: ansible-hooks
|
||||
name: prehook-test-dfcff01-presync-1687897341
|
||||
namespace: argocd
|
||||
resourceVersion: "6536518"
|
||||
uid: 09fa0d39-a170-4c37-a3b0-6e140e029868
|
||||
spec:
|
||||
job_template_name: Demo Job Template
|
||||
tower_auth_secret: toweraccess
|
||||
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_pending.yaml
vendored
Normal file
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_pending.yaml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
apiVersion: tower.ansible.com/v1alpha1
|
||||
kind: AnsibleJob
|
||||
metadata:
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PreSync
|
||||
creationTimestamp: "2023-06-27T20:22:22Z"
|
||||
generateName: prehook-test-
|
||||
generation: 1
|
||||
labels:
|
||||
app.kubernetes.io/instance: ansible-hooks
|
||||
tower_job_id: "1"
|
||||
name: prehook-test-dfcff01-presync-1687897341
|
||||
namespace: argocd
|
||||
resourceVersion: "6536518"
|
||||
uid: 09fa0d39-a170-4c37-a3b0-6e140e029868
|
||||
spec:
|
||||
job_template_name: Demo Job Template
|
||||
tower_auth_secret: toweraccess
|
||||
status:
|
||||
ansibleJobResult:
|
||||
changed: true
|
||||
failed: false
|
||||
started: "2023-06-27T20:22:34.906399Z"
|
||||
status: pending
|
||||
url: https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1
|
||||
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_running.yaml
vendored
Normal file
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_running.yaml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
apiVersion: tower.ansible.com/v1alpha1
|
||||
kind: AnsibleJob
|
||||
metadata:
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PreSync
|
||||
creationTimestamp: "2023-06-27T20:22:22Z"
|
||||
generateName: prehook-test-
|
||||
generation: 1
|
||||
labels:
|
||||
app.kubernetes.io/instance: ansible-hooks
|
||||
tower_job_id: "1"
|
||||
name: prehook-test-dfcff01-presync-1687897341
|
||||
namespace: argocd
|
||||
resourceVersion: "6536518"
|
||||
uid: 09fa0d39-a170-4c37-a3b0-6e140e029868
|
||||
spec:
|
||||
job_template_name: Demo Job Template
|
||||
tower_auth_secret: toweraccess
|
||||
status:
|
||||
ansibleJobResult:
|
||||
changed: true
|
||||
failed: false
|
||||
started: "2023-06-27T20:22:34.906399Z"
|
||||
status: running
|
||||
url: https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1
|
||||
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_waiting.yaml
vendored
Normal file
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_waiting.yaml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
apiVersion: tower.ansible.com/v1alpha1
|
||||
kind: AnsibleJob
|
||||
metadata:
|
||||
annotations:
|
||||
argocd.argoproj.io/hook: PreSync
|
||||
creationTimestamp: "2023-06-27T20:22:22Z"
|
||||
generateName: prehook-test-
|
||||
generation: 1
|
||||
labels:
|
||||
app.kubernetes.io/instance: ansible-hooks
|
||||
tower_job_id: "1"
|
||||
name: prehook-test-dfcff01-presync-1687897341
|
||||
namespace: argocd
|
||||
resourceVersion: "6536518"
|
||||
uid: 09fa0d39-a170-4c37-a3b0-6e140e029868
|
||||
spec:
|
||||
job_template_name: Demo Job Template
|
||||
tower_auth_secret: toweraccess
|
||||
status:
|
||||
ansibleJobResult:
|
||||
changed: true
|
||||
failed: false
|
||||
started: "2023-06-27T20:22:34.906399Z"
|
||||
status: waiting
|
||||
url: https://argocd.test.ansiblejob.custom.health.com/#/jobs/playbook/1
|
||||
Reference in New Issue
Block a user