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 exception if no data in certs config map #18519

Merged
merged 1 commit into from
Dec 3, 2020
Merged

Conversation

mmorhun
Copy link
Contributor

@mmorhun mmorhun commented Dec 3, 2020

What does this PR do?

Provides fix for inability to start second workspace for the user

Screenshot/screencast of this PR

N/A

What issues does this PR fix or reference?

Failure to start second workspace for the user cause by exception:

2020-12-03 07:46:49,827[aceSharedPool-1]  [WARN ] [.i.k.KubernetesInternalRuntime 257]  - Failed to start Kubernetes runtime of workspace workspacem1wn6pmb06ltlsrn.
java.lang.NullPointerException: null
	at org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesTrustedCAProvisioner.provision(KubernetesTrustedCAProvisioner.java:117)
	at org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesEnvironmentProvisioner$KubernetesEnvironmentProvisionerImpl.provision(KubernetesEnvironmentProvisioner.java:185)
	at org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.PluginBrokerManager.getTooling(PluginBrokerManager.java:118)
	at org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.SidecarToolingProvisioner.provision(SidecarToolingProvisioner.java:90)
	at org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesInternalRuntime.provisionWorkspace(KubernetesInternalRuntime.java:288)
	at org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesInternalRuntime.internalStart(KubernetesInternalRuntime.java:204)
	at org.eclipse.che.api.workspace.server.spi.InternalRuntime.start(InternalRuntime.java:141)
	at org.eclipse.che.api.workspace.server.WorkspaceRuntimes$StartRuntimeTask.run(WorkspaceRuntimes.java:969)
	at org.eclipse.che.commons.lang.concurrent.CopyThreadLocalRunnable.run(CopyThreadLocalRunnable.java:38)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source)
	at io.micrometer.core.instrument.internal.TimedRunnable.run(TimedRunnable.java:44)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.eclipse.che.commons.observability.CountedThreadFactory.lambda$newThread$0(CountedThreadFactory.java:75)
	at java.base/java.lang.Thread.run(Unknown Source)
2020-12-03 07:46:49,903[aceSharedPool-1]  [INFO ] [o.e.c.a.w.s.WorkspaceRuntimes 995]   - Workspace 'admin:golang-omt8y' with id 'workspacem1wn6pmb06ltlsrn' start failed
2020-12-03 07:46:49,903[aceSharedPool-1]  [ERROR] [o.e.c.a.w.s.WorkspaceRuntimes 1005]  - An exception occurred.
org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException: An exception occurred.
	at org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesInternalRuntime.wrapAndRethrow(KubernetesInternalRuntime.java:966)
	at org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesInternalRuntime.internalStart(KubernetesInternalRuntime.java:277)
	at org.eclipse.che.api.workspace.server.spi.InternalRuntime.start(InternalRuntime.java:141)
	at org.eclipse.che.api.workspace.server.WorkspaceRuntimes$StartRuntimeTask.run(WorkspaceRuntimes.java:969)
	at org.eclipse.che.commons.lang.concurrent.CopyThreadLocalRunnable.run(CopyThreadLocalRunnable.java:38)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source)
	at io.micrometer.core.instrument.internal.TimedRunnable.run(TimedRunnable.java:44)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.eclipse.che.commons.observability.CountedThreadFactory.lambda$newThread$0(CountedThreadFactory.java:75)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: null
	at org.eclipse.che.workspace.infrastructure.kubernetes.provision.KubernetesTrustedCAProvisioner.provision(KubernetesTrustedCAProvisioner.java:117)
	at org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesEnvironmentProvisioner$KubernetesEnvironmentProvisionerImpl.provision(KubernetesEnvironmentProvisioner.java:185)
	at org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.PluginBrokerManager.getTooling(PluginBrokerManager.java:118)
	at org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.SidecarToolingProvisioner.provision(SidecarToolingProvisioner.java:90)
	at org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesInternalRuntime.provisionWorkspace(KubernetesInternalRuntime.java:288)
	at org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesInternalRuntime.internalStart(KubernetesInternalRuntime.java:204)
	... 9 common frames omitted

How to test this PR?

Start two workspaces simultaniously

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
@mmorhun mmorhun self-assigned this Dec 3, 2020
@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 Dec 3, 2020
@che-bot
Copy link
Contributor

che-bot commented Dec 3, 2020

✅ E2E Happy path tests succeed 🎉

See Details

Tested with Eclipse Che Multiuser User on K8S (minikube v1.1.1)

  • Use comment "[crw-ci-test]" to rerun happy path E2E test.
  • Use comment "[crw-ci-test --rebuild]" to re-build the images and rerun happy path E2E test.

@@ -114,7 +114,9 @@ public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity runtimeID)

KubernetesNamespace namespace = namespaceFactory.getOrCreate(runtimeID);
Optional<ConfigMap> existing = namespace.configMaps().get(configMapName);
if (existing.isEmpty() || !existing.get().getData().equals(allCaCertsConfigMap.getData())) {
if (existing.isEmpty()
|| !(existing.get().getData() == allCaCertsConfigMap.getData()
Copy link
Member

Choose a reason for hiding this comment

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

A || !(B || C) is hard to read and understand.
The following can be a bit easier if A || !B && !C!
If empty OR not the same (not equals in pointers terms && does not have the same values)

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Conditions B and C are logically related so, to my mind, it is clearer to leave that as is.

@mmorhun mmorhun merged commit 2864592 into master Dec 3, 2020
@mmorhun mmorhun deleted the che-17634-fix1 branch December 3, 2020 10:17
@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 Dec 3, 2020
@tolusha tolusha mentioned this pull request Dec 3, 2020
58 tasks
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.

4 participants