You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by sa...@apache.org on 2022/05/01 02:13:38 UTC
[incubator-heron] branch saadurrahman/3821-Remove-Deprecated-Volumes-K8s-dev updated: [K8s] removed config volume de-duplicator.
This is an automated email from the ASF dual-hosted git repository.
saadurrahman pushed a commit to branch saadurrahman/3821-Remove-Deprecated-Volumes-K8s-dev
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git
The following commit(s) were added to refs/heads/saadurrahman/3821-Remove-Deprecated-Volumes-K8s-dev by this push:
new 8d701c5119e [K8s] removed config volume de-duplicator.
8d701c5119e is described below
commit 8d701c5119e7ea34804809f30597d1f152243ac7
Author: Saad Ur Rahman <sa...@apache.org>
AuthorDate: Sat Apr 30 22:13:26 2022 -0400
[K8s] removed config volume de-duplicator.
Volumes are no longer loaded from Configs. As such there is no longer a need to de-duplicate against volumes loaded from Pod Templates and the CLI.
---
.../heron/scheduler/kubernetes/V1Controller.java | 24 --------
.../scheduler/kubernetes/V1ControllerTest.java | 65 ----------------------
2 files changed, 89 deletions(-)
diff --git a/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/V1Controller.java b/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/V1Controller.java
index be6e48ebe4f..cfe4a9d923e 100644
--- a/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/V1Controller.java
+++ b/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/V1Controller.java
@@ -656,8 +656,6 @@ public class V1Controller extends KubernetesController {
podSpec.setContainers(containers);
- addVolumesIfPresent(podSpec);
-
mountSecretsAsVolumes(podSpec);
}
@@ -695,28 +693,6 @@ public class V1Controller extends KubernetesController {
return tolerations;
}
- /**
- * Adds volume to the <code>Pod Spec</code> that Heron requires. Heron's values taking precedence.
- * @param spec <code>Pod Spec</code> to be configured.
- */
- @VisibleForTesting
- protected void addVolumesIfPresent(final V1PodSpec spec) {
- final Config config = getConfiguration();
- if (KubernetesContext.hasVolume(config)) {
- final V1Volume volumeFromConfig = Volumes.get().create(config);
- if (volumeFromConfig != null) {
- // Merge volumes. Deduplicate using volume's name with Heron defaults taking precedence.
- KubernetesUtils.V1ControllerUtils<V1Volume> utils =
- new KubernetesUtils.V1ControllerUtils<>();
- spec.setVolumes(
- utils.mergeListsDedupe(Collections.singletonList(volumeFromConfig), spec.getVolumes(),
- Comparator.comparing(V1Volume::getName), "Pod Template Volumes")
- );
- LOG.fine("Adding volume: " + volumeFromConfig);
- }
- }
- }
-
/**
* Adds <code>Volume Mounts</code> for <code>Secrets</code> to a pod.
* @param podSpec <code>Pod Spec</code> to add secrets to.
diff --git a/heron/schedulers/tests/java/org/apache/heron/scheduler/kubernetes/V1ControllerTest.java b/heron/schedulers/tests/java/org/apache/heron/scheduler/kubernetes/V1ControllerTest.java
index 162b4017896..e9fd8673153 100644
--- a/heron/schedulers/tests/java/org/apache/heron/scheduler/kubernetes/V1ControllerTest.java
+++ b/heron/schedulers/tests/java/org/apache/heron/scheduler/kubernetes/V1ControllerTest.java
@@ -678,71 +678,6 @@ public class V1ControllerTest {
Assert.assertEquals("Container Resources are set from CLI.", expected, actual);
}
- @Test
- public void testAddVolumesIfPresent() {
- final String pathDefault = "config-host-volume-path";
- final String pathNameDefault = "config-host-volume-name";
- final Config configWithVolumes = Config.newBuilder()
- .put(KubernetesContext.KUBERNETES_VOLUME_NAME, pathNameDefault)
- .put(KubernetesContext.KUBERNETES_VOLUME_TYPE, Volumes.HOST_PATH)
- .put(KubernetesContext.KUBERNETES_VOLUME_HOSTPATH_PATH, pathDefault)
- .build();
- final V1Controller controllerWithVol = new V1Controller(configWithVolumes, RUNTIME);
-
- final V1Volume volumeDefault = new V1VolumeBuilder()
- .withName(pathNameDefault)
- .withNewHostPath()
- .withNewPath(pathDefault)
- .endHostPath()
- .build();
- final V1Volume volumeToBeKept = new V1VolumeBuilder()
- .withName("volume-to-be-kept-name")
- .withNewHostPath()
- .withNewPath("volume-to-be-kept-path")
- .endHostPath()
- .build();
-
- final List<V1Volume> customVolumeList = Arrays.asList(
- new V1VolumeBuilder()
- .withName(pathNameDefault)
- .withNewHostPath()
- .withNewPath("this-path-must-be-replaced")
- .endHostPath()
- .build(),
- volumeToBeKept
- );
- final List<V1Volume> expectedDefault = Collections.singletonList(volumeDefault);
- final List<V1Volume> expectedCustom = Arrays.asList(volumeDefault, volumeToBeKept);
-
- // No Volumes set.
- V1Controller controllerDoNotSetVolumes = new V1Controller(Config.newBuilder().build(), RUNTIME);
- V1PodSpec podSpecNoSetVolumes = new V1PodSpec();
- controllerDoNotSetVolumes.addVolumesIfPresent(podSpecNoSetVolumes);
- Assert.assertNull(podSpecNoSetVolumes.getVolumes());
-
- // Default. Null Volumes.
- V1PodSpec podSpecNull = new V1PodSpecBuilder().build();
- controllerWithVol.addVolumesIfPresent(podSpecNull);
- Assert.assertTrue("Default VOLUMES should be set in container with null VOLUMES",
- CollectionUtils.containsAll(expectedDefault, podSpecNull.getVolumes()));
-
- // Empty Volumes list
- V1PodSpec podSpecEmpty = new V1PodSpecBuilder()
- .withVolumes(new LinkedList<>())
- .build();
- controllerWithVol.addVolumesIfPresent(podSpecEmpty);
- Assert.assertTrue("Default VOLUMES should be set in container with empty VOLUMES",
- CollectionUtils.containsAll(expectedDefault, podSpecEmpty.getVolumes()));
-
- // Custom Volumes list
- V1PodSpec podSpecCustom = new V1PodSpecBuilder()
- .withVolumes(customVolumeList)
- .build();
- controllerWithVol.addVolumesIfPresent(podSpecCustom);
- Assert.assertTrue("Default VOLUMES should be set in container with custom VOLUMES",
- CollectionUtils.containsAll(expectedCustom, podSpecCustom.getVolumes()));
- }
-
@Test
public void testMountVolumeIfPresent() {
final String pathDefault = "config-host-volume-path";