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_service continuously attempts to update Swarm services which use host network #13

Open
pa-yourserveradmin-com opened this issue Aug 20, 2020 · 5 comments
Labels
bug Something isn't working docker-swarm Docker Swarm

Comments

@pa-yourserveradmin-com
Copy link

SUMMARY

The problem is docker_swarm_service module works incorrectly with Swarm services which use host network(s) and continuously attempts to update such services due to wrong processing of host networks.

Sample patch which also may help to solve the issue can be found in f43219827dbabf33f43af2114838ee20.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

docker_swarm_service

ANSIBLE VERSION
ansible 2.9.12
  config file = /home/pa/PycharmProjects/ansible/ansible.cfg
  configured module search path = ['/home/pa/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/pa/PycharmProjects/ansible/venv/lib64/python3.8/site-packages/ansible
  executable location = /home/pa/PycharmProjects/ansible/venv/bin/ansible
  python version = 3.8.5 (default, Aug 12 2020, 00:00:00) [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]
CONFIGURATION
ANSIBLE_PIPELINING(/home/pa/PycharmProjects/ansible/ansible.cfg) = True
DEFAULT_CALLBACK_WHITELIST(/home/pa/PycharmProjects/ansible/ansible.cfg) = ['profile_tasks']
DISPLAY_SKIPPED_HOSTS(env: ANSIBLE_DISPLAY_SKIPPED_HOSTS) = False
HOST_KEY_CHECKING(env: ANSIBLE_HOST_KEY_CHECKING) = False
OS / ENVIRONMENT

Docker server and API information:

Server: Docker Engine - Community
 Engine:
  Version:          19.03.11
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       42e35e61f3
  Built:            Mon Jun  1 09:12:26 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Python docker module version:

Name: docker
Version: 4.3.0
Summary: A Python library for the Docker Engine API.
Home-page: https://github.com/docker/docker-py
Author: None
Author-email: None
License: Apache License 2.0
Location: /usr/lib/python3.6/site-packages
Requires: six, websocket-client, requests
STEPS TO REPRODUCE

Before all you will need Docker Swarm cluster to deploy service using example playbook provided below.

Example playbook which will deploy Nginx containers to Swarm using host network (please customize it according to local testing environment):

---
- hosts: all

  tasks:

    - docker_swarm_service:
        image: nginx:latest
        mode: global
        name: nginx
        networks:
          - host

Once playbook is applied - run it once again with --check --diff options to see planned changes.

Run playbook once again and it will report changes in Swarm service configuration while service configuration actually not changed (i.e. no downtime actually happen what significantly reduces impact of this issue).

EXPECTED RESULTS

No changes reported in dry-run and run modes when nothing really changed in service configuration.

ACTUAL RESULTS

Either in dry-run or run mode Ansible updates Swarm service with wrong network ID:

--- before
+++ after
@@ -1,7 +1,7 @@
 {
     "networks": [
         {
-            "id": "exvfwyotuxat3z1bt38s3rork"
+            "id": "71d4bd2cf80870bf68df480c876e01ea02183d8fc33d292658c49f323e5c795a"
         }
     ]
 }

Correct network exvfwyotuxat3z1bt38s3rork has swarm scope and inspect returns the next information:

$ docker network inspect exvfwyotuxat3z1bt38s3rork
[
    {
        "Name": "host",
        "Id": "exvfwyotuxat3z1bt38s3rork",
        "Created": "2020-07-01T17:26:48.708139127Z",
        "Scope": "swarm",
        "Driver": "host",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "",
            "Options": null,
            "Config": []
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": null,
        "Options": null,
        "Labels": {
            "com.docker.swarm.predefined": "true"
        }
    }
]

Wrong network 71d4bd2cf80870bf68df480c876e01ea02183d8fc33d292658c49f323e5c795a has local scope and inspect returns the next information:

$ docker network inspect 71d4bd2cf80870bf68df480c876e01ea02183d8fc33d292658c49f323e5c795a
[
    {
        "Name": "host",
        "Id": "71d4bd2cf80870bf68df480c876e01ea02183d8fc33d292658c49f323e5c795a",
        "Created": "2020-06-26T14:09:30.161137267Z",
        "Scope": "local",
        "Driver": "host",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": []
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]
@pa-yourserveradmin-com
Copy link
Author

pa-yourserveradmin-com commented Aug 20, 2020

Originally posted in ansible/ansible#71386.

@pa-yourserveradmin-com
Copy link
Author

Hey, guys. Do you need any additional details about this issue?

@felixfontein
Copy link
Collaborator

@dariko @jwitko @hannseman can you take a look at this?

@felixfontein
Copy link
Collaborator

Ping @dariko @jwitko @hannseman

@gundalow gundalow transferred this issue from ansible-collections/community.general Oct 30, 2020
@felixfontein felixfontein added the docker-swarm Docker Swarm label Jan 2, 2021
@felixfontein felixfontein added the bug Something isn't working label Sep 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docker-swarm Docker Swarm
Projects
None yet
Development

No branches or pull requests

3 participants