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

Record the generation allowing for items to be patched #129

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions roles/credential/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
when:
- ansiblecred_info['resources'][0]['status']['isFinished'] is defined
- ansiblecred_info['resources'][0]['status']['isFinished']
- ansiblecred_info['resources'][0]['status']['generation'] is defined
- ansiblecred_info['resources'][0]['status']['generation']|int == ansiblecred_info['resources'][0]['metadata']['generation']|int

- block:
- name: Check number of attempts to execute the job have been made
Expand Down Expand Up @@ -84,6 +86,7 @@
name: "{{ ansible_operator_meta.name }}"
namespace: "{{ ansible_operator_meta.namespace }}"
status:
generation: "{{ ansiblecred_info['resources'][0]['metadata']['generation'] }}"
k8sJob:
created: true
message: |-
Expand Down
3 changes: 3 additions & 0 deletions roles/instancegroup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
when:
- ansibleig_info['resources'][0]['status']['isFinished'] is defined
- ansibleig_info['resources'][0]['status']['isFinished']
- ansibleig_info['resources'][0]['status']['generation'] is defined
- ansibleig_info['resources'][0]['status']['generation']|int == ansibleig_info['resources'][0]['metadata']['generation']|int

- block:
- name: Check number of attempts to execute the job have been made
Expand Down Expand Up @@ -98,6 +100,7 @@
name: "{{ ansible_operator_meta.name }}"
namespace: "{{ ansible_operator_meta.namespace }}"
status:
generation: "{{ ansibleig_info['resources'][0]['metadata']['generation'] }}"
k8sJob:
created: true
message: |-
Expand Down
3 changes: 3 additions & 0 deletions roles/job/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
when:
- ansiblejob_info['resources'][0]['status']['isFinished'] is defined
- ansiblejob_info['resources'][0]['status']['isFinished']
- ansiblejob_info['resources'][0]['status']['generation'] is defined
- ansiblejob_info['resources'][0]['status']['generation']|int == ansiblejob_info['resources'][0]['metadata']['generation']|int
cooktheryan marked this conversation as resolved.
Show resolved Hide resolved

- block:
- name: Check number of attempts to execute the job have been made
Expand Down Expand Up @@ -111,6 +113,7 @@
namespace: "{{ ansible_operator_meta.namespace }}"
status:
k8sJob:
generation: "{{ k8s_job['resources'][0]['metadata']['generation'] }}"
created: true
message: |-
Monitor the job.batch status for more details with the following commands:
Expand Down
5 changes: 4 additions & 1 deletion roles/project/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
when:
- ansibleproj_info['resources'][0]['status']['isFinished'] is defined
- ansibleproj_info['resources'][0]['status']['isFinished']
- ansibleproj_info['resources'][0]['status']['generation'] is defined
- ansibleproj_info['resources'][0]['status']['generation']|int == ansibleproj_info['resources'][0]['metadata']['generation']|int

- block:
- name: Check number of attempts to execute the job have been made
Expand Down Expand Up @@ -77,13 +79,14 @@
set_fact:
_project_name: "{{ name}}"

- name: Update AnsibleProject status with K8s job info
- name: Update AnsibleProject status with K8s job info and generation
operator_sdk.util.k8s_status:
api_version: tower.ansible.com/v1alpha1
kind: AnsibleProject
name: "{{ ansible_operator_meta.name }}"
namespace: "{{ ansible_operator_meta.namespace }}"
status:
generation: "{{ ansibleproj_info['resources'][0]['metadata']['generation'] }}"
k8sJob:
created: true
message: |-
Expand Down
3 changes: 3 additions & 0 deletions roles/schedule/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
when:
- ansiblesched_info['resources'][0]['status']['isFinished'] is defined
- ansiblesched_info['resources'][0]['status']['isFinished']
- ansiblesched_info['resources'][0]['status']['generation'] is defined
- ansiblesched_info['resources'][0]['status']['generation']|int == ansiblesched_info['resources'][0]['metadata']['generation']|int

- block:
- name: Check number of attempts to execute the job have been made
Expand Down Expand Up @@ -84,6 +86,7 @@
name: "{{ ansible_operator_meta.name }}"
namespace: "{{ ansible_operator_meta.namespace }}"
status:
generation: "{{ ansiblesched_info['resources'][0]['metadata']['generation'] }}"
k8sJob:
created: true
message: |-
Expand Down
16 changes: 9 additions & 7 deletions roles/workflow/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

- name: WFJT defined
assert:
that:
Expand All @@ -11,7 +10,7 @@
api_version: batch/v1
name: "{{ ansible_operator_meta.name }}"
namespace: "{{ ansible_operator_meta.namespace }}"
register: k8s_job
register: k8s_wf

- name: Update AnsibleWorkflow isFinished status if job succeeded
operator_sdk.util.k8s_status:
Expand All @@ -22,8 +21,8 @@
status:
isFinished: true
when:
- k8s_job['resources'][0]['status']['succeeded'] is defined
- k8s_job['resources'][0]['status']['succeeded'] == 1
- k8s_wf['resources'][0]['status']['succeeded'] is defined
- k8s_wf['resources'][0]['status']['succeeded'] == 1

- name: Read AnsibleWorkflow info
kubernetes.core.k8s_info:
Expand All @@ -38,11 +37,13 @@
when:
- ansiblejob_info['resources'][0]['status']['isFinished'] is defined
- ansiblejob_info['resources'][0]['status']['isFinished']
- ansiblejob_info['resources'][0]['status']['generation'] is defined
- ansiblejob_info['resources'][0]['status']['generation']|int == ansiblejob_info['resources'][0]['metadata']['generation']|int

- block:
- name: Check number of attempts to execute the job have been made
set_fact:
_attempts: "{{ k8s_job['resources'][0]['status']['failed'] | default(0) }}"
_attempts: "{{ k8s_wf['resources'][0]['status']['failed'] | default(0) }}"

- name: Set the maximum failed attempts allowed based on the backoffLimit
set_fact:
Expand Down Expand Up @@ -71,8 +72,8 @@
- name: End play early
meta: end_play
when:
- k8s_job['resources'] is defined
- (k8s_job["resources"]|length>0)
- k8s_wf['resources'] is defined
- (k8s_wf["resources"]|length>0)

- name: Set user provided runner image
set_fact:
Expand Down Expand Up @@ -111,6 +112,7 @@
namespace: "{{ ansible_operator_meta.namespace }}"
status:
k8sJob:
generation: "{{ k8s_wf['resources'][0]['metadata']['generation'] }}"
created: true
message: |-
Monitor the job.batch status for more details with the following commands:
Expand Down
12 changes: 7 additions & 5 deletions watches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,39 @@
kind: AnsibleJob
role: job
watchDependentResources: True
# finalizer:
# name: finalizer.tower.ansible.com
# vars:
# tower_resource_state: absent

- version: v1alpha1
group: tower.ansible.com
kind: JobTemplate
role: jobtemplate
watchDependentResources: True
- version: v1alpha1
group: tower.ansible.com
kind: AnsibleProject
role: project
watchDependentResources: True
- version: v1alpha1
group: tower.ansible.com
kind: AnsibleWorkflow
role: workflow
watchDependentResources: True
- version: v1alpha1
group: tower.ansible.com
kind: AnsibleCredential
role: credential
watchDependentResources: True
- version: v1alpha1
group: tower.ansible.com
kind: AnsibleSchedule
role: schedule
watchDependentResources: True
- version: v1alpha1
group: tower.ansible.com
kind: AnsibleInstanceGroup
role: instancegroup
watchDependentResources: True
- version: v1alpha1
group: tower.ansible.com
kind: WorkflowTemplate
role: workflowtemplate
watchDependentResources: True
#+kubebuilder:scaffold:watch