Skip to content

Return a better error if Docker is not running #56

Description

@benbridts

(using a project started with the pyhton login)
I get this error when I run cfn submit without docker running:

fn submit --dry-run
Starting Docker build. This may take several minutes if the image 'lambci/lambda:build-python3.7' needs to be pulled first.
=== Unhandled exception ===
Please report this issue to the team.
Issue tracker: https://github.com/aws-cloudformation/aws-cloudformation-rpdk/issues
Please include the log file 'rpdk.log'

It's normal that things go wrong, but the message "Could not connect to docker daemon would make the casue clear:

Relevant part of the log:

[2019-11-21T12:04:28Z] DEBUG    - Logging set up successfully
[2019-11-21T12:04:28Z] DEBUG    - Running submit: Namespace(command=<function submit at 0x109444a70>, dry_run=True, endpoint_url=None, region=None, role_arn=None, set_default=False, subparser_name='submit', use_role=True, verbose=0, version=False)
[2019-11-21T12:04:28Z] DEBUG    - Root directory: /Users/ben/src/sandbox/cfn-rp
[2019-11-21T12:04:28Z] DEBUG    - Loading project file '/Users/ben/src/sandbox/cfn-rp/.rpdk-config'
[2019-11-21T12:04:29Z] INFO     - Validating your resource specification...
[2019-11-21T12:04:29Z] DEBUG    - Rewriting refs in '<BASE>' (file:///Users/ben/src/sandbox/cfn-rp/cloudar-ec2-keypair.json)
[2019-11-21T12:04:29Z] DEBUG    - overrides.json not found. Not writing to package.
[2019-11-21T12:04:29Z] DEBUG    - Package started
[2019-11-21T12:04:29Z] DEBUG    - '/Users/ben/src/sandbox/cfn-rp/build' not found, skipping removal
Traceback (most recent call last):
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/rpdk/python/codegen.py", line 187, in _remove_build_artifacts
    shutil.rmtree(deps_path)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/shutil.py", line 485, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/shutil.py", line 483, in rmtree
    orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/ben/src/sandbox/cfn-rp/build'
[2019-11-21T12:04:29Z] DEBUG    - Dependencies build started from '/Users/ben/src/sandbox/cfn-rp'
[2019-11-21T12:04:29Z] DEBUG    - command is 'pip install --no-cache-dir --no-color --disable-pip-version-check --upgrade --find-links /project --requirement /project/requirements.txt --target /project/build'
[2019-11-21T12:04:29Z] WARNING  - Starting Docker build. This may take several minutes if the image 'lambci/lambda:build-python3.7' needs to be pulled first.
[2019-11-21T12:04:29Z] DEBUG    - Trying paths: ['/Users/ben/.docker/config.json', '/Users/ben/.dockercfg']
[2019-11-21T12:04:29Z] DEBUG    - Found file at path: /Users/ben/.docker/config.json
[2019-11-21T12:04:29Z] DEBUG    - Found 'credsStore' section
[2019-11-21T12:04:29Z] DEBUG    - Unhandled exception
Traceback (most recent call last):
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/urllib3/connectionpool.py", line 387, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/docker/transport/unixconn.py", line 43, in connect
    sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/urllib3/util/retry.py", line 400, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/urllib3/packages/six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/urllib3/connectionpool.py", line 387, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/docker/transport/unixconn.py", line 43, in connect
    sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/rpdk/core/cli.py", line 98, in main
    args.command(args)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/rpdk/core/submit.py", line 21, in submit
    args.set_default,
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/rpdk/core/project.py", line 285, in submit
    self._plugin.package(self, zip_file)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/rpdk/python/codegen.py", line 175, in package
    self._build(project.root)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/rpdk/python/codegen.py", line 194, in _build
    self._docker_build(base_path)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/rpdk/python/codegen.py", line 250, in _docker_build
    stream=True,
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/docker/models/containers.py", line 785, in run
    detach=detach, **kwargs)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/docker/models/containers.py", line 843, in create
    resp = self.client.api.create_container(**create_kwargs)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/docker/api/container.py", line 427, in create_container
    return self.create_container_from_config(config, name)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/docker/api/container.py", line 437, in create_container_from_config
    res = self._post_json(u, data=config, params=params)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/docker/api/client.py", line 289, in _post_json
    return self._post(url, data=json.dumps(data2), **kwargs)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/docker/api/client.py", line 226, in _post
    return self.post(url, **self._set_request_timeout(kwargs))
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/Users/ben/.local/share/virtualenvs/cfn-rp-NqS8upcL/lib/python3.7/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

Activity

  1. johnttompkins commented on Nov 21, 2019

    @johnttompkins
    Contributor

    Looks like this is specific to the python plugin packaging. I'll transfer this over to the python plugin.

  2. tobywf commented on Nov 23, 2019

    @tobywf
    Contributor

    ah, didn't know this could be thrown, and i thought we were catching all the appropriate errors here:
    https://github.com/aws-cloudformation/aws-cloudformation-rpdk-python-plugin/blob/9eda207789e9d904a529dff802f5c73addacb2a7/python/rpdk/python/codegen.py#L252-L253

    catching requests.exceptions.ConnectionError inside _docker_build is definitely possible, would be a good improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or requestgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions