forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(health): Implement AnsibleJob CRD health checks (argoproj#14483)
Signed-off-by: Mike Ng <[email protected]>
- Loading branch information
1 parent
d16b51f
commit af38f92
Showing
11 changed files
with
287 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
resource_customizations/tower.ansible.com/AnsibleJob/health.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
37 changes: 37 additions & 0 deletions
37
resource_customizations/tower.ansible.com/AnsibleJob/health_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 27 additions & 0 deletions
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/degraded_canceled.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 27 additions & 0 deletions
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/degraded_error.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 27 additions & 0 deletions
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/degraded_failed.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 27 additions & 0 deletions
27
resource_customizations/tower.ansible.com/AnsibleJob/testdata/healthy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 25 additions & 0 deletions
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_new.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 17 additions & 0 deletions
17
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_noStatus.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 25 additions & 0 deletions
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_pending.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 25 additions & 0 deletions
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_running.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 25 additions & 0 deletions
25
resource_customizations/tower.ansible.com/AnsibleJob/testdata/progressing_waiting.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |