Skip to content

Commit bc46441

Browse files
committed
Merge branch 'clarify-cluster-name-error-msg-42' into 'release/4.2'
Clarify error message when clusterName specified in cluster spec does not exists. See merge request weblogic-cloud/weblogic-kubernetes-operator!4897
2 parents 6d616ce + 60463ea commit bc46441

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

common/src/main/resources/Operator.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ WLSDO-0007=Configuration overridesConfigMap ''{0}'' is not supported if ''domain
199199
WLSDO-0008=ConfigMap ''{0}'' specified by ''{1}'' not found in namespace ''{2}''.
200200
WLSDO-0009=The secret ''{0}'' must be specified if ''domainHomeSourceType'' is configured as ''FromModel''.
201201
WLSDO-0010=The secret ''{0}'' must be specified if ''domainHomeSourceType'' is configured as ''FromModel'' and spec.configuration.model.domainType is configured as ''JRF''.
202-
WLSDO-0011=Cluster ''{0}'' specified in the domain resource does not exist in the WebLogic domain home configuration.
202+
WLSDO-0011=The clusterName ''{0}'' specified in the cluster resource ''{1}'' referenced by the domain resource does not exist in the WebLogic domain home configuration.
203203
WLSDO-0012=Managed Server ''{0}'' specified in the domain resource does not exist in the WebLogic domain home configuration.
204204
WLSDO-0013=Istio is enabled and the domain resource specified to expose channel {0} in the adminServices section. The channel name default, \
205205
default-admin, default-secure are internal to the WebLogic Kubernetes Operator. Please create the network channel with a different name in the WebLogic Domain before \

operator/src/main/java/oracle/kubernetes/operator/helpers/WlsConfigValidator.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.ArrayList;
77
import java.util.Arrays;
88
import java.util.List;
9+
import java.util.Map;
910
import java.util.Objects;
1011
import java.util.Optional;
1112
import javax.annotation.Nonnull;
@@ -21,8 +22,6 @@
2122
import oracle.kubernetes.operator.wlsconfig.WlsDynamicServersConfig;
2223
import oracle.kubernetes.operator.wlsconfig.WlsServerConfig;
2324
import oracle.kubernetes.operator.work.Packet;
24-
import oracle.kubernetes.weblogic.domain.model.ClusterResource;
25-
import oracle.kubernetes.weblogic.domain.model.ClusterSpec;
2625
import oracle.kubernetes.weblogic.domain.model.ManagedServer;
2726
import oracle.kubernetes.weblogic.domain.model.MonitoringExporterSpecification;
2827
import org.apache.commons.collections4.ListUtils;
@@ -128,8 +127,13 @@ List<String> getTopologyFailures() {
128127
private void verifyDomainResourceReferences() {
129128
getManagedServers().stream()
130129
.map(ManagedServer::getServerName).filter(this::isUnknownServer).forEach(this::reportUnknownServer);
131-
info.getReferencedClusters().stream().map(ClusterResource::getSpec)
132-
.map(ClusterSpec::getClusterName).filter(this::isUnknownCluster).forEach(this::reportUnknownCluster);
130+
131+
info.getReferencedClusters().stream()
132+
.map(cluster -> Map.entry(cluster.getSpec().getClusterName(),
133+
Objects.requireNonNull(cluster.getMetadata().getName())))
134+
.filter(entry -> isUnknownCluster(entry.getKey()))
135+
.forEach(entry -> reportUnknownCluster(entry.getKey(), entry.getValue()));
136+
133137
}
134138

135139
private List<ManagedServer> getManagedServers() {
@@ -155,8 +159,8 @@ private boolean isUnknownCluster(String clusterName) {
155159
return !domainConfig.containsCluster(clusterName);
156160
}
157161

158-
private void reportUnknownCluster(String clusterName) {
159-
reportFailure(NO_CLUSTER_IN_DOMAIN, clusterName);
162+
private void reportUnknownCluster(String wlsClusterName, String refClusterName) {
163+
reportFailure(NO_CLUSTER_IN_DOMAIN, wlsClusterName, refClusterName);
160164
}
161165

162166
// Ensure that generated service names are valid.

operator/src/test/java/oracle/kubernetes/operator/helpers/TopologyValidationStepTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ void whenClusterDoesNotExistInDomain_logWarning() {
463463

464464
runTopologyValidationStep();
465465

466-
assertTopologyMismatchReported(NO_CLUSTER_IN_DOMAIN, "no-such-cluster");
466+
assertTopologyMismatchReported(NO_CLUSTER_IN_DOMAIN, "no-such-cluster", "no-such-cluster");
467467
}
468468

469469
@Test
@@ -533,7 +533,7 @@ void removeOldReplicasTooHighFailures() {
533533
void preserveTopologyFailuresThatStillExist() {
534534
consoleControl.ignoreMessage(NO_CLUSTER_IN_DOMAIN);
535535
final OffsetDateTime initialTime = SystemClock.now();
536-
final String message = getFormattedMessage(NO_CLUSTER_IN_DOMAIN, "no-such-cluster");
536+
final String message = getFormattedMessage(NO_CLUSTER_IN_DOMAIN, "no-such-cluster", "no-such-cluster");
537537
domain.getStatus().addCondition(new DomainCondition(FAILED).withReason(TOPOLOGY_MISMATCH)
538538
.withFailureInfo(domain.getSpec()).withMessage(message));
539539

@@ -1027,7 +1027,7 @@ void whenClusterDoesNotExistInDomain_logWarningAndCreateEvent() {
10271027

10281028
runTopologyValidationStep();
10291029

1030-
assertTopologyMismatchReported(NO_CLUSTER_IN_DOMAIN, "no-such-cluster");
1030+
assertTopologyMismatchReported(NO_CLUSTER_IN_DOMAIN, "no-such-cluster", "no-such-cluster");
10311031
}
10321032

10331033
@Test
@@ -1043,7 +1043,7 @@ void whenBothServerAndClusterDoNotExistInDomain_createEventWithBothWarnings() {
10431043

10441044
assertThat(testSupport, hasEvent(DOMAIN_FAILED_EVENT)
10451045
.withMessageContaining(getLocalizedString(TOPOLOGY_MISMATCH_EVENT_ERROR),
1046-
getFormattedMessage(NO_CLUSTER_IN_DOMAIN, "no-such-cluster"),
1046+
getFormattedMessage(NO_CLUSTER_IN_DOMAIN, "no-such-cluster", "no-such-cluster"),
10471047
getFormattedMessage(NO_MANAGED_SERVER_IN_DOMAIN, "no-such-server")));
10481048
}
10491049

0 commit comments

Comments
 (0)