Skip to content

Name containers created by s2i explicitly - #496

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
rhcarvalho:issue395-consistent-container-names
Jun 27, 2016
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
rhcarvalho:issue395-consistent-container-names

Conversation

@rhcarvalho

@rhcarvalho rhcarvalho commented May 15, 2016 •

Copy link
Copy Markdown
Contributor

Instead of leaving the name blank and letting the Docker daemon name
containers with random strings like 'lonely_thompson', we give proper
names so that we can identify and filter containers created by S2I
later.

Names take a fixed prefix, 's2i_', and a random suffix. The builder
image is also used to compose the container name, replacing with
underscores characters that would be invalid for a container name.

Example:

$ s2i build \
    git://github.com/openshift/ruby-hello-world \
    centos/ruby-22-centos7 \
    hello-world-app

The above creates a temporary container named
's2i_centos_ruby_22_centos7_397cfecd'.


Fixes #395.

@bparees

bparees commented May 16, 2016

Copy link
Copy Markdown
Contributor

s2i prefix seems reasonable to me.. maybe s2i__randomuid ?

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

s2i prefix seems reasonable to me.. maybe s2i__randomuid ?

I thought maybe we could include the same info that openshift uses (build name, namespace, ...), this would allow for better debugging and perhaps more directed cleanup.

But that would require openshift to pass in that information to s2i.

@bparees

bparees commented May 16, 2016

Copy link
Copy Markdown
Contributor

when running from openshift i agree it would be good to include that info, i thought we were just discussing the non-openshift scenario here.

@bparees

bparees commented Jun 10, 2016

Copy link
Copy Markdown
Contributor

@rhcarvalho any chance of moving forward w/ this? (trying to clear tech debt)

Comment thread pkg/docker/docker.go Outdated
hostConfig := rco.asDockerHostConfig()
return docker.CreateContainerOptions{
Name: "",
Name: containerName("", ""),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

BTW, why we're generating names? Could we specify names explicitly? For example, "Builder container", "Runtime image container" etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We cannot have name collisions. Keep in mind there can be several concurrent builds.

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@rhcarvalho any chance of moving forward w/ this? (trying to clear tech debt)

I scheduled some time towards the end half of this sprint to catch up on old PRs.

@bparees

bparees commented Jun 15, 2016

Copy link
Copy Markdown
Contributor

thanks @rhcarvalho!

On Wed, Jun 15, 2016 at 8:53 AM, Rodolfo Carvalho [email protected]
wrote:

@rhcarvalho https://github.com/rhcarvalho any chance of moving forward
w/ this? (trying to clear tech debt)

I scheduled some time towards the end half of this sprint to catch up on
old PRs.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#496 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AEvl3pxTFqrO7fQL2wlmWi_jk-NrzaSxks5qMCAXgaJpZM4Ie8N3
.

Ben Parees | OpenShift

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

s2i prefix seems reasonable to me.. maybe s2i__randomuid ?

@bparees we cannot use the image spec as is, because it may not always lead to a valid container name. E.g.:

$ docker run --name 's2i_centos:latest_f4f4f4' centos:latest
Error response from daemon: Invalid container name (s2i_centos:latest_f4f4f4), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed

Neither / nor : are allowed, which would naturally appear in the image spec.

Since I like the idea of using the image name, we could replace slashes and colons with underscores, wdyt?

@rhcarvalho
rhcarvalho force-pushed the issue395-consistent-container-names branch from 447773f to ac883cd Compare June 27, 2016 13:51
@rhcarvalho rhcarvalho changed the title [WIP] Name containers created by s2i explicitly Name containers created by s2i explicitly Jun 27, 2016
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

Updated description to reflect the current state.
Ready for review / merge.

[test]

Comment thread pkg/docker/docker.go Outdated

// RunContainerOptions are options passed in to the RunContainer method
type RunContainerOptions struct {
Name string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looked at how we'd leverage this from Origin, doesn't seem useful.

We never set RunContainerOptions directly, instead we call the Save and Execute methods defined in pkg/build/strategies/sti/sti.go, and they call RunContainer with options based on yet another Config struct.

If we don't care to correlate BuildConfigs and S2I containers, then the name generated by containerName should be enough. Otherwise we'd need to make changes to the Config struct. In that case, probably instead of providing a container name we should provide just metadata because S2I might create multiple containers and I guess we don't want to use a single name (for a given build).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i'm fine with not introducing it at this point.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will drop the second commit and we're ready to go then.

@rhcarvalho
rhcarvalho force-pushed the issue395-consistent-container-names branch from ac883cd to d003c98 Compare June 27, 2016 14:16
@bparees

bparees commented Jun 27, 2016

Copy link
Copy Markdown
Contributor

substituting w/ underscores works for me.

Instead of leaving the name blank and letting the Docker daemon name
containers with random strings like 'lonely_thompson', we give proper
names so that we can identify and filter containers created by S2I
later.

Names take a fixed prefix, 's2i_', and a random suffix. The builder
image is also used to compose the container name, replacing with
underscores characters that would be invalid for a container name.

Example:

$ s2i build \
    git://github.com/openshift/ruby-hello-world \
    centos/ruby-22-centos7 \
    hello-world-app

The above creates a temporary container named
's2i_centos_ruby_22_centos7_397cfecd'.
@rhcarvalho
rhcarvalho force-pushed the issue395-consistent-container-names branch from d003c98 to 5ed269f Compare June 27, 2016 14:42
@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for source to image test up to 5ed269f

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@bparees ready to go.

@bparees

bparees commented Jun 27, 2016

Copy link
Copy Markdown
Contributor

lgtm [merge]
thanks @rhcarvalho, great to have this one done :)

@openshift-bot

openshift-bot commented Jun 27, 2016 •

Copy link
Copy Markdown
Contributor

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for source to image merge up to 5ed269f

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

great to have this one done :)

I ❤️ it too, let's kill some more bugs this week.

@openshift-bot

Copy link
Copy Markdown
Contributor

@openshift-bot
openshift-bot merged commit 16d25b0 into openshift:master Jun 27, 2016
@rhcarvalho
rhcarvalho deleted the issue395-consistent-container-names branch June 27, 2016 15:42
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.

Build containers are named randomly by the Docker daemon

4 participants