From 80d1f4e06d83e76c55d4e3d691bc96b68e3a6fa3 Mon Sep 17 00:00:00 2001 From: Andrew Obuchowicz Date: Tue, 4 Oct 2022 18:57:21 -0400 Subject: [PATCH] chore: remove che.workspace.pod.tolerations_json property Signed-off-by: Andrew Obuchowicz --- .../webapp/WEB-INF/classes/che/che.properties | 6 ---- .../provision/TolerationsProvisioner.java | 22 ++---------- .../provision/TolerationsProvisionerTest.java | 36 ++----------------- 3 files changed, 5 insertions(+), 59 deletions(-) diff --git a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties index ee44491eff..75cb8a350e 100644 --- a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties +++ b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties @@ -630,12 +630,6 @@ che.workspace.provision.secret.labels=app.kubernetes.io/part-of=che.eclipse.org, # and supported by the environment. che.workspace.devfile.async.storage.plugin=eclipse/che-async-pv-plugin/latest -# Optionally configures tolerations for workspace pod. The format is a string representing a JSON Array of taint tolerations, -# or `NULL` to disable it. The objects contained in the array have to follow the -# link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#toleration-v1-core[toleration v1 core specifications]. -# For example: `[{"effect":"NoExecute","key":"aNodeTaint","operator":"Equal","value":"aValue"}]` -che.workspace.pod.tolerations_json=NULL - # Bitbucket endpoints used for factory integrations. # A comma separated list of Bitbucket server URLs or `NULL` if no integration is expected. che.integration.bitbucket.server_endpoints=NULL diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/TolerationsProvisioner.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/TolerationsProvisioner.java index fc9b987b45..e12d3a4978 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/TolerationsProvisioner.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/TolerationsProvisioner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2021 Red Hat, Inc. + * Copyright (c) 2012-2022 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ @@ -13,17 +13,12 @@ package org.eclipse.che.workspace.infrastructure.kubernetes.provision; import static java.util.Collections.emptyList; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; import io.fabric8.kubernetes.api.model.PodSpec; import io.fabric8.kubernetes.api.model.Toleration; import java.util.List; import javax.inject.Inject; -import javax.inject.Named; import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; import org.eclipse.che.api.workspace.server.spi.InfrastructureException; -import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.inject.ConfigurationException; import org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment; @@ -33,19 +28,8 @@ public class TolerationsProvisioner implements ConfigurationProvisioner { private final List tolerations; @Inject - public TolerationsProvisioner( - @Nullable @Named("che.workspace.pod.tolerations_json") String tolerationsProperty) - throws ConfigurationException { - try { - ObjectMapper jsonMapper = new ObjectMapper(); - this.tolerations = - tolerationsProperty != null - ? jsonMapper.readValue(tolerationsProperty, new TypeReference>() {}) - : emptyList(); - } catch (JsonProcessingException e) { - throw new ConfigurationException( - "che.workspace.pod.tolerations_json contains an invalid JSON string", e); - } + public TolerationsProvisioner() throws ConfigurationException { + this.tolerations = emptyList(); } @Override diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/TolerationsProvisionerTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/TolerationsProvisionerTest.java index 262a726b26..2c0dcc2443 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/TolerationsProvisionerTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/TolerationsProvisionerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2021 Red Hat, Inc. + * Copyright (c) 2012-2022 Red Hat, Inc. * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ @@ -11,17 +11,12 @@ */ package org.eclipse.che.workspace.infrastructure.kubernetes.provision; -import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -import com.fasterxml.jackson.databind.ObjectMapper; import io.fabric8.kubernetes.api.model.ContainerBuilder; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; -import io.fabric8.kubernetes.api.model.Toleration; -import java.util.Collections; import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity; -import org.eclipse.che.inject.ConfigurationException; import org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; @@ -42,34 +37,13 @@ public class TolerationsProvisionerTest { k8sEnv = KubernetesEnvironment.builder().build(); } - @Test - public void shouldAddTolerationsIntoAllPods() throws Exception { - // given - k8sEnv.addPod(createPod("pod")); - k8sEnv.addPod(createPod("pod2")); - Toleration expectedToleration = - new Toleration("NoExecute", "a.node.taint", "Equal", 0L, "aValue"); - ObjectMapper objMapper = new ObjectMapper(); - String json = objMapper.writeValueAsString(Collections.singletonList(expectedToleration)); - provisioner = new TolerationsProvisioner(json); - - // when - provisioner.provision(k8sEnv, runtimeId); - - // then - for (Pod pod : k8sEnv.getPodsCopy().values()) { - assertEquals(pod.getSpec().getTolerations().size(), 1); - assertEquals(pod.getSpec().getTolerations().get(0), expectedToleration); - } - } - @Test public void shouldOmitEmptyTolerations() throws Exception { // given k8sEnv.addPod(createPod("pod")); k8sEnv.addPod(createPod("pod2")); - provisioner = new TolerationsProvisioner(null); + provisioner = new TolerationsProvisioner(); // when provisioner.provision(k8sEnv, runtimeId); @@ -80,12 +54,6 @@ public class TolerationsProvisionerTest { } } - @Test(expectedExceptions = ConfigurationException.class) - public void shouldFailOnInvalidTolerationsJson() throws Exception { - // given - provisioner = new TolerationsProvisioner("an invalid json string"); - } - private Pod createPod(String podName) { return new PodBuilder() .withNewMetadata()