Skip to content

Commit

Permalink
Merge branch 'issue-4368' into 'main'
Browse files Browse the repository at this point in the history
Resolve issue 4368 by only applying volume mount overlap validation to initialize domain on PV use case

See merge request weblogic-cloud/weblogic-kubernetes-operator!4439
  • Loading branch information
rjeberhard committed Sep 15, 2023
2 parents 2da1e33 + 406ec92 commit 7d28127
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<V1VolumeMount> getRemainingVolumeMounts(List<V1VolumeMount> list, V1VolumeMount mount) {
Expand All @@ -63,7 +63,8 @@ Set<String> getEnvNames(ClusterSpec spec) {
.collect(toSet());
}

void checkValidMountPath(V1VolumeMount mount, Set<String> envNames, List<V1VolumeMount> mounts) {
void checkValidMountPath(DomainSpec spec, V1VolumeMount mount, Set<String> envNames,
List<V1VolumeMount> mounts) {
if (skipValidation(mount.getMountPath(), envNames)) {
return;
}
Expand All @@ -72,10 +73,16 @@ void checkValidMountPath(V1VolumeMount mount, Set<String> envNames, List<V1Volum
failures.add(DomainValidationMessages.badVolumeMountPath(mount));
}

mounts.stream().forEach(m -> 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<String> list1 = getTokensWithCollection(mount1.getMountPath());
List<String> list2 = getTokensWithCollection(mount2.getMountPath());
for (int i = 0; i < Math.min(list1.size(), list2.size()); i++) {
Expand Down

0 comments on commit 7d28127

Please # to comment.