Skip to content

Commit d7529da

Browse files
committed
Merge remote-tracking branch 'origin/main' into release/4.0
2 parents 36f2150 + 58ec63c commit d7529da

File tree

7 files changed

+172
-49
lines changed

7 files changed

+172
-49
lines changed

operator/src/main/java/oracle/kubernetes/operator/DomainNamespaces.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2023, 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;
@@ -75,6 +75,10 @@ AtomicBoolean isStopping(String ns) {
7575
return namespaceStoppingMap.computeIfAbsent(ns, key -> new AtomicBoolean(false));
7676
}
7777

78+
AtomicBoolean getStopping(String ns) {
79+
return namespaceStoppingMap.get(ns);
80+
}
81+
7882
boolean isStarting(String ns) {
7983
return Optional.ofNullable(namespaceStatuses.get(ns))
8084
.map(NamespaceStatus::isNamespaceStarting)

operator/src/main/java/oracle/kubernetes/operator/Namespaces.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2023, 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;
55

6+
import java.util.ArrayList;
67
import java.util.Arrays;
78
import java.util.Collection;
89
import java.util.Collections;
@@ -271,7 +272,7 @@ static class NamespaceListAfterStep extends Step {
271272

272273
@Override
273274
public NextAction apply(Packet packet) {
274-
NamespaceValidationContext validationContext = new NamespaceValidationContext(packet);
275+
NamespaceValidationContext validationContext = new NamespaceValidationContext(packet, domainNamespaces);
275276
getNonNullConfiguredDomainNamespaces().forEach(validationContext::validateConfiguredNamespace);
276277
List<StepAndPacket> nsStopEventSteps = getCreateNSStopEventSteps(packet, validationContext);
277278
stopRemovedNamespaces(validationContext);
@@ -280,18 +281,23 @@ public NextAction apply(Packet packet) {
280281

281282
private List<StepAndPacket> getCreateNSStopEventSteps(Packet packet, NamespaceValidationContext validationContext) {
282283
return domainNamespaces.getNamespaces().stream()
283-
.filter(validationContext::isNoLongerActiveDomainNamespace)
284+
.filter(validationContext::isNotManaged)
284285
.map(n -> createNSStopEventDetails(packet, n)).collect(Collectors.toList());
285286
}
286287

287288
private StepAndPacket createNSStopEventDetails(Packet packet, String namespace) {
288289
LOGGER.info(MessageKeys.END_MANAGING_NAMESPACE, namespace);
289-
return new StepAndPacket(
290-
Step.chain(
291-
createEventStep(new EventData(NAMESPACE_WATCHING_STOPPED).resourceName(namespace).namespace(namespace)),
292-
createEventStep(new EventData(STOP_MANAGING_NAMESPACE).resourceName(namespace)
293-
.namespace(getOperatorNamespace()))),
294-
packet.copy());
290+
return new StepAndPacket(getSteps(namespace), packet.copy());
291+
}
292+
293+
private Step getSteps(String ns) {
294+
List<Step> steps = new ArrayList<>();
295+
if (!domainNamespaces.isStopping(ns).get()) {
296+
steps.add(createEventStep(new EventData(NAMESPACE_WATCHING_STOPPED).resourceName(ns).namespace(ns)));
297+
}
298+
steps.add(createEventStep(
299+
new EventData(STOP_MANAGING_NAMESPACE).resourceName(ns).namespace(getOperatorNamespace())));
300+
return Step.chain(steps.toArray(new Step[0]));
295301
}
296302

297303
private Step createNamespaceWatchStopEventsStep(List<StepAndPacket> nsStopEventDetails) {
@@ -333,9 +339,15 @@ private void stopRemovedNamespaces(NamespaceValidationContext validationContext)
333339
private static class NamespaceValidationContext {
334340

335341
final Collection<String> allDomainNamespaces;
342+
final DomainNamespaces domainNamespaces;
336343

337-
NamespaceValidationContext(Packet packet) {
344+
NamespaceValidationContext(Packet packet, DomainNamespaces domainNamespaces) {
338345
allDomainNamespaces = Optional.ofNullable(getFoundDomainNamespaces(packet)).orElse(Collections.emptyList());
346+
this.domainNamespaces = domainNamespaces;
347+
}
348+
349+
private boolean isNotManaged(String ns) {
350+
return !allDomainNamespaces.contains(ns) || domainNamespaces.isStopping(ns).get();
339351
}
340352

341353
private boolean isNoLongerActiveDomainNamespace(String ns) {

operator/src/main/java/oracle/kubernetes/operator/OperatorMain.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2017, 2023, 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;
@@ -445,7 +445,7 @@ void dispatchNamespaceWatch(Watch.Response<V1Namespace> item) {
445445
case "DELETED":
446446
// Mark the namespace as isStopping, which will cause the namespace be stopped
447447
// the next time when recheckDomains is triggered
448-
mainDelegate.getDomainNamespaces().isStopping(ns).set(true);
448+
Optional.ofNullable(mainDelegate.getDomainNamespaces().getStopping(ns)).ifPresent(n -> n.set(true));
449449

450450
break;
451451

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ private String createContainerPortName(List<V1ContainerPort> ports, String name)
368368
@Nonnull
369369
private String getPortNamePrefix(String name) {
370370
// Use first 12 characters of port name as prefix due to 15 character port name limit
371-
return name.substring(0, 12);
371+
return name.length() > 12 ? name.substring(0, 12) : name;
372372
}
373373

374374
Integer getListenPort() {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ def getDynamicServersOrNone(self,cluster):
268268
childObjs = ls(returnMap='true', returnType='c')
269269
if not childObjs.isEmpty():
270270
cd(childObjs[0])
271-
if get('ServerTemplate') is not None:
272-
# Cluster is a dynamic cluster if a ServerTemplate MBean is found
271+
if get('ServerTemplate') is not None or int(get('DynamicClusterSize')) > 0:
272+
# Cluster is a dynamic cluster if a ServerTemplate MBean is found or DynamicClusterSize is greater than 0.
273273
ret = cmo
274274
except:
275275
trace("Ignoring cd() exception for cluster '" + cluster.getName() + "' in getDynamicServerOrNone() and returning None.")
@@ -611,7 +611,7 @@ def validateDynamicClusterReferencedByOneServerTemplate(self, cluster):
611611
self.addError("The WebLogic dynamic cluster " + self.name(cluster) + " is referenced the server template " + self.name(server_template) + " and the server template " + self.name(template) + ".")
612612
return
613613
if server_template is None:
614-
self.addError("The WebLogic dynamic cluster " + self.name(cluster) + "' is not referenced by any server template.")
614+
self.addError("The WebLogic dynamic cluster " + self.name(cluster) + " is not referenced by any server template.")
615615

616616
def validateServerTemplateNapListenPortIsSet(self, server_or_template):
617617
naps = server_or_template.getNetworkAccessPoints()

0 commit comments

Comments
 (0)