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

docker_swarm module does not actually apply node_id parameter #53501

Closed
jwitko opened this issue Mar 8, 2019 · 4 comments · Fixed by #53503
Closed

docker_swarm module does not actually apply node_id parameter #53501

jwitko opened this issue Mar 8, 2019 · 4 comments · Fixed by #53503
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@jwitko
Copy link
Contributor

jwitko commented Mar 8, 2019

SUMMARY

the docker_swarm ansible module contains a parameter to specify node_id in the case of state=remove. In its current state the module does not apply this parameter regardless if its specified or not.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
ANSIBLE VERSION
ansible 2.7.7
  config file = /home/admin.witkowski/throtle-ansible/ansible.cfg
  configured module search path = [u'/home/admin.witkowski/throtle-ansible/library']
  ansible python module location = /home/admin.witkowski/throtle-ansible-venv/lib/python2.7/site-packages/ansible
  executable location = /home/admin.witkowski/throtle-ansible-venv/bin/ansible
  python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
CONFIGURATION
ANSIBLE_PIPELINING(/home/admin.witkowski/throtle-ansible/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/home/admin.witkowski/throtle-ansible/ansible.cfg) = -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ForwardAgent=
DEFAULT_CALLBACK_PLUGIN_PATH(/home/admin.witkowski/throtle-ansible/ansible.cfg) = [u'/home/admin.witkowski/throtle-ansible/library/callback']
DEFAULT_FILTER_PLUGIN_PATH(/home/admin.witkowski/throtle-ansible/ansible.cfg) = [u'/usr/share/ansible_plugins/filter_plugins', u'/home/admin.witko
DEFAULT_FORKS(/home/admin.witkowski/throtle-ansible/ansible.cfg) = 15
DEFAULT_GATHERING(/home/admin.witkowski/throtle-ansible/ansible.cfg) = smart
DEFAULT_GATHER_SUBSET(/home/admin.witkowski/throtle-ansible/ansible.cfg) = !hardware,!ohai,!facter
DEFAULT_HOST_LIST(/home/admin.witkowski/throtle-ansible/ansible.cfg) = [u'/home/admin.witkowski/throtle-ansible/inventory']
DEFAULT_MANAGED_STR(/home/admin.witkowski/throtle-ansible/ansible.cfg) = Created by Ansible
DEFAULT_MODULE_PATH(/home/admin.witkowski/throtle-ansible/ansible.cfg) = [u'/home/admin.witkowski/throtle-ansible/library']
DEFAULT_PRIVATE_KEY_FILE(/home/admin.witkowski/throtle-ansible/ansible.cfg) = /home/admin.witkowski/.ssh/throtle-ansible.key
DEFAULT_ROLES_PATH(/home/admin.witkowski/throtle-ansible/ansible.cfg) = [u'/home/admin.witkowski/throtle-ansible/roles']
DEFAULT_SCP_IF_SSH(/home/admin.witkowski/throtle-ansible/ansible.cfg) = True
DEFAULT_VAULT_PASSWORD_FILE(/home/admin.witkowski/throtle-ansible/ansible.cfg) = /home/admin.witkowski/throtle-ansible/.vault
DISPLAY_ARGS_TO_STDOUT(/home/admin.witkowski/throtle-ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/home/admin.witkowski/throtle-ansible/ansible.cfg) = False
RETRY_FILES_SAVE_PATH(/home/admin.witkowski/throtle-ansible/ansible.cfg) = /home/admin.witkowski/.ansible/retry-files

OS / ENVIRONMENT

CentOS 7
Docker-CE 18.09.2, 18.09.3
Swarm mode enabled

STEPS TO REPRODUCE
    - name: Remove node from swarm
      docker_swarm:
        docker_host: 'tcp://{{ swarm_master_ip }}:2375'
        state: remove
        node_id: "{{ node_id }}" # Server must be demoted from manager in swarm
EXPECTED RESULTS

Node removed from docker swarm cluster.

ACTUAL RESULTS

The removal attempts to run on the host which is receiving the API call. Error reports about the node being a manager since it has not been demoted.

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Mar 8, 2019
jwitko added a commit to jwitko/ansible that referenced this issue Mar 8, 2019
This fixes ansible#53501

The module currently does not define a default `None` for `node_id` in the Spec section.  It also does not apply it during the node removal phase causing the removal to get attempted on the swarm manager that is receiving the API request instead of the swarm node specified by the `node_id` parameter.  This is met with an error since the manager receiving the request is likely not demoted and if it was it could not service the API request.
@felixfontein
Copy link
Contributor

!component =lib/ansible/modules/cloud/docker/docker_swarm.py

@felixfontein
Copy link
Contributor

Are you sure this already happens in 2.7.7? I think it just happens in devel, and in current stable-2.7 (which hasn't been released yet).

@felixfontein
Copy link
Contributor

Anyway, a very good catch, since this is unfortunately one of the things the tests won't catch (since that requires more than one node...), and neither can I locally (with also just a one-node cluster).

@felixfontein
Copy link
Contributor

Ah, sorry, it does happen in 2.7.7 as well (and probably all earlier versions). I thought I've thrown node_id out from TaskParameters (but forgot to adjust the places where it is used), but apparently it has never been in there...

@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Mar 11, 2019
@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
4 participants