Skip to content

Commit

Permalink
Allow to inject custom wait_conditions during stages
Browse files Browse the repository at this point in the history
This feature is needed, especially in HCI scenario, when we want to
scale-out the deployment:
in order to do so, we have to create a new OpenStackDataPlaneDeployment
resource, with a new name to trigger the deployment of the new
compute(s).

In such a use-case, using [1] and the following parameters, we're able
to wait for the right resource to be ready:

```YAML
cifmw_architecture_user_kustomize:
  stage_2:
    edpm-values:
      data:
        deployment:
          name: edpm-scale-out
cifmw_architecture_wait_condition:
  stage_2:
    - >-
      oc -n openstack wait
      osdpd edpm-scale-out --for condition=Ready
      --timeout=1500s
```

In this example, the first snippet will inject a user kustomization in
the ci_gen_kustomize_values role in order to override the resource name.
The second snippet will then inject a new wait_condition to the existing
one.
When the deployment hits the wait_conditions loop, it will pass over the
first one (since it's already done), and run the second condition until
it ends.

[1] openstack-k8s-operators/architecture#158
  • Loading branch information
cjeanner authored and openshift-merge-bot[bot] committed Apr 4, 2024
1 parent 622b328 commit 1632065
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 2 additions & 0 deletions docs/source/usage/01_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ are shared among multiple roles:
- `cifmw_arch_automation_file`: (String) Name of the workflow automation file
in the architecture repository. Defaults to `default.yaml`
- `cifmw_architecture_scenario`: (String) The selected VA scenario to deploy.
- `cifmw_architecture_wait_condition`: (Dict) Structure defining custom wait_conditions for the automation.
- `cifmw_architecture_user_kustomize`: (Dict) Structure defining user provided kustomization for automation.
- `cifmw_ceph_target`: (String) The Ansible inventory group where ceph is deployed. Defaults to `computes`.
- `cifmw_run_tests`: (Bool) Specifies whether tests should be executed.
Defaults to false.
Expand Down
28 changes: 21 additions & 7 deletions roles/kustomize_deploy/tasks/execute_step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,32 @@
ansible.builtin.command:
cmd: "oc apply -f {{ _cr }}"

- name: "Run Wait Conditions for {{ stage.path }}"
- name: "Build Wait Conditions for {{ stage.path }}"
when:
- not cifmw_kustomize_deploy_generate_crs_only | bool
vars:
_stage_name: "stage_{{ stage_id }}"
_custom_conditions: >-
{{
cifmw_architecture_wait_condition[_stage_name] |
default([])
}}
## TODO: remove "validations" once architecture is up-to-date
_commands: >-
{{
(stage['wait_conditions'] |
default(stage['validations'])) + _custom_conditions
}}
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
ansible.builtin.command:
cmd: "{{ wait_condition }}"
## TODO: remove "validations" once architecture is up-to-date
loop: "{{ stage['wait_conditions'] | default(stage['validations']) }}"
loop_control:
loop_var: wait_condition
block:
- name: "Run Wait Conditions for {{ stage.path }}"
ansible.builtin.command:
cmd: "{{ wait_condition }}"
loop: "{{ _commands }}"
loop_control:
loop_var: wait_condition

- name: Stop after applying CRs if requested
when:
Expand Down

0 comments on commit 1632065

Please sign in to comment.