Skip to content

Commit

Permalink
Merge pull request #178 from varad-ahirwadkar/eus
Browse files Browse the repository at this point in the history
Minor enhancement for OCP EUS-EUS upgrade
  • Loading branch information
Power Cloud Robot authored Feb 3, 2023
2 parents 9157020 + 301858b commit 9fe3beb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
retry_files_enabled = False
pipelining = True
host_key_checking = False

log_path = /root/ocp4-playbooks/logs.txt
53 changes: 53 additions & 0 deletions playbooks/roles/ocp-upgrade/tasks/eus_upgrades.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---

- name: Get intial kubelet version
kubernetes.core.k8s_info:
kind: Node
register: initial_node_info

- name: Pause the worker's MachineConfigPool
kubernetes.core.k8s:
state: present
Expand All @@ -10,6 +15,14 @@
spec:
paused: true

- name: Check if worker's MachineConfigPool has paused
shell: oc get mcp worker -o json | jq ".spec.paused"
register: worker_mcp_paused
failed_when: not worker_mcp_paused.stdout | bool

- debug:
msg: "Worker's MachineConfigPool has paused. 'spec.paused: {{ worker_mcp_paused.stdout }}'"

- name: Patch the ClusterVersion with the eus intermediate upgrade channel
kubernetes.core.k8s:
state: present
Expand Down Expand Up @@ -92,6 +105,26 @@
msg: "Worker machine config pool get updated"
when: worker_mcp.resources[0].status.updatedMachineCount != 0

- name: Get kubelet version of workers after intermediate upgrade
kubernetes.core.k8s_info:
kind: Node
label_selectors: node-role.kubernetes.io/worker
register: worker_node_info

- debug:
msg: "Kubelet version of worker nodes after intermediate upgrade: {{ item.status.nodeInfo.kubeletVersion }}"
with_items: "{{ worker_node_info.resources }}"
loop_control:
label: "{{ item.status.nodeInfo.kubeletVersion }}"

- name: Validate kubelet version of workers after intermediate upgrade
fail:
msg: "Kubelet version has updated for workers"
when: item.status.nodeInfo.kubeletVersion != initial_node_info.resources[0].status.nodeInfo.kubeletVersion
with_items: "{{ worker_node_info.resources }}"
loop_control:
label: "{{ item.status.nodeInfo.kubeletVersion }}"

- name: Patch the ClusterVersion with the upgrade channel
kubernetes.core.k8s:
state: present
Expand Down Expand Up @@ -144,6 +177,26 @@
msg: "Master MachineConfigPool not get updated"
when: master_mcp.resources[0].status.updatedMachineCount != master_mcp.resources[0].status.machineCount

- name: Get kubelet version of workers after final upgrade
kubernetes.core.k8s_info:
kind: Node
label_selectors: node-role.kubernetes.io/worker
register: worker_node_info

- debug:
msg: "Kubelet version of worker nodes after final upgrade: {{ item.status.nodeInfo.kubeletVersion }}"
with_items: "{{ worker_node_info.resources }}"
loop_control:
label: "{{ item.status.nodeInfo.kubeletVersion }}"

- name: Validate kubelet version of workers after final upgrade
fail:
msg: "Kubelet version has updated for workers"
when: item.status.nodeInfo.kubeletVersion != initial_node_info.resources[0].status.nodeInfo.kubeletVersion
with_items: "{{ worker_node_info.resources }}"
loop_control:
label: "{{ item.status.nodeInfo.kubeletVersion }}"

- name: Resume the worker's MachineConfigPool
kubernetes.core.k8s:
state: present
Expand Down

0 comments on commit 9fe3beb

Please sign in to comment.