add support for check_mode for modules k8s_scale and k8s_rollback (#255)

k8s_scale, k8s_rollback - add support for check_mode 

SUMMARY

closes #243 and #244

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

k8s_scale
k8s_rollback
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
Reviewed-by: Mike Graves <mgraves@redhat.com>
This commit is contained in:
abikouo
2022-02-16 20:05:28 +01:00
committed by GitHub
parent 951be74dc0
commit 691f0cb235
5 changed files with 262 additions and 72 deletions

View File

@@ -45,6 +45,68 @@
field_selectors:
- status.phase=Running
- name: Scale the deployment (check_mode)
k8s_scale:
api_version: apps/v1
kind: Deployment
name: scale-deploy
namespace: "{{ scale_namespace }}"
replicas: 0
wait: yes
register: scale_down
check_mode: true
- name: Get pods in scale-deploy
k8s_info:
kind: Pod
label_selectors:
- app=scale-deploy
namespace: "{{ scale_namespace }}"
field_selectors:
- status.phase=Running
register: scale_down_deploy_pods
ignore_errors: true
until: scale_down_deploy_pods.resources | length == 0
retries: 6
delay: 5
- name: Ensure the deployment did not changed and pods are still running
assert:
that:
- scale_down is changed
- scale_down_deploy_pods.resources | length > 0
- name: Scale the deployment (check_mode) once again - validate idempotency
k8s_scale:
api_version: apps/v1
kind: Deployment
name: scale-deploy
namespace: "{{ scale_namespace }}"
replicas: 0
wait: yes
register: scale_down
check_mode: true
- name: Get pods in scale-deploy
k8s_info:
kind: Pod
label_selectors:
- app=scale-deploy
namespace: "{{ scale_namespace }}"
field_selectors:
- status.phase=Running
register: scale_down_deploy_pods
ignore_errors: true
until: scale_down_deploy_pods.resources | length == 0
retries: 6
delay: 5
- name: Ensure the deployment did not changed and pods are still running
assert:
that:
- scale_down is changed
- scale_down_deploy_pods.resources | length > 0
- name: Scale the deployment
k8s_scale:
api_version: apps/v1
@@ -76,6 +138,22 @@
- '"duration" in scale_down'
- scale_down.diff
- name: Scale the deployment once again (idempotency)
k8s_scale:
api_version: apps/v1
kind: Deployment
name: scale-deploy
namespace: "{{ scale_namespace }}"
replicas: 0
wait: yes
register: scale_down_idempotency
diff: true
- name: Ensure that scale down did not took effect
assert:
that:
- scale_down_idempotency is not changed
- name: Reapply the earlier deployment
k8s:
definition: