Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check that kube-master, kube-node and etcd groups are not empty. #3367

Merged
merged 1 commit into from
Sep 21, 2018
Merged

Conversation

mgsergio
Copy link
Contributor

This can save a lot of time debugging silly mistakes.

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please email the CNCF helpdesk: [email protected]

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Sep 20, 2018
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 20, 2018
@woopstar
Copy link
Member

Please commit with github user and if so, sign the cla.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 20, 2018
@mgsergio
Copy link
Contributor Author

Please commit with github user and if so, sign the cla.

Done.

@@ -5,6 +5,15 @@
- ansible_version.full|version_compare('2.3.0', '>=')
run_once: yes

- name: Stop if either kube-master, kube-node or etcd is empty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this create any issues when you run playbooks like upgrade / scale and you limit to either masters, nodes or etcd's ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I didn't think of it.
I'll check...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works like a charm. ansible is clever enough to keep groups and other settings intact while using --limit. If to thing carefully it should behave this way because while limiting to some hosts you may still need group and host vars from others. Or you may need to delegate a task to another host. So ansible can't touch your inventory.

2018-09-20 16:52:08 mgserjio: tmp$ cat i.ini
[kube-master]
master1 ansible_host=127.0.0.1

[etcd]
etcd1 ansible_host=127.0.0.1

[kube-node]
node1 ansible_host=127.0.0.1
node2 ansible_host=127.0.0.1
node3 ansible_host=127.0.0.1
node4 ansible_host=127.0.0.1
node5 ansible_host=127.0.0.1

[k8s-cluster:children]
kube-master
kube-node
2018-09-20 16:52:21 mgserjio: tmp$ cat task.yml
- hosts: k8s-cluster
  connection: local

  tasks:
    - name: Stop if either kube-master, kube-node, etcd is empty
      assert:
        that: groups.get('{{ item }}')
      with_items:
        - kube-master
        - kube-node
        - etcd

- hosts: kube-node
  connection: local

  tasks:
    - name: Stop if either kube-master, kube-node, etcd is empty
      assert:
        that: groups.get('{{ item }}')
      with_items:
        - kube-master
        - kube-node
        - etcd
2018-09-20 16:52:27 mgserjio: tmp$ ansible-playbook -i i.ini task.yml --limit master1

PLAY [k8s-cluster] **********************************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************************
ok: [master1]

TASK [Stop if either kube-master, kube-node, etcd is empty] *****************************************************************************************************************************
ok: [master1] => (item=kube-master) => {
    "changed": false,
    "item": "kube-master",
    "msg": "All assertions passed"
}
ok: [master1] => (item=kube-node) => {
    "changed": false,
    "item": "kube-node",
    "msg": "All assertions passed"
}
ok: [master1] => (item=etcd) => {
    "changed": false,
    "item": "etcd",
    "msg": "All assertions passed"
}

PLAY [kube-node] ************************************************************************************************************************************************************************
skipping: no hosts matched

PLAY RECAP ******************************************************************************************************************************************************************************
master1                    : ok=2    changed=0    unreachable=0    failed=0

@mgsergio
Copy link
Contributor Author

Would it be better to move some checks to earlier stages and perform on localhost?

@mgsergio
Copy link
Contributor Author

PTAL

@Atoms
Copy link
Member

Atoms commented Sep 21, 2018

ci check this

@Atoms
Copy link
Member

Atoms commented Sep 21, 2018

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 21, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Atoms

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 21, 2018
@k8s-ci-robot k8s-ci-robot merged commit 6b598ea into kubernetes-sigs:master Sep 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants