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

Fix bug where broker container name can exceed 63 characters #14964

Merged
merged 4 commits into from
Oct 28, 2019

Conversation

amisevsk
Copy link
Contributor

What does this PR do?

Strips docker registry hostname when creating a container name for plugin brokers.

The container name for the plugin broker is derived from its docker image reference. When this reference contains a registry, it's possible for this name to exceed the 63-character limit imposed by Kubernetes,
e.g.

  my-internal-registry/my-organization/che-unified-plugin-broker:v0.20

results in a broker container named

  my-internal-registry-my-organization-che-unified-plugin-broker-v0-20

What issues does this PR fix or reference?

#14958

@amisevsk
Copy link
Contributor Author

@tomgeorge Could you check that this fixes the issue?

@che-bot che-bot added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/bug Outline of a bug - must adhere to the bug report template. labels Oct 23, 2019
@amisevsk
Copy link
Contributor Author

Note that even with this commit, it's possible to encounter #14958 if the organization publishing the broker image has a name that exceeds 30 characters.

@che-bot
Copy link
Contributor

che-bot commented Oct 23, 2019

E2E Happy path tests of Eclipse Che Single User on K8S (minikube v1.1.1) has failed:

@che-bot
Copy link
Contributor

che-bot commented Oct 23, 2019

E2E tests of Eclipse Che Multiuser on OCP has been successful:

@amisevsk
Copy link
Contributor Author

ci-build

Comment on lines 167 to 172
Matcher matcher = IMAGE_PATTERN.matcher(image);
String containerName;
if (matcher.matches()) {
containerName = String.format("%s/%s", matcher.group("org"), matcher.group("image"));
} else {
containerName = image;
Copy link
Member

Choose a reason for hiding this comment

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

will it be possible to extract this into method and cover with unit test + doc (the logic is not transparent IMO)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've extracted the method (and simplified it to strip everything but image name) and added tests.

@tomgeorge
Copy link
Contributor

containers will start with this fix

Copy link
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

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

LGTM
Please consider addressing Illya's comment

@l0rd l0rd mentioned this pull request Oct 24, 2019
30 tasks
The container name for the plugin broker is derived from its docker
image reference. When this reference contains a registry, it's possible
for this name to exceed the 63-character limit imposed by Kubernetes,
e.g.

  my-internal-registry/my-organization/che-unified-plugin-broker:v0.20

results in a broker container named

  my-internal-registry-my-organization-che-unified-plugin-broker-v0-20

This commit removes the registry hostname from the container name and
keeps the conversion the same.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Signed-off-by: Angel Misevski <amisevsk@redhat.com>
@amisevsk
Copy link
Contributor Author

@sleshchenko Ilya and I discussed in standup that it's probably safer to just remove everything but image name (since a long organization name could still cause the issue) -- could you reapprove the new logic?

@che-bot
Copy link
Contributor

che-bot commented Oct 24, 2019

E2E Happy path tests of Eclipse Che Single User on K8S (minikube v1.1.1) has been successful:

Copy link
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

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

still LGTM

@che-bot
Copy link
Contributor

che-bot commented Oct 24, 2019

E2E tests of Eclipse Che Multiuser on OCP has been successful:

Comment on lines 166 to 167
// There's a chance the full image reference may be over the name limit of 63 chars
// so we need to remove registry hostname
Copy link
Member

Choose a reason for hiding this comment

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

@amisevsk this comment looks obsolete

Copy link
Member

Choose a reason for hiding this comment

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

or maybe it meant to be added to the generateContainerNameFromImageRef doc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved docs to generateContainerNameFromImageRef

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Copy link
Member

@ibuziuk ibuziuk left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@che-bot
Copy link
Contributor

che-bot commented Oct 24, 2019

E2E tests of Eclipse Che Multiuser on OCP has failed:

@che-bot
Copy link
Contributor

che-bot commented Oct 24, 2019

E2E Happy path tests of Eclipse Che Single User on K8S (minikube v1.1.1) has been successful:

@amisevsk
Copy link
Contributor Author

ci-test

@amisevsk
Copy link
Contributor Author

ci-build

@che-bot
Copy link
Contributor

che-bot commented Oct 24, 2019

E2E tests of Eclipse Che Multiuser on OCP has failed:

@ibuziuk
Copy link
Member

ibuziuk commented Oct 25, 2019

ci-build

@ibuziuk
Copy link
Member

ibuziuk commented Oct 25, 2019

12:54:23 [ERROR] Failed to execute goal com.coveo:fmt-maven-plugin:2.5.1:check (default) on project infrastructure-kubernetes: Found 1 non-complying files, failing build -> [Help 1]
12:54:23 [ERROR] 
12:54:23 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
12:54:23 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
12:54:23 [ERROR] 
12:54:23 [ERROR] For more information about the errors and possible solutions, please read the following articles:
12:54:23 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
12:54:23 [ERROR] 
12:54:23 [ERROR] After correcting the problems, you can resume the build with the command
12:54:23 [ERROR]   mvn <goals> -rf :infrastructure-kubernetes

@amisevsk looks like formatting needs to be fixed ;)

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
@che-bot
Copy link
Contributor

che-bot commented Oct 25, 2019

E2E Happy path tests of Eclipse Che Single User on K8S (minikube v1.1.1) has been successful:

{"very-long-registry-hostname-url.service/eclipse/image:tag", "image-tag"},
{"eclipse/che-unified-plugin-broker:v0.20", "che-unified-plugin-broker-v0-20"},
{"very-long-organization.name-eclipse-che/image:tag", "image-tag"},
{"very-long-registry-hostname-url.service/very-long-organization/image:tag", "image-tag"}
Copy link
Contributor

Choose a reason for hiding this comment

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

different images from different registries or users will have same name

It looks odd when you debug if there is no easy way to know from where it could come

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You could always get the full image ref from the pod or env var though. There's no way to include registry and organization in the name, since it very easily goes over the 63 char limit (the length of just the broker pod name + version is 32 chars already).

Copy link
Contributor

Choose a reason for hiding this comment

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

I never talked on including the full registry or org name
but I think it's like some logger are doing for packages
instead of seeing org.apache.catalina.something you see o.a.c.something

In logger of Tomcat I see for example o.a.c.startup.VersionLoggerListener
so I know more from where is coming the VersionLoggerListener class than if only VersionLoggerListener was displayed

So I would say you could do something similar, it's for UX.

and of course I could go to openshift webconsole or somewhere else but it's definitely not UX

Copy link
Contributor

Choose a reason for hiding this comment

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

quay.io/my-organization/che-unified-plugin-broker:v0.20 --> q-m-che-unified-plugin-broker-v0-20

docker.io/my-organization/che-unified-plugin-broker:v0.20 --> d-m-che-unified-plugin-broker-v0-20

docker.io/other-organization/che-unified-plugin-broker:v0.20 --> d-o-che-unified-plugin-broker-v0-20

Copy link
Member

Choose a reason for hiding this comment

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

@benoitf this sounds like a relevant improvement, but is it really that valuable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think q-m-che-unified-broker-image-v0-20 and d-m-che-unified-plugin-broker-v0-20 are less readable than che-unified-plugin-broker-v0-20. Even with the truncation, it's an external reference (whereas logger trimming is referring to internal classes), so you'll still have to ask "what image is this/where is it hosted/what is it built from?" A single m character doesn't tell us anything real about the actual organization it's pushed to. I care more about what job the broker has (init vs unified), and what version it comes from (since e.g. v0.19 brokers don't support offline).

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems i'm the only one to care UX or that it's just a hot fix of removing repo/org and not fixing the 63 limit

If we know that we can't reach more than 63 values should never return more than 63 characters

@amisevk. You may use other prefix it was an example to illustrate that you may care repo/org more than full image name as well

I won't block but to me it's not a fix of the issue. Just hot fix

Copy link
Contributor

Choose a reason for hiding this comment

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

Also speaking about UX I think issue is that we're giving each image name independently and not a set of images so the logic can work only on a limited data while with all images it could dedup in a better format all images

@che-bot
Copy link
Contributor

che-bot commented Oct 25, 2019

E2E tests of Eclipse Che Multiuser on OCP has been successful:

@ibuziuk
Copy link
Member

ibuziuk commented Oct 25, 2019

@dmytro-ndp @vkuznyetsov @rhopp please provide QA approval

Copy link
Contributor

@dmytro-ndp dmytro-ndp left a comment

Choose a reason for hiding this comment

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

E2E Java selenium tests against OCP and Happy path tests against kubernetes have passed.

@benoitf
Copy link
Contributor

benoitf commented Oct 25, 2019

What happens for my image like:

https://hub.docker.com/r/florentbenoit/thisisaverylongcontainernamewithanimageitrytomakeimagenamelongerthan63characters/tags

$ docker pull florentbenoit/thisisaverylongcontainernamewithanimageitrytomakeimagenamelongerthan63characters:thisisaverylongtagwithanimageitrytomakeimagenamelongerthan63characters

(if this image is a broker)

@ibuziuk
Copy link
Member

ibuziuk commented Oct 25, 2019

@benoitf isn't it an edge case?

@benoitf
Copy link
Contributor

benoitf commented Oct 25, 2019

I don't know, issue is about 63characters limit but PR is just a workaround by stripping org/repo

@ibuziuk
Copy link
Member

ibuziuk commented Oct 25, 2019

issue is about 63characters limit but PR is just a workaround by stripping org/repo

well, dropping the org,repo makes the possibility of hitting 63 chars limit utterly unlike. unless you use smth like #14964 (comment)
Do you insist on PR rework or is it good enough for 7.3.1 ?

@ibuziuk
Copy link
Member

ibuziuk commented Oct 28, 2019

Merging to master. @benoitf @amisevsk we can create a separate issue for improving the generateContainerNameFromImageRef method

@ibuziuk ibuziuk merged commit 75b95d5 into eclipse-che:master Oct 28, 2019
@che-bot che-bot removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Oct 28, 2019
@che-bot che-bot added this to the 7.4.0 milestone Oct 28, 2019
@ibuziuk
Copy link
Member

ibuziuk commented Oct 28, 2019

@amisevsk could you please backport it to 7.3.x ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Outline of a bug - must adhere to the bug report template.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants