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

Links ignore other running services when restarting a single service #929

Open
Chostakovitch opened this issue May 16, 2018 · 0 comments
Open

Comments

@Chostakovitch
Copy link

ISSUE TYPE
  • Bug Report
container.yml
version: "2"
settings:
  conductor:
    base: alpine:3.5
  project_name: link_alias

services:
  dest_link:
    from: alpine:3.5
    command: [ 'sleep', '1000' ]

  source_link:
    from: alpine:3.5
    command: [ 'sleep', '1000' ]
    links:
      - dest_link
OS / ENVIRONMENT
Ansible Container, version 0.9.3rc0
Linux, chosto-XPS-15-9560, 4.13.0-39-generic, #44-Ubuntu SMP Thu Apr 5 14:25:01 UTC 2018, x86_64
2.7.14 (default, Sep 23 2017, 22:06:14) 
[GCC 7.2.0] /usr/bin/python
{
  "ContainersPaused": 0, 
  "Labels": [], 
  "CgroupDriver": "cgroupfs", 
  "ContainersRunning": 13, 
  "ContainerdCommit": {
    "Expected": "773c489c9c1b21a6d78b5c538cd395416ec50f88", 
    "ID": "773c489c9c1b21a6d78b5c538cd395416ec50f88"
  }, 
  "InitBinary": "docker-init", 
  "NGoroutines": 112, 
  "Swarm": {
    "ControlAvailable": false, 
    "NodeID": "", 
    "Error": "", 
    "RemoteManagers": null, 
    "LocalNodeState": "inactive", 
    "NodeAddr": ""
  }, 
  "LoggingDriver": "json-file", 
  "OSType": "linux", 
  "HttpProxy": "", 
  "Runtimes": {
    "runc": {
      "path": "docker-runc"
    }
  }, 
  "DriverStatus": [
    [
      "Backing Filesystem", 
      "extfs"
    ], 
    [
      "Supports d_type", 
      "true"
    ], 
    [
      "Native Overlay Diff", 
      "true"
    ]
  ], 
  "OperatingSystem": "Ubuntu 17.10", 
  "Containers": 56, 
  "HttpsProxy": "", 
  "BridgeNfIp6tables": true, 
  "MemTotal": 16662814720, 
  "SecurityOptions": [
    "name=apparmor", 
    "name=seccomp,profile=default"
  ], 
  "Driver": "overlay2", 
  "IndexServerAddress": "https://index.docker.io/v1/", 
  "ClusterStore": "", 
  "InitCommit": {
    "Expected": "949e6fa", 
    "ID": "949e6fa"
  }, 
  "GenericResources": null, 
  "Isolation": "", 
  "SystemStatus": null, 
  "OomKillDisable": true, 
  "ClusterAdvertise": "", 
  "SystemTime": "2018-05-16T17:14:25.682903347+02:00", 
  "Name": "chosto-XPS-15-9560", 
  "CPUSet": true, 
  "RegistryConfig": {
    "AllowNondistributableArtifactsCIDRs": [], 
    "Mirrors": [], 
    "IndexConfigs": {
      "docker.io": {
        "Official": true, 
        "Name": "docker.io", 
        "Secure": true, 
        "Mirrors": []
      }
    }, 
    "AllowNondistributableArtifactsHostnames": [], 
    "InsecureRegistryCIDRs": [
      "127.0.0.0/8"
    ]
  }, 
  "DefaultRuntime": "runc", 
  "ContainersStopped": 43, 
  "NCPU": 8, 
  "NFd": 124, 
  "Architecture": "x86_64", 
  "KernelMemory": true, 
  "CpuCfsQuota": true, 
  "Debug": false, 
  "ID": "QKCR:7XJZ:3377:X2MH:6HP2:4DHH:MHE3:54OJ:5YFO:4Q4I:PJYL:C6FV", 
  "IPv4Forwarding": true, 
  "KernelVersion": "4.13.0-39-generic", 
  "BridgeNfIptables": true, 
  "NoProxy": "", 
  "LiveRestoreEnabled": false, 
  "ServerVersion": "18.03.1-ce", 
  "CpuCfsPeriod": true, 
  "ExperimentalBuild": false, 
  "MemoryLimit": true, 
  "SwapLimit": false, 
  "Plugins": {
    "Volume": [
      "local"
    ], 
    "Network": [
      "bridge", 
      "host", 
      "macvlan", 
      "null", 
      "overlay"
    ], 
    "Authorization": null, 
    "Log": [
      "awslogs", 
      "fluentd", 
      "gcplogs", 
      "gelf", 
      "journald", 
      "json-file", 
      "logentries", 
      "splunk", 
      "syslog"
    ]
  }, 
  "Images": 82, 
  "DockerRootDir": "/var/lib/docker", 
  "NEventsListener": 0, 
  "CPUShares": true, 
  "RuncCommit": {
    "Expected": "4fc53a81fb7c994640722ac585fa9ca548971871", 
    "ID": "4fc53a81fb7c994640722ac585fa9ca548971871"
  }
}
{
  "KernelVersion": "4.13.0-39-generic", 
  "Components": [
    {
      "Version": "18.03.1-ce", 
      "Name": "Engine", 
      "Details": {
        "KernelVersion": "4.13.0-39-generic", 
        "Os": "linux", 
        "BuildTime": "2018-04-26T07:15:45.000000000+00:00", 
        "ApiVersion": "1.37", 
        "MinAPIVersion": "1.12", 
        "GitCommit": "9ee9f40", 
        "Arch": "amd64", 
        "Experimental": "false", 
        "GoVersion": "go1.9.5"
      }
    }
  ], 
  "Arch": "amd64", 
  "BuildTime": "2018-04-26T07:15:45.000000000+00:00", 
  "ApiVersion": "1.37", 
  "Platform": {
    "Name": ""
  }, 
  "Version": "18.03.1-ce", 
  "MinAPIVersion": "1.12", 
  "GitCommit": "9ee9f40", 
  "Os": "linux", 
  "GoVersion": "go1.9.5"
}

SUMMARY

When linking services together, I am not able to specifically start a single service which is linked to another service because the other service is reported as undefined.

With an analog docker-compose, I don't experiment this behavior, see last section.

STEPS TO REPRODUCE
ansible-container init
# fill-up container.yml with file above
ansible-container build
ansible-container run # works fine
ansible-container restart source_link dest_link # also works fine
ansible-container restart source_link # fails
EXPECTED RESULTS

I expect the service to be restarted and either linked to the already running container, either to a new container.

ACTUAL RESULTS

The target service is reported as undefined.

# output truncated
The full traceback is:
  File "/tmp/ansible_IXOxuw/ansible_module_docker_service.py", line 648, in __init__
    self.project = project_from_options(self.project_src, self.options)
  File "/usr/lib/python2.7/site-packages/compose/cli/command.py", line 41, in project_from_options
    compatibility=options.get('--compatibility'),
  File "/usr/lib/python2.7/site-packages/compose/cli/command.py", line 113, in get_project
    config_data = config.load(config_details, compatibility)
  File "/usr/lib/python2.7/site-packages/compose/config/config.py", line 402, in load
    service_dicts = load_services(config_details, main_file, compatibility)
  File "/usr/lib/python2.7/site-packages/compose/config/config.py", line 502, in load_services
    return build_services(service_config)
  File "/usr/lib/python2.7/site-packages/compose/config/config.py", line 481, in build_services
    for name, service_dict in service_config.items()
  File "/usr/lib/python2.7/site-packages/compose/config/config.py", line 467, in build_service
    validate_service(service_config, service_names, config_file)
  File "/usr/lib/python2.7/site-packages/compose/config/config.py", line 705, in validate_service
    validate_links(service_config, service_names)
  File "/usr/lib/python2.7/site-packages/compose/config/validation.py", line 230, in validate_links
    "undefined.".format(s=service_config, link=link))
fatal: [localhost]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_args": {
            "api_version": null,
            "build": false,
            "cacert_path": null,
            "cert_path": null,
            "debug": false,
            "definition": {
                "services": {
                    "source_link": {
                        "command": [
                            "sleep",
                            "1000"
                        ],
                        "image": "alpine:3.5",
                        "links": [
                            "dest_link"
                        ]
                    }
                },
                "version": "2"
            },
            "dependencies": true,
            "docker_host": null,
            "files": null,
            "filter_logger": false,
            "hostname_check": false,
            "key_path": null,
            "nocache": false,
            "project_name": "link_alias",
            "project_src": null,
            "pull": false,
            "recreate": "smart",
            "remove_images": null,
            "remove_orphans": false,
            "remove_volumes": false,
            "restarted": true,
            "scale": null,
            "services": null,
            "ssl_version": null,
            "state": "present",
            "stopped": false,
            "timeout": 10,
            "tls": null,
            "tls_hostname": null,
            "tls_verify": null
        }
    },
    "msg": "Configuration error - Service 'source_link' has a link to service 'dest_link' which is undefined."
}
WITH DOCKER-COMPOSE

I don't know if this is relevant, but check this analog docker-compose.yml :

version: '2'
services:
  dest_link:
    image: "alpine:3.5"
    command: [ "sleep", "1000" ]
  source_link:
    image: "alpine:3.5"
    command: [ "sleep", "1000" ]
    links:
      - dest_link

When running the following analog commands :

docker-compose up -d
docker-compose restart -t 1 source_link

All works fine.

Thank you for your time and please tell me if you need anything else.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant