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

Rename a existing container #8570

Merged
merged 1 commit into from
Jan 13, 2015
Merged

Conversation

brahmaroutu
Copy link
Contributor

Addresses #3036

Signed-off-by: Srini Brahmaroutu srbrahma@us.ibm.com

@brahmaroutu brahmaroutu force-pushed the rename_container_3036 branch 4 times, most recently from cb27f73 to 73a69ac Compare October 16, 2014 18:24
There are no available options.

# HISTORY
October 2014, updated by Sven Dowideit <SvenDowideit@home.org.au>
Copy link
Contributor

Choose a reason for hiding this comment

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

lies! i never wrote this ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops let me see, It may be just a cut and paste issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, It is a cut and paste errors(now removed).

@SvenDowideit
Copy link
Contributor

oh, yes, i would like this. Docs LGTM -

now for an implementation question.

what happens when you rename a container that has been linked to? does everything still hand together? (I presume so, but :))

@brahmaroutu brahmaroutu force-pushed the rename_container_3036 branch 2 times, most recently from 1f39e4c to 62892b9 Compare October 29, 2014 03:09
@brahmaroutu
Copy link
Contributor Author

About the links, they work after rename, I tested them manually and also have integration tests that I can add, please let me know. I see the link is actually added to hosts file using IP address and container name is not used.

@SvenDowideit
Copy link
Contributor

nice - @jamtur01 @fredlf

plus you need core review, @crosbymichael @tiborvass ?

@SvenDowideit SvenDowideit changed the title rename a existing container Proposal: Rename a existing container Oct 30, 2014
@@ -79,6 +79,7 @@ func init() {
{"ps", "List containers"},
{"pull", "Pull an image or a repository from a Docker registry server"},
{"push", "Push an image or a repository to a Docker registry server"},
{"rename", "Rename a existing container"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be "an existing", here and below.

@fredlf
Copy link
Contributor

fredlf commented Nov 3, 2014

Docs LGTM from me once the grammar mistake is fixed. Ping @jamtur01 @ostezer.

Still needs core review. Ping @crosbymichael @tiborvass

Many thanks for the contribution.

@tiborvass tiborvass changed the title Proposal: Rename a existing container Rename a existing container Nov 3, 2014
@tiborvass
Copy link
Contributor

@brahmaroutu Thanks for your contribution.

I'd like to note though that this is not a proposal (hence my editing of the title). A proposal is either in a form of an issue explaining what are the changes needed and why, OR a PR to the documentation explaining what would change if it were implemented (see #8859 as an example).

Design needs to be reviewed with @shykes. Sorry if it's taking longer than expected! I'll make sure we review this in the next design review session.

@brahmaroutu
Copy link
Contributor Author

@fredlf Sorry, I made that minor change to docs.
@tiborvass Thanks for reviewing, I understand such changes require more diligent review considerations.

@fredlf
Copy link
Contributor

fredlf commented Nov 3, 2014

No problem, and thanks!

@brahmaroutu brahmaroutu force-pushed the rename_container_3036 branch 3 times, most recently from 50c38fb to 7712f98 Compare December 2, 2014 20:31
@shykes
Copy link
Contributor

shykes commented Dec 23, 2014

Design review with @icecrime

I approve docker rename OLD NEW. I haven't looked at the implementation. In particular please make sure edge cases are properly handled in the underlying storage (graphdb etc).

@shykes shykes removed UX labels Dec 23, 2014
@shykes
Copy link
Contributor

shykes commented Dec 23, 2014

#uxapproved

t.Fatal(out, err)
}

dockerCmd(t, "kill", idA)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think these are needed if you deleteAllContainers

@LK4D4
Copy link
Contributor

LK4D4 commented Jan 9, 2015

ping @jfrazelle @icecrime @tiborvass

return job.Errorf("Failed to delete container %q: %v", old_name, err)
}
if _, err := daemon.reserveName(container.ID, new_name); err != nil {
return job.Errorf("Error when allocating new name: %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a major issue here, as error is returned without releasing the lock (same for the code path right above):

$ docker run --name test busybox true
$ docker rename test " "
Error response from daemon: Error when allocating new name: Invalid container name ( ), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed
FATA[0000] Error: failed to rename container named test
$ docker ps -a # Hangs (probably daemon in deadlock)

I think we should use defer container.Unlock() to play safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added defer on Unlock. thanks for pointing it out.

@icecrime
Copy link
Contributor

icecrime commented Jan 9, 2015

Not LGTM: there is a blocking issue (see my comment).

@brahmaroutu
Copy link
Contributor Author

Please let me know if I change it to the first ever PUT on Docker server, makes sense, instead of POST?

@icecrime
Copy link
Contributor

Can we get an API maintainer input on the method to use so we can move on with this cool PR? Ping @vieux @jfrazelle!

@vieux
Copy link
Contributor

vieux commented Jan 13, 2015

I would use GET parameter:

"/containers/{name:.*}/rename?name={newname}"

@brahmaroutu
Copy link
Contributor Author

@vieux Can you also let me know if I should change it to PUT call?

@vieux
Copy link
Contributor

vieux commented Jan 13, 2015

Sorry I meant a POST /containers/{name:.*}/rename?name={newname}

We don't have any PUT on the API, we use only POST, GET or DELETE to I would stay on the POST

Closes moby#3036

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
@brahmaroutu
Copy link
Contributor Author

@vieux @cpuguy83 @LK4D4 Please review, code is updated as per your comments

@LK4D4
Copy link
Contributor

LK4D4 commented Jan 13, 2015

LGTM

@thaJeztah
Copy link
Member

fwiw; since I'm the one coming up with PUT originally; I'm fine with POST for consistency with the rest of the API.

(If the need ever rises to be more "strict", I think that would require a complete review of the whole API)

@jessfraz
Copy link
Contributor

LGTM

jessfraz pushed a commit that referenced this pull request Jan 13, 2015
@jessfraz jessfraz merged commit b9e42d6 into moby:master Jan 13, 2015
@vieux
Copy link
Contributor

vieux commented Jan 13, 2015

No API bump ?
No New section in docs/sources/reference/api/docker_remote_api.md ?

@jessfraz
Copy link
Contributor

@vieux making patch now

@vieux
Copy link
Contributor

vieux commented Jan 13, 2015

@jfrazelle thank you.

@vieux
Copy link
Contributor

vieux commented Jan 13, 2015

It's easier for us when there is doc, every week we can look and see if we need to add the new endpoints in swarm.

@brahmaroutu
Copy link
Contributor Author

@jfrazelle thanks, let me know if I can help.

thaJeztah added a commit to thaJeztah/docker that referenced this pull request Jan 13, 2015
The "or rename" part was removed from the error-message,
because renaming wasn't possible at the time.

Now that moby#8570 is merged,
renaming existing containers is possible.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@brahmaroutu
Copy link
Contributor Author

@borromeotlhs there are not many tests testing 409 and I did not add one. I can quickly add a test if you want but I need a issue to do so.

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.

None yet