Skip to content

Fix unrecoverable events functionality after move to deployments#10709

Merged
amisevsk merged 1 commit intoeclipse-che:masterfrom
amisevsk:issue-10559
Aug 20, 2018
Merged

Fix unrecoverable events functionality after move to deployments#10709
amisevsk merged 1 commit intoeclipse-che:masterfrom
amisevsk:issue-10559

Conversation

@amisevsk
Copy link
Copy Markdown
Contributor

@amisevsk amisevsk commented Aug 9, 2018

What does this PR do?

Fix unrecoverable events functionality, which was broken by the Deployments change.

Since workspace pods are created by deployments, their names are no longer predictable and it is no longer possible to match them directly to internal representations. Currently this PR matches events to machines by checking for name prefixes, as pods generated by deployments share the deployment's name, plus a random suffix. It's not the most elegant solution but seems to be the best option at this time.

What issues does this PR fix or reference?

#10559

Docs PR

N/A (bugfix)

@amisevsk amisevsk added kind/bug Outline of a bug - must adhere to the bug report template. status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. labels Aug 9, 2018
@amisevsk amisevsk requested review from ibuziuk and sleshchenko August 9, 2018 06:28
@amisevsk amisevsk requested a review from garagatyi as a code owner August 9, 2018 06:28
@riuvshin
Copy link
Copy Markdown
Contributor

riuvshin commented Aug 9, 2018

Can one of the admins verify this patch?

machines.getMachines(getContext().getIdentity()).entrySet()) {
final KubernetesMachineImpl machine = entry.getValue();
if (machine.getPodName().equals(podName)) {
if (!Strings.isNullOrEmpty(podName) && podName.startsWith(machine.getPodName())) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it is redundant change. As far as I see machine contains the actual name of the deployed pod (with suffix) but not configured one https://github.com/eclipse/che/blob/07263f1e30089689d71b057f747a44a29283e3c4/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInternalRuntime.java#L524

Please check it

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.

You're right, I added the getName() line later and forgot to fix. I'll update the PR.

machines.getMachines(getContext().getIdentity()).entrySet()) {
final KubernetesMachineImpl machine = entry.getValue();
if (machine.getPodName().equals(podName)) {
if (podName.startsWith(machine.getPodName())) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here #10709 (comment)
I mean that using equals should be fine here. Correct me if I'm wrong.
Sorry, if it was not clear at the beginning.

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.

Ah, sorry I misunderstood. I'm not sure equals is sufficient here -- in KubernetesDeployments, podName is set to the involved object's metadata.name. For workspace pods, this will be machine.getPodName() plus a suffix added by the replica set.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

podName is set to the involved object's metadata.name

It's true

For workspace pods, this will be machine.getPodName() plus a suffix added by the replica set.

I guess machine.getPodName() will return the value with suffix but not configured one. I think so because be create a machine with podName that is fetched from a deployed pod.
Here is a place where we fetch deployed pod
https://github.com/eclipse/che/blob/07263f1e30089689d71b057f747a44a29283e3c4/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInternalRuntime.java#L513
And here we use its name
https://github.com/eclipse/che/blob/07263f1e30089689d71b057f747a44a29283e3c4/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/KubernetesInternalRuntime.java#L524

Correct me If I am wrong and deployed pod has a name without a suffix added by the replica set.

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.

Ah I see what you mean now -- you're right. I've reverted to using equals here.

Copy link
Copy Markdown
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 👍

return workspacePods
.keySet()
.stream()
.anyMatch(workspacePodName -> podName.startsWith(workspacePodName));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add a small comment why startsWith method should be used here.

@skabashnyuk
Copy link
Copy Markdown
Contributor

ci-test

@riuvshin
Copy link
Copy Markdown
Contributor

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:10709
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@riuvshin
Copy link
Copy Markdown
Contributor

ci-test

@riuvshin
Copy link
Copy Markdown
Contributor

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:10709
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

Since workspace pods on Openshift/Kubernetes are created by deployments
now, they do not have predictable names, and code that relies on this
does not work anymore.

Updates pod events functionality to account for this change, allowing
unrecoverable events to be handled correctly.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
@amisevsk amisevsk merged commit a0c19a8 into eclipse-che:master Aug 20, 2018
@benoitf benoitf added this to the 6.10.0 milestone Aug 20, 2018
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Aug 20, 2018
@amisevsk amisevsk deleted the issue-10559 branch August 20, 2018 03:13
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.

6 participants