From 406ec9289d100ad272643eecdb8ad8698e719934 Mon Sep 17 00:00:00 2001 From: Ryan Eberhard Date: Wed, 13 Sep 2023 16:32:18 -0400 Subject: [PATCH] Resolve issue 4368 by only applying volume mount overlap validation to initialize domain on PV use case --- .../weblogic/domain/model/DomainResource.java | 6 +++--- .../weblogic/domain/model/Validator.java | 15 +++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/operator/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainResource.java b/operator/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainResource.java index 01ac70c8156..de113f8dd03 100644 --- a/operator/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainResource.java +++ b/operator/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainResource.java @@ -1186,11 +1186,11 @@ private String getClusterLegalName(ClusterResource cluster) { } private void addInvalidMountPathsManagedServers() { - spec.getAdditionalVolumeMounts().forEach(mount -> checkValidMountPath(mount, getEnvNames(), + spec.getAdditionalVolumeMounts().forEach(mount -> checkValidMountPath(spec, mount, getEnvNames(), getRemainingVolumeMounts(spec.getAdditionalVolumeMounts(), mount))); if (getSpec().getAdminServer() != null) { getSpec().getAdminServer().getAdditionalVolumeMounts() - .forEach(mount -> checkValidMountPath(mount, getEnvNames(), + .forEach(mount -> checkValidMountPath(spec, mount, getEnvNames(), getRemainingVolumeMounts(getSpec().getAdminServer().getAdditionalVolumeMounts(), mount))); } } @@ -1208,7 +1208,7 @@ private void addInvalidMountPathsForPodSpec(V1PodSpec podSpec) { .forEach(container -> Optional.ofNullable(container.getVolumeMounts()) .ifPresent(volumes -> volumes.forEach(mount -> - checkValidMountPath(mount, getEnvNames(), getRemainingVolumeMounts(volumes, mount))))); + checkValidMountPath(spec, mount, getEnvNames(), getRemainingVolumeMounts(volumes, mount))))); } private void whenAuxiliaryImagesDefinedVerifyMountPathNotInUseManagedServers() { diff --git a/operator/src/main/java/oracle/kubernetes/weblogic/domain/model/Validator.java b/operator/src/main/java/oracle/kubernetes/weblogic/domain/model/Validator.java index 0591434766b..27d0ac90d37 100644 --- a/operator/src/main/java/oracle/kubernetes/weblogic/domain/model/Validator.java +++ b/operator/src/main/java/oracle/kubernetes/weblogic/domain/model/Validator.java @@ -44,7 +44,7 @@ void addClusterInvalidMountPaths(ClusterResource cluster) { ClusterSpec spec = cluster.getSpec(); Optional.of(spec).map(ClusterSpec::getAdditionalVolumeMounts) .ifPresent(mounts -> mounts.forEach(mount -> - checkValidMountPath(mount, getEnvNames(spec), getRemainingVolumeMounts(mounts, mount)))); + checkValidMountPath(null, mount, getEnvNames(spec), getRemainingVolumeMounts(mounts, mount)))); } List getRemainingVolumeMounts(List list, V1VolumeMount mount) { @@ -63,7 +63,8 @@ Set getEnvNames(ClusterSpec spec) { .collect(toSet()); } - void checkValidMountPath(V1VolumeMount mount, Set envNames, List mounts) { + void checkValidMountPath(DomainSpec spec, V1VolumeMount mount, Set envNames, + List mounts) { if (skipValidation(mount.getMountPath(), envNames)) { return; } @@ -72,10 +73,16 @@ void checkValidMountPath(V1VolumeMount mount, Set envNames, List checkOverlappingMountPaths(mount, m)); + mounts.stream().forEach(m -> checkOverlappingMountPaths(spec, mount, m)); } - private void checkOverlappingMountPaths(V1VolumeMount mount1, V1VolumeMount mount2) { + private void checkOverlappingMountPaths(DomainSpec spec, V1VolumeMount mount1, V1VolumeMount mount2) { + // This validation only applies to the initialize domain on PV use case + if (Optional.ofNullable(spec).map(DomainSpec::getConfiguration) + .map(Configuration::getInitializeDomainOnPV).isEmpty()) { + return; + } + List list1 = getTokensWithCollection(mount1.getMountPath()); List list2 = getTokensWithCollection(mount2.getMountPath()); for (int i = 0; i < Math.min(list1.size(), list2.size()); i++) {