chore: remove che.workspace.pod.tolerations_json property
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>pull/378/head
parent
5283270814
commit
80d1f4e06d
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<Toleration> 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<List<Toleration>>() {})
|
||||
: 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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue