Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
Wait should work for deployments when replicas is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
willthames committed Feb 21, 2020
1 parent bce5c48 commit c05d6fd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions molecule/default/tasks/waiter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,30 @@
- deploy.result.status.availableReplicas == deploy.result.status.replicas
- updated_deploy_pods.resources[0].spec.containers[0].image.endswith(":2")

- name: scale a deployment to 0 replicas
k8s:
definition:
apiVersion: apps/v1
kind: Deployment
metadata:
name: wait-deploy
namespace: "{{ wait_namespace }}"
spec:
replicas: 0
selector:
matchLabels:
app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}"
wait: yes
vars:
k8s_pod_name: wait-deploy
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2
k8s_pod_ports:
- containerPort: 8080
name: http
protocol: TCP
register: scale_down_deploy

- name: Pause a deployment
k8s:
definition:
Expand Down
3 changes: 2 additions & 1 deletion plugins/module_utils/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ def wait(self, resource, definition, sleep, timeout, state='present', condition=
def _deployment_ready(deployment):
# FIXME: frustratingly bool(deployment.status) is True even if status is empty
# Furthermore deployment.status.availableReplicas == deployment.status.replicas == None if status is empty
return (deployment.status and deployment.status.replicas is not None and
# deployment.status.replicas is None is perfectly ok if desired replicas == 0
return (deployment.status and
deployment.status.availableReplicas == deployment.status.replicas and
deployment.status.observedGeneration == deployment.metadata.generation and
not deployment.status.unAvailableReplicas)
Expand Down

0 comments on commit c05d6fd

Please sign in to comment.