Skip to content

Conversation

larsks
Copy link
Contributor

@larsks larsks commented Jul 16, 2015

This changes raises docker.errors.NotFound on 404 errors. This gives
client code the ability to differentiate between "an image does not
exist" and "you are using the api incorrectly".

This inherits from docker.errors.APIError so it will not affect any
existing code.

The particular case I am trying to address is client code that does something like this:

    try:
        container = create_a_container()
    except:
        pull_an_image(image)
        container = create_a_container()

It really only makes sense to retry the create operation if the image
was not found; any other API error will simply fail the second time as
well.

@aanand
Copy link
Contributor

aanand commented Jul 17, 2015

Sounds sensible. You've got some linting errors:

docker/errors.py:55:1: E302 expected 2 blank lines, found 1
docker/errors.py:58:1: E302 expected 2 blank lines, found 1

This changes raises docker.errors.NotFound on 404 errors.  This gives
client code the ability to differentiate between "an image does not
exist" and "you are using the api incorrectly".

This inherits from docker.errors.APIError so it will not affect any
existing code.
@larsks larsks force-pushed the feature/notfound-on-404 branch from 3f7e270 to 2e546f7 Compare July 17, 2015 12:32
@larsks
Copy link
Contributor Author

larsks commented Jul 17, 2015

Thanks, fixed that...

@shin-
Copy link
Contributor

shin- commented Jul 17, 2015

lgtm!

@aanand
Copy link
Contributor

aanand commented Jul 20, 2015

LGTM

aanand added a commit that referenced this pull request Jul 20, 2015
@aanand aanand merged commit 4cfb157 into docker:master Jul 20, 2015
@shin- shin- modified the milestone: 1.3.1 Jul 20, 2015
acaprez added a commit to unlhcc/shipwright that referenced this pull request Mar 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants