private void discoverFolderMounts() { List<VolumeMount> volumeMounts = zaleniumPod.getSpec().getContainers().get(0).getVolumeMounts(); List<VolumeMount> validMounts = new ArrayList<>(); volumeMounts.stream() .filter(volumeMount -> !Arrays.asList(PROTECTED_NODE_MOUNT_POINTS).contains(volumeMount.getMountPath())) .forEach(validMounts::add); // Look through the volume mounts to see if the shared folder is mounted if (!validMounts.isEmpty()) { List<Volume> volumes = zaleniumPod.getSpec().getVolumes(); for (VolumeMount validMount : validMounts) { volumes.stream() .filter(volume -> validMount.getName().equalsIgnoreCase(volume.getName())) .findFirst() .ifPresent(volume -> mountedSharedFoldersMap.put(validMount, volume)); } } }
public static boolean volumeMountExists(String path, Iterable<VolumeMount> existingMounts) { for (VolumeMount mount : existingMounts) { if (mount.getMountPath().equals(path)) { return true; } } return false; } }
private String getMountPath(List<Container> containers, String name){ for (Container container : containers) { List<VolumeMount> volumeMounts = container.getVolumeMounts(); if (volumeMounts != null) { for (VolumeMount volumeMount : volumeMounts) { if (name.equals(volumeMount.getName())){ return volumeMount.getMountPath(); } } } } throw new IllegalArgumentException("No matching volume mount found for volume "+ name); }
private String getMountPath(List<Container> containers, String name){ for (Container container : containers) { List<VolumeMount> volumeMounts = container.getVolumeMounts(); if (volumeMounts != null) { for (VolumeMount volumeMount : volumeMounts) { if (name.equals(volumeMount.getName())){ return volumeMount.getMountPath(); } } } } throw new IllegalArgumentException("No matching volume mount found for volume "+ name); }
private void revertVolumeChanges(StatefulSet current, StatefulSet desired) { Container currentKafka = current.getSpec().getTemplate().getSpec().getContainers().stream().filter(c -> c.getName().equals("kafka")).findFirst().get(); Container desiredKafka = desired.getSpec().getTemplate().getSpec().getContainers().stream().filter(c -> c.getName().equals("kafka")).findFirst().get(); desiredKafka.setVolumeMounts(currentKafka.getVolumeMounts()); StatefulSet updated = new StatefulSetBuilder(desired) .editSpec() .editTemplate() .editSpec() .editFirstContainer() .editMatchingEnv(e -> e.getName().equals(KafkaCluster.ENV_VAR_KAFKA_LOG_DIRS)) .withValue(desiredKafka.getVolumeMounts().stream() .filter(vm -> vm.getMountPath().contains(AbstractModel.VOLUME_NAME)) .map(vm -> vm.getMountPath()) .collect(Collectors.joining(","))) .endEnv() .endContainer() .endSpec() .endTemplate() .endSpec() .build(); desired.setSpec(updated.getSpec()); }
public VolumeMountBuilder( VolumeMountFluent<?> fluent , VolumeMount instance ){ this.fluent = fluent; fluent.withMountPath(instance.getMountPath()); fluent.withName(instance.getName()); fluent.withReadOnly(instance.getReadOnly()); } public VolumeMountBuilder( VolumeMount instance ){
public VolumeMountBuilder( VolumeMountFluent<?> fluent , VolumeMount instance ){ this.fluent = fluent; fluent.withMountPath(instance.getMountPath()); fluent.withName(instance.getName()); fluent.withReadOnly(instance.getReadOnly()); } public VolumeMountBuilder( VolumeMount instance ){
public VolumeMountBuilder( VolumeMount instance ){ this.fluent = this; this.withMountPath(instance.getMountPath()); this.withName(instance.getName()); this.withReadOnly(instance.getReadOnly()); }
public VolumeMountBuilder( VolumeMount instance ){ this.fluent = this; this.withMountPath(instance.getMountPath()); this.withName(instance.getName()); this.withReadOnly(instance.getReadOnly()); }
.map(volumeMount -> volumeMount.getMountPath()).collect(Collectors.joining(",")); varList.add(buildEnvVar(ENV_VAR_KAFKA_LOG_DIRS, logDirs));
public VolumeMountBuilder(VolumeMount instance,Boolean validationEnabled){ this.fluent = this; this.withMountPath(instance.getMountPath()); this.withName(instance.getName()); this.withReadOnly(instance.getReadOnly()); this.withSubPath(instance.getSubPath()); this.validationEnabled = validationEnabled; }
public VolumeMountFluentImpl(VolumeMount instance){ this.withMountPath(instance.getMountPath()); this.withName(instance.getName()); this.withReadOnly(instance.getReadOnly()); this.withSubPath(instance.getSubPath()); }
public VolumeMountBuilder(VolumeMountFluent<?> fluent,VolumeMount instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withMountPath(instance.getMountPath()); fluent.withName(instance.getName()); fluent.withReadOnly(instance.getReadOnly()); fluent.withSubPath(instance.getSubPath()); this.validationEnabled = validationEnabled; } public VolumeMountBuilder(VolumeMount instance){
.noneMatch(vm -> vm.getMountPath().equals( c.getWorkingDir() != null ? c.getWorkingDir() : ContainerTemplate.DEFAULT_WORKING_DIR))) .forEach(c -> c.getVolumeMounts().add(getDefaultVolumeMount(c.getWorkingDir())));
template.getVolumeMounts().stream().forEach(vm -> volumeMounts.put(vm.getMountPath(), vm));
mainContainerBuilder.addToVolumeMounts(saMount); mainContainerBuilder.addToEnv(envVar(STYX_WORKFLOW_SA_ENV_VARIABLE, saMount.getMountPath() + STYX_WORKFLOW_SA_JSON_KEY)); });