Duncan Doyle
2018-07-14 02960f334b8980f4bc2a288e67b2e77640c7dc8c
Added scripts to wait for builds and deployments to finish.
2 files added
2 files modified
69 ■■■■■ changed files
ansible/roles/ocp-workload-fsi-client-onboarding-demo/defaults/main.yml 6 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-fsi-client-onboarding-demo/tasks/wait_for_build.yml 23 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-fsi-client-onboarding-demo/tasks/wait_for_deploy.yml 20 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-fsi-client-onboarding-demo/tasks/workload.yml 20 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-fsi-client-onboarding-demo/defaults/main.yml
@@ -17,3 +17,9 @@
quota_services: 15
quota_secrets: 50
quota_requests_storage: 0Gi
build_status_retries: 20
build_status_delay: 20
deploy_status_retries: 15
deploy_status_delay: 20
ansible/roles/ocp-workload-fsi-client-onboarding-demo/tasks/wait_for_build.yml
New file
@@ -0,0 +1,23 @@
---
# Purpose:
#   This script queries OCP for builds that exist but are not yet ready.
#   So long as there are unready builds, this script continues to loop
#
# Manual Test to determine list of unready builds :
#  1) install jp :  https://github.com/jmespath/jp
#  2) oc get builds -o json | jp "items[?  (status.phase != 'Complete') ].metadata.annotations.\"openshift.io/build-config.name\""
#
#  Documentation pertaining to jq syntax:
#    - http://jmespath.org/tutorial.html
#    - https://stackoverflow.com/questions/41261680/ansible-json-query-path-to-select-item-by-content
#
- name: "Wait for following builds to become ready: {{build_to_wait}}"
  command: 'oc get build -o json -n "{{ ocp_project }}"'
  register: build_state
  changed_when: false
  retries: "{{ build_status_retries }}"
  delay: "{{ build_status_delay }}"
  vars:
    query: "items[?  (status.phase != 'Complete') ].metadata.annotations.\"openshift.io/build-config.name\""
  until: "build_state.stdout |from_json |json_query(query) |intersect(build_to_wait) |length == 0"
ansible/roles/ocp-workload-fsi-client-onboarding-demo/tasks/wait_for_deploy.yml
New file
@@ -0,0 +1,20 @@
---
# Purpose:
#   This script queries OCP for replication controllers that exist but are not yet ready.
#   So long as there are unready replication controllers, this script continues to loop
#
# Manual Test to determine list of unready replication controllers :
#  1) install jp :  https://github.com/jmespath/jp
#  2) oc get rc -o json | jp 'items[?  (status.readyReplicas == ""|| status.readyReplicas == `0`) ].metadata.annotations."openshift.io/deployment-config.name"'
#
- name: "Wait for following deployments to become ready: {{pod_to_wait}}"
  command: 'oc get rc -o json -n "{{ ocp_project }}"'
  register: rc_state
  changed_when: false
  retries: "{{ deploy_status_retries }}"
  delay: "{{ deploy_status_delay }}"
  until: 'rc_state.stdout |from_json |json_query(''items[?  (status.readyReplicas == ""|| status.readyReplicas == `0`) ].metadata.annotations."openshift.io/deployment-config.name"'') |intersect(pod_to_wait) |length == 0'
#  Documentation pertaining to jq syntax:
#    - http://jmespath.org/tutorial.html
ansible/roles/ocp-workload-fsi-client-onboarding-demo/tasks/workload.yml
@@ -67,6 +67,26 @@
          oc patch bc/co --type="json" \
          -p="[{'op': 'replace', 'path': '/spec/strategy/sourceStrategy/from/namespace', 'value': '{{ocp_project}}'}]"
#### Wait for the build to complete before slapping on the quota ....
- include: ./wait_for_build.yml
  static: no
  vars:
    build_to_wait:
      - co
      - fsi-backoffice
      - fsi-customer
#### Wait for the deployment to complete before slapping on the quota ...
- include: ./wait_for_deploy.yml
  static: no
  vars:
    pod_to_wait:
      - co
      - co-postgresql
      - fsi-backoffice
      - fsi-customer
#- name: "Start build of BPM Process application"
#  shell: "oc start-build co"