Skip to content

Remove container name not empty check#12269

Merged
estesp merged 1 commit intomoby:masterfrom
kostickm:12251-remove-not-empty-check
Apr 14, 2015
Merged

Remove container name not empty check#12269
estesp merged 1 commit intomoby:masterfrom
kostickm:12251-remove-not-empty-check

Conversation

@kostickm
Copy link
Contributor

Removed the unneeded not empty container name check from getContainersChanges and deleteContainers. Fixes #12251

Signed-off-by: Megan Kostick [email protected]

@tiborvass
Copy link
Contributor

LGTM

@duglin
Copy link
Contributor

duglin commented Apr 10, 2015

The problem with this is that now we say:
Error response from daemon: Prefix can't be empty
which isn't very meaningful to an end-user.

@duglin
Copy link
Contributor

duglin commented Apr 10, 2015

At least for delete, I prefer the current msg:
Error response from daemon: Container name cannot be empty

@kostickm
Copy link
Contributor Author

@duglin So does deleteContainers not fall under the same scenario as stated in the issue "Check is not needed because the http handler didn't match that route with an empty string" ?

@runcom
Copy link
Member

runcom commented Apr 10, 2015

Why shouldn't it? There's another check in GetFullContainerName in ContainerRm that says Container name cannot be emtpy. @duglin when is printing Prefix can't be empty?

@duglin
Copy link
Contributor

duglin commented Apr 10, 2015

Actually, I would almost prefer if we checked for these on the CLI - and printed a nice error message from there. Then on the daemon side I'd expect both to return 404's since I think they map to:

diff: ../containers//changes - which gets a 301 redirect to ../containers/changes - which then gives a 404
del: ../containers/

@runcom
Copy link
Member

runcom commented Apr 10, 2015

I like 404 from a rest view..

@duglin
Copy link
Contributor

duglin commented Apr 10, 2015

@runcom with this PR I get this:

$docker rm ""
Error response from daemon: Prefix can't be empty
FATA[0000] Error: failed to remove one or more containers 

which isn't very friendly as the old way.

@runcom
Copy link
Member

runcom commented Apr 10, 2015

@runcom
Copy link
Member

runcom commented Apr 10, 2015

because there was no check before, and that just maintained the old behaviour

@runcom
Copy link
Member

runcom commented Apr 10, 2015

antonio-laptop :: ~ » docker rm ""
Error response from daemon: Prefix can't be empty
FATA[0000] Error: failed to remove one or more containers

I get this error even on 1.6 rc5

@duglin
Copy link
Contributor

duglin commented Apr 10, 2015

In my master (just refreshed) I get:

$ docker rm ""
Error response from daemon: Container name cannot be empty
FATA[0000] Error: failed to remove one or more containers 

@duglin
Copy link
Contributor

duglin commented Apr 10, 2015

Regardless, I think the "Container name cannot be empty" is the right one - so, let's make that come out.... somehow (and on purpose) :-)

@kostickm
Copy link
Contributor Author

@duglin So change back deleteContainers, but getContainersChanges is fine as is?

@runcom
Copy link
Member

runcom commented Apr 10, 2015

you get that on master AND on 1.5.0+... however yes Container name cannot be empty is more meaningful

@duglin
Copy link
Contributor

duglin commented Apr 10, 2015

@kostickm let's add checks to the CLI code to stop "" even before it tries to hit the daemon - for both.

I think the daemon side changes for "changes"/diff are ok.

For "delete" though, we have an interesting situation where:
DELETE ../containers/ returns Prefix can't be empty
but
DELETE ../containers returns a 404.
and
DELETE ../containers/foo returns a 404.
I would prefer if the "../containers/" acted like the other 2 and returned a 404.

@kostickm
Copy link
Contributor Author

I'll work on making those changes.

@kostickm kostickm force-pushed the 12251-remove-not-empty-check branch from 29540ca to a70b198 Compare April 14, 2015 17:56
@kostickm
Copy link
Contributor Author

@duglin For delete, the place where it returns the 404 or the "Prefix can't be empty" is found in pkg/truncindex/truncindex.go. I didn't want to change it at that level in case it is needed in other cases. Though from the CLI with the "" check in place we won't run into this error. I tested it without the CLI check though to make sure it returns the 404 in all cases now.

Let me know what you think :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you don't need the errStr var anywhere else, you can put the strings.ToLower.. line as the first parameter to strings.Contains()

@kostickm
Copy link
Contributor Author

@estesp Let me change that!

@kostickm kostickm force-pushed the 12251-remove-not-empty-check branch from a70b198 to 98f8577 Compare April 14, 2015 18:27
@duglin
Copy link
Contributor

duglin commented Apr 14, 2015

LGTM
But I will note that I'm pretty sure the 404 is coming back because of an interesting behavior on the daemon. In both cases the incoming URL will be something like .../containers// or ../containers//changes which forces a 301 to be returned with with ../container/ or ../containers/changes. And that generates a 404 from a different spot in the code. But that an issue for this PR.

@duglin
Copy link
Contributor

duglin commented Apr 14, 2015

Actually, I take that back - in the rm case it is hitting the new code so that's good :-) (I had a typo in my test)

@estesp
Copy link
Contributor

estesp commented Apr 14, 2015

LGTM

estesp added a commit that referenced this pull request Apr 14, 2015
@estesp estesp merged commit 5395cdc into moby:master Apr 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check for container name not empty is not needed

6 participants