Skip to content

Commit a82069c

Browse files
committed
Merge remote-tracking branch 'origin/release/3.3' into backport-remocon
2 parents fbf4b7d + 9e32456 commit a82069c

File tree

8 files changed

+210
-73
lines changed

8 files changed

+210
-73
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiAuxiliaryImage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2021, 2022, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
@@ -479,7 +479,7 @@ void testErrorPathDomainMismatchMountPath() {
479479
assertDoesNotThrow(() -> createDomainCustomResource(domainCR), "createDomainCustomResource throws Exception");
480480

481481
// check the introspector pod log contains the expected error message
482-
String expectedErrorMsg = "Auxiliary Image: Dir '/errorpath' doesn't exist or is empty. Exiting.";
482+
String expectedErrorMsg = "cp: can't stat '/errorpath/*': No such file or directory";
483483
verifyIntrospectorPodLogContainsExpectedErrorMsg(domainUid, errorpathDomainNamespace, expectedErrorMsg);
484484

485485
// check the domain event contains the expected error message

kubernetes/samples/scripts/common/utility.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2+
# Copyright (c) 2018, 2022, Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44

55
#
@@ -926,3 +926,26 @@ function checkService(){
926926
done
927927
echo "Service [$svc] found"
928928
}
929+
930+
# Get pod name when pod available in a given namespace
931+
function getPodName(){
932+
933+
local max=$((SECONDS + 120))
934+
935+
local pod=$1
936+
local ns=$2
937+
938+
local pname=""
939+
while [ $SECONDS -le $max ] ; do
940+
pname=`kubectl get po -n ${ns} | grep -w ${pod} | awk '{print $1}'`
941+
[ -z "${pname}" ] || break
942+
sleep 1
943+
done
944+
945+
if [ -z "${pname}" ] ; then
946+
echo "[ERROR] Could not find Pod [$pod] after $max seconds";
947+
exit 1
948+
fi
949+
950+
echo "${pname}"
951+
}

kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2+
# Copyright (c) 2018, 2022, Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
#
55
# Description
@@ -212,9 +212,9 @@ function createDomainHome {
212212
# domain resource is created by exec'ing into the pod to look for the presence of domainCreate.yaml file.
213213

214214
if [ "$useWdt" = true ]; then
215-
POD_NAME=`kubectl get pods -n ${namespace} | grep ${JOB_NAME} | awk ' { print $1; } '`
215+
POD_NAME=$(getPodName "${JOB_NAME}" "${namespace}")
216216
echo "Waiting for results to be available from $POD_NAME"
217-
kubectl wait --timeout=600s --for=condition=ContainersReady pod $POD_NAME
217+
kubectl wait --timeout=600s --for=condition=ContainersReady pod $POD_NAME -n ${namespace}
218218
#echo "Fetching results"
219219
sleep 30
220220
max=30

operator/src/main/java/oracle/kubernetes/operator/steps/ManagedServersUpStep.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2017, 2022, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.steps;
@@ -15,6 +15,7 @@
1515
import java.util.stream.Collectors;
1616
import javax.annotation.Nonnull;
1717

18+
import io.kubernetes.client.openapi.models.V1Pod;
1819
import oracle.kubernetes.operator.DomainStatusUpdater;
1920
import oracle.kubernetes.operator.MakeRightDomainOperation;
2021
import oracle.kubernetes.operator.ProcessingConstants;
@@ -41,6 +42,7 @@
4142
import static oracle.kubernetes.operator.DomainStatusUpdater.MANAGED_SERVERS_STARTING_PROGRESS_REASON;
4243
import static oracle.kubernetes.operator.DomainStatusUpdater.createProgressingStartedEventStep;
4344
import static oracle.kubernetes.operator.helpers.EventHelper.createEventStep;
45+
import static oracle.kubernetes.operator.helpers.PodHelper.getPodServerName;
4446

4547
public class ManagedServersUpStep extends Step {
4648
static final String SERVERS_UP_MSG =
@@ -118,7 +120,7 @@ public NextAction apply(Packet packet) {
118120
LOGGER.fine(SERVERS_UP_MSG, factory.domain.getDomainUid(), getRunningServers(info));
119121
}
120122

121-
Optional.ofNullable(config).ifPresent(wlsDomainConfig -> addServersToFactory(factory, wlsDomainConfig));
123+
Optional.ofNullable(config).ifPresent(wlsDomainConfig -> addServersToFactory(factory, wlsDomainConfig, info));
122124

123125
info.setServerStartupInfo(factory.getStartupInfos());
124126
info.setServerShutdownInfo(factory.getShutdownInfos());
@@ -130,7 +132,8 @@ public NextAction apply(Packet packet) {
130132
packet);
131133
}
132134

133-
private void addServersToFactory(@Nonnull ServersUpStepFactory factory, @Nonnull WlsDomainConfig wlsDomainConfig) {
135+
private void addServersToFactory(@Nonnull ServersUpStepFactory factory, @Nonnull WlsDomainConfig wlsDomainConfig,
136+
DomainPresenceInfo info) {
134137
Set<String> clusteredServers = new HashSet<>();
135138

136139
List<ServerConfig> pendingServers = new ArrayList<>();
@@ -145,6 +148,15 @@ private void addServersToFactory(@Nonnull ServersUpStepFactory factory, @Nonnull
145148
for (ServerConfig serverConfig : pendingServers) {
146149
factory.addServerIfNeeded(serverConfig.wlsServerConfig, serverConfig.wlsClusterConfig);
147150
}
151+
152+
info.getServerPods().filter(pod -> !factory.getServers().contains(getPodServerName(pod)))
153+
.filter(pod -> !getPodServerName(pod).equals(wlsDomainConfig.getAdminServerName()))
154+
.forEach(pod -> shutdownServersNotPresentInDomainConfig(factory, pod));
155+
}
156+
157+
private void shutdownServersNotPresentInDomainConfig(ServersUpStepFactory factory, V1Pod pod) {
158+
WlsServerConfig serverConfig = new WlsServerConfig(getPodServerName(pod), pod.getMetadata().getName(), 0);
159+
factory.addShutdownInfo(new ServerShutdownInfo(serverConfig, pod.getMetadata().getClusterName(), null, false));
148160
}
149161

150162
private void addClusteredServersToFactory(
@@ -258,6 +270,10 @@ Collection<DomainPresenceInfo.ServerShutdownInfo> getShutdownInfos() {
258270
return shutdownInfos;
259271
}
260272

273+
Collection<String> getServers() {
274+
return servers;
275+
}
276+
261277
private void addStartupInfo(ServerStartupInfo startupInfo) {
262278
if (startupInfos == null) {
263279
startupInfos = new ArrayList<>();

operator/src/main/java/oracle/kubernetes/operator/steps/ReadHealthStep.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2022, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.steps;
@@ -191,6 +191,9 @@ static final class ReadHealthWithHttpStep extends Step {
191191
@Override
192192
public NextAction apply(Packet packet) {
193193
ReadHealthProcessing processing = new ReadHealthProcessing(packet, service, pod);
194+
if (processing.getWlsServerConfig() == null) {
195+
return doNext(packet);
196+
}
194197
return doNext(createRequestStep(processing.createRequest(), new RecordHealthStep(getNext())), packet);
195198
}
196199

@@ -381,4 +384,4 @@ private static void logReadFailure(Packet packet) {
381384
MessageKeys.WLS_HEALTH_READ_FAILED,
382385
packet.get(ProcessingConstants.SERVER_NAME));
383386
}
384-
}
387+
}

operator/src/main/resources/scripts/introspectDomain.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2022, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
#
44
# ------------
@@ -351,6 +351,7 @@ def validate(self):
351351
self.validateAdminServer()
352352
self.validateClusters()
353353
self.validateServerCustomChannelName()
354+
self.validateDynamicClustersDuplicateServerNamePrefix()
354355
return self.isValid()
355356

356357
def generate(self):
@@ -401,6 +402,15 @@ def validateAdminServer(self):
401402
if cluster is not None:
402403
self.addError("The admin server " + self.name(adminServer) + " belongs to the WebLogic cluster " + self.name(cluster) + ", the operator does not support having an admin server participate in a cluster.")
403404

405+
def validateDynamicClustersDuplicateServerNamePrefix(self):
406+
serverNamePrefixes = []
407+
for cluster in self.env.getDomain().getClusters():
408+
if self.getDynamicServersOrNone(cluster) is not None:
409+
if cluster.getDynamicServers().getServerNamePrefix() in serverNamePrefixes:
410+
self.addError("The ServerNamePrefix '" + cluster.getDynamicServers().getServerNamePrefix() + "' specified for WebLogic dynamic cluster " + self.name(cluster) + "'s dynamic servers is already in use. The ServerNamePrefix must be unique for each WebLogic dynamic cluster.")
411+
else:
412+
serverNamePrefixes.append(cluster.getDynamicServers().getServerNamePrefix())
413+
404414
def validateClusters(self):
405415
for cluster in self.env.getDomain().getClusters():
406416
self.validateCluster(cluster)

operator/src/main/resources/scripts/modelInImage.sh

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2+
# Copyright (c) 2018, 2022, Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
#
55
# This script contains the all the function of model in image
@@ -1054,12 +1054,22 @@ function wdtHandleOnlineUpdate() {
10541054
mkdir -p ${DOMAIN_HOME}/lib || exitOrLoop
10551055
for file in $(sort_files ${IMG_ARCHIVES_ROOTDIR} "*.zip")
10561056
do
1057-
# expand the archive domain libraries to the domain lib
1057+
# expand the archive domain libraries to the domain lib, 11 is caution when zip entry doesn't exists
10581058
cd ${DOMAIN_HOME}/lib || exitOrLoop
1059-
${JAVA_HOME}/bin/jar xf ${IMG_ARCHIVES_ROOTDIR}/${file} wlsdeploy/domainLibraries/
1059+
unzip -jo ${IMG_ARCHIVES_ROOTDIR}/${file} wlsdeploy/domainLibraries/*
1060+
if [ $? -ne 0 && $? -ne 11 ] ; then
1061+
trace SEVERE "Domain Source Type is FromModel, error in extracting domainLibraries " \
1062+
"${IMG_ARCHIVES_ROOTDIR}/${file}"
1063+
exitOrLoop
1064+
fi
10601065

1061-
if [ $? -ne 0 ] ; then
1062-
trace SEVERE "Error extracting domain lib '${IMG_ARCHIVES_ROOTDIR}/${file}'"
1066+
# expand the domain bin, in update case user may only update a file in the domainBin archive, 11 is caution when
1067+
# zip entry doesn't exists
1068+
cd ${DOMAIN_HOME}/bin || exitOrLoop
1069+
unzip -jo ${IMG_ARCHIVES_ROOTDIR}/${file} wlsdeploy/domainBin/*
1070+
if [ $? -ne 0 && $? -ne 11 ] ; then
1071+
trace SEVERE "Domain Source Type is FromModel, error in extracting domainBin " \
1072+
"${IMG_ARCHIVES_ROOTDIR}/${file}"
10631073
exitOrLoop
10641074
fi
10651075

@@ -1290,21 +1300,25 @@ function prepareMIIServer() {
12901300

12911301
for file in $(sort_files ${IMG_ARCHIVES_ROOTDIR} "*.zip")
12921302
do
1293-
# expand the archive domain libraries to the domain lib
1294-
cd ${DOMAIN_HOME}/lib || return 1
1295-
${JAVA_HOME}/bin/jar xf ${IMG_ARCHIVES_ROOTDIR}/${file} ${WLSDEPLOY_DOMAINLIB}
12961303

1297-
if [ $? -ne 0 ] ; then
1298-
trace SEVERE "Domain Source Type is FromModel, error in extracting domain libs ${IMG_ARCHIVES_ROOTDIR}/${file}"
1299-
return 1
1304+
# expand the archive domain libraries to the domain lib, 11 is caution when zip entry doesn't exists
1305+
cd ${DOMAIN_HOME}/lib || exitOrLoop
1306+
unzip -jo ${IMG_ARCHIVES_ROOTDIR}/${file} wlsdeploy/domainLibraries/*
1307+
if [ $? -ne 0 && $? -ne 11 ] ; then
1308+
trace SEVERE "Domain Source Type is FromModel, error in extracting domainLibraries " \
1309+
"${IMG_ARCHIVES_ROOTDIR}/${file}"
1310+
exitOrLoop
13001311
fi
13011312

1302-
# Flatten the jars to the domain lib root
1303-
1304-
if [ -d ${WLSDEPLOY_DOMAINLIB} ] && [ "$(ls -A ${WLSDEPLOY_DOMAINLIB})" ] ; then
1305-
mv ${WLSDEPLOY_DOMAINLIB}/* .
1313+
# expand the domain bin, in update case user may only update a file in the domainBin archive, 11 is caution when
1314+
# zip entry doesn't exists
1315+
cd ${DOMAIN_HOME}/bin || exitOrLoop
1316+
unzip -jo ${IMG_ARCHIVES_ROOTDIR}/${file} wlsdeploy/domainBin/*
1317+
if [ $? -ne 0 && $? -ne 11 ] ; then
1318+
trace SEVERE "Domain Source Type is FromModel, error in extracting domainBin " \
1319+
"${IMG_ARCHIVES_ROOTDIR}/${file}"
1320+
exitOrLoop
13061321
fi
1307-
rm -fr wlsdeploy/
13081322

13091323
# expand the archive apps and shared lib to the wlsdeploy/* directories
13101324
# the config.xml is referencing them from that path

0 commit comments

Comments
 (0)