Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
* Get rid of the caasp_cmd.run state, as the retry is now part
Browse files Browse the repository at this point in the history
of the standard Salt cmd.run state (and it was messing with it).
* Add an `interval` for the `http.wait_for_sucessful_query`

bsc#1127036

Signed-off-by: Alvaro Saurin <[email protected]>
  • Loading branch information
inercia committed Feb 28, 2019
1 parent 6af85a7 commit ff27951
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 238 deletions.
8 changes: 4 additions & 4 deletions salt/_macros/kubectl.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
# right dependencies...

{% macro _kubectl_run(args) -%}
caasp_cmd.run:
cmd.run:
- name: kubectl --request-timeout=1m --kubeconfig={{ pillar['paths']['kubeconfig'] }} {{ args }}
- retry:
attempts: 10
interval: 1
attempts: 60
interval: 2
- require:
- {{ pillar['paths']['kubeconfig'] }}
{%- if 'require' in kwargs %}
Expand Down Expand Up @@ -89,7 +89,7 @@

{% macro kubectl_wait_for_deployment(deployment, namespace = 'kube-system', timeout = 600) -%}
wait-for-{{ deployment }}-deployment:
caasp_cmd.run:
cmd.run:
- name: |-
desiredReplicas=$(kubectl --request-timeout=1m --kubeconfig={{ pillar['paths']['kubeconfig'] }} get deployment {{ deployment }} --namespace={{ namespace }} --template {{ '{{.spec.replicas}}' }})
readyReplicas=$(kubectl --request-timeout=1m --kubeconfig={{ pillar['paths']['kubeconfig'] }} get deployment {{ deployment }} --namespace={{ namespace }} --template {{ '{{.status.readyReplicas}}' }})
Expand Down
228 changes: 0 additions & 228 deletions salt/_states/caasp_cmd.py

This file was deleted.

8 changes: 4 additions & 4 deletions salt/_states/caasp_etcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def etcdctl(name, retry={}, **kwargs):
Arguments:
In addition to all the arguments supported by the `caasp_cmd.run` state.
In addition to all the arguments supported by the `cmd.run` state.
* `skip_this`: (optional) skip current node when calculating the list of etcd endpoints.
Expand All @@ -39,9 +39,9 @@ def etcdctl(name, retry={}, **kwargs):
else:
cmd = 'ETCDCTL_API=3 {}'.format(cmd)

return __states__['caasp_cmd.run'](name=cmd,
retry=retry_,
**kwargs)
return __states__['cmd.run'](name=cmd,
retry=retry_,
**kwargs)


def healthy(name, **kwargs):
Expand Down
5 changes: 4 additions & 1 deletion salt/_states/caasp_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def query(name, match=None, match_type='string', status=None, wait_for=None, **k
return ret


def wait_for_successful_query(name, wait_for=300, **kwargs):
def wait_for_successful_query(name, wait_for=300, interval=1, **kwargs):
'''
Like query but, repeat and wait until match/match_type or status is fulfilled. State returns result from last
query state in case of success or if no successful query was made within wait_for timeout.
Expand All @@ -154,3 +154,6 @@ def wait_for_successful_query(name, wait_for=300, **kwargs):
raise caught_exception # pylint: disable=E0702

return ret

if interval > 0:
time.sleep(interval)
2 changes: 1 addition & 1 deletion salt/kubelet/update-post-start-services.sls
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include:
{% if salt['grains.get']('kubelet:should_uncordon', false) %}

uncordon-node:
caasp_cmd.run:
cmd.run:
- name: |
kubectl --request-timeout=1m uncordon {{ grains['nodename'] }}
- retry:
Expand Down

0 comments on commit ff27951

Please sign in to comment.