Skip to content

Commit 5e83289

Browse files
committed
Merge branch 'processing-backports' into 'release/4.0'
Backport 4250 and 4260 to release/4.0 See merge request weblogic-cloud/weblogic-kubernetes-operator!4289
2 parents cb43c02 + 1d5272f commit 5e83289

14 files changed

+364
-227
lines changed

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

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ static void cleanupNamespace(String namespace) {
188188
}
189189

190190
private static void registerStatusUpdater(
191-
String ns, String domainUid, ScheduledFuture<?> future) {
191+
String ns, String domainUid, ScheduledFuture<?> future) {
192192
ScheduledFuture<?> existing =
193-
statusUpdaters.computeIfAbsent(ns, k -> new ConcurrentHashMap<>()).put(domainUid, future);
193+
statusUpdaters.computeIfAbsent(ns, k -> new ConcurrentHashMap<>()).put(domainUid, future);
194194
if (existing != null) {
195195
existing.cancel(false);
196196
}
@@ -293,8 +293,8 @@ private static void processServerEvent(CoreV1Event event) {
293293
}
294294

295295
Optional.ofNullable(domains.get(event.getMetadata().getNamespace()))
296-
.map(m -> m.get(domainUid))
297-
.ifPresent(info -> info.updateLastKnownServerStatus(serverName, status));
296+
.map(m -> m.get(domainUid))
297+
.ifPresent(info -> info.updateLastKnownServerStatus(serverName, status));
298298
}
299299

300300
/**
@@ -337,9 +337,9 @@ private void onDeleteEvent(@Nonnull String kind, @Nonnull String name, CoreV1Eve
337337

338338
private static String getReadinessStatus(CoreV1Event event) {
339339
return Optional.ofNullable(event.getMessage())
340-
.filter(m -> m.contains(WebLogicConstants.READINESS_PROBE_NOT_READY_STATE))
341-
.map(m -> m.substring(m.lastIndexOf(':') + 1).trim())
342-
.orElse(null);
340+
.filter(m -> m.contains(WebLogicConstants.READINESS_PROBE_NOT_READY_STATE))
341+
.map(m -> m.substring(m.lastIndexOf(':') + 1).trim())
342+
.orElse(null);
343343
}
344344

345345
// pre-conditions: DomainPresenceInfo SPI
@@ -379,10 +379,14 @@ private boolean shouldContinue(MakeRightDomainOperation operation, DomainPresenc
379379
final DomainPresenceInfo cachedInfo = getExistingDomainPresenceInfo(liveInfo);
380380
if (isNewDomain(cachedInfo)) {
381381
return true;
382-
} else if (liveInfo.isFromOutOfDateEvent(operation, cachedInfo)
383-
|| liveInfo.isDomainProcessingHalted(cachedInfo)) {
382+
} else if (liveInfo.isFromOutOfDateEvent(operation, cachedInfo)) {
383+
return false;
384+
} else if (isDeleting(operation)) {
385+
return true;
386+
} else if (liveInfo.isDomainProcessingHalted(cachedInfo)) {
384387
return false;
385-
} else if (operation.isExplicitRecheck() || liveInfo.isDomainGenerationChanged(cachedInfo)) {
388+
} else if (isExplicitRecheckWithoutRetriableFailure(operation, liveInfo)
389+
|| liveInfo.isDomainGenerationChanged(cachedInfo)) {
386390
return true;
387391
} else {
388392
cachedInfo.setDomain(liveInfo.getDomain());
@@ -392,7 +396,7 @@ private boolean shouldContinue(MakeRightDomainOperation operation, DomainPresenc
392396

393397
private boolean shouldContinue(MakeRightClusterOperation operation, ClusterPresenceInfo liveInfo) {
394398
final ClusterPresenceInfo cachedInfo = getExistingClusterPresenceInfo(liveInfo);
395-
if (hasDeletedClusterEventData(operation)) {
399+
if (isDeleting(operation)) {
396400
return findClusterPresenceInfo(liveInfo.getNamespace(), liveInfo.getResourceName());
397401
} else if (isNewCluster(cachedInfo)) {
398402
return true;
@@ -406,6 +410,15 @@ private boolean shouldContinue(MakeRightClusterOperation operation, ClusterPrese
406410
}
407411
}
408412

413+
private boolean isExplicitRecheckWithoutRetriableFailure(
414+
MakeRightDomainOperation operation, DomainPresenceInfo info) {
415+
return operation.isExplicitRecheck() && !hasRetriableFailureNonRetryingOperation(operation, info);
416+
}
417+
418+
private boolean hasRetriableFailureNonRetryingOperation(MakeRightDomainOperation operation, DomainPresenceInfo info) {
419+
return info.hasRetriableFailure() && !operation.isRetryOnFailure();
420+
}
421+
409422
private boolean isNewDomain(DomainPresenceInfo cachedInfo) {
410423
return Optional.ofNullable(cachedInfo).map(DomainPresenceInfo::getDomain).orElse(null) == null;
411424
}
@@ -418,11 +431,15 @@ private boolean findClusterPresenceInfo(String namespace, String clusterName) {
418431
return Optional.ofNullable(clusters.get(namespace)).orElse(Collections.emptyMap()).get(clusterName) != null;
419432
}
420433

421-
private boolean hasDeletedClusterEventData(MakeRightClusterOperation operation) {
434+
private boolean isDeleting(MakeRightClusterOperation operation) {
422435
return EventItem.CLUSTER_DELETED == getEventItem(operation);
423436
}
424437

425-
private EventItem getEventItem(MakeRightClusterOperation operation) {
438+
private boolean isDeleting(MakeRightDomainOperation operation) {
439+
return operation.isDeleting() || EventItem.DOMAIN_DELETED == getEventItem(operation);
440+
}
441+
442+
private EventItem getEventItem(MakeRightOperation operation) {
426443
return Optional.ofNullable(operation.getEventData()).map(EventData::getItem).orElse(null);
427444
}
428445

@@ -454,8 +471,8 @@ public void scheduleDomainStatusUpdates(DomainPresenceInfo info) {
454471
@Override
455472
public void registerDomainPresenceInfo(DomainPresenceInfo info) {
456473
domains
457-
.computeIfAbsent(info.getNamespace(), k -> new ConcurrentHashMap<>())
458-
.put(info.getDomainUid(), info);
474+
.computeIfAbsent(info.getNamespace(), k -> new ConcurrentHashMap<>())
475+
.put(info.getDomainUid(), info);
459476
}
460477

461478
@Override
@@ -522,22 +539,22 @@ public void reportSuspendedFibers() {
522539
if (LOGGER.isFineEnabled()) {
523540
BiConsumer<String, FiberGate> consumer =
524541
(namespace, gate) -> gate.getCurrentFibers().forEach(
525-
(key, fiber) -> Optional.ofNullable(fiber.getSuspendedStep()).ifPresent(suspendedStep -> {
526-
try (ThreadLoggingContext ignored
527-
= setThreadContext().namespace(namespace).domainUid(getDomainUid(fiber))) {
528-
LOGGER.fine("Fiber is SUSPENDED at " + suspendedStep.getResourceName());
529-
}
530-
}));
542+
(key, fiber) -> Optional.ofNullable(fiber.getSuspendedStep()).ifPresent(suspendedStep -> {
543+
try (ThreadLoggingContext ignored
544+
= setThreadContext().namespace(namespace).domainUid(getDomainUid(fiber))) {
545+
LOGGER.fine("Fiber is SUSPENDED at " + suspendedStep.getResourceName());
546+
}
547+
}));
531548
makeRightFiberGates.forEach(consumer);
532549
statusFiberGates.forEach(consumer);
533550
}
534551
}
535552

536553
private String getDomainUid(Fiber fiber) {
537554
return Optional.ofNullable(fiber)
538-
.map(Fiber::getPacket)
539-
.map(p -> p.getSpi(DomainPresenceInfo.class))
540-
.map(DomainPresenceInfo::getDomainUid).orElse("");
555+
.map(Fiber::getPacket)
556+
.map(p -> p.getSpi(DomainPresenceInfo.class))
557+
.map(DomainPresenceInfo::getDomainUid).orElse("");
541558
}
542559

543560
/**
@@ -622,10 +639,9 @@ private void processIntrospectorJobPodWatch(@Nonnull V1Pod pod, String watchType
622639
@Override
623640
public void updateDomainStatus(@Nonnull V1Pod pod, DomainPresenceInfo info) {
624641
Optional.ofNullable(IntrospectionStatus.createStatusUpdateSteps(pod))
625-
.ifPresent(steps -> delegate.runSteps(new Packet().with(info), steps, null));
642+
.ifPresent(steps -> delegate.runSteps(new Packet().with(info), steps, null));
626643
}
627644

628-
629645
/* Recently, we've seen a number of intermittent bugs where K8s reports
630646
* outdated watch events. There seem to be two main cases: 1) a DELETED
631647
* event for a resource that was deleted, but has since been recreated, and 2)
@@ -677,7 +693,7 @@ public void dispatchPodDisruptionBudgetWatch(Watch.Response<V1PodDisruptionBudge
677693
}
678694

679695
DomainPresenceInfo info =
680-
getExistingDomainPresenceInfo(getPDBNamespace(pdb), domainUid);
696+
getExistingDomainPresenceInfo(getPDBNamespace(pdb), domainUid);
681697
if (info == null) {
682698
return;
683699
}
@@ -718,7 +734,7 @@ public void dispatchConfigMapWatch(Watch.Response<V1ConfigMap> item) {
718734
case DELETED:
719735
delegate.runSteps(
720736
ConfigMapHelper.createScriptConfigMapStep(
721-
c.getMetadata().getNamespace(), productVersion));
737+
c.getMetadata().getNamespace(), productVersion));
722738
break;
723739

724740
case ERROR:
@@ -993,7 +1009,7 @@ private void reportFailure(Throwable throwable) {
9931009
logThrowable(throwable);
9941010
runFailureSteps(throwable);
9951011
}
996-
1012+
9971013
private void runFailureSteps(Throwable throwable) {
9981014
gate.startNewFiberIfCurrentFiberMatches(
9991015
((DomainPresenceInfo)presenceInfo).getDomainUid(),
@@ -1042,7 +1058,7 @@ private void scheduleRetry(@Nonnull DomainPresenceInfo domainPresenceInfo) {
10421058
final MakeRightDomainOperation retry = operation.createRetry(domainPresenceInfo);
10431059
gate.getExecutor().schedule(retry::execute, delayUntilNextRetry(domainPresenceInfo), TimeUnit.SECONDS);
10441060
}
1045-
1061+
10461062
private long delayUntilNextRetry(@Nonnull DomainPresenceInfo domainPresenceInfo) {
10471063
final OffsetDateTime nextRetryTime = domainPresenceInfo.getDomain().getNextRetryTime();
10481064
final Duration interval = Duration.between(SystemClock.now(), nextRetryTime);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ private boolean isStranded(DomainPresenceInfo dpi) {
273273
private static void removeStrandedDomainPresenceInfo(DomainProcessor dp, DomainPresenceInfo info) {
274274
info.setDeleting(true);
275275
info.setPopulated(true);
276-
dp.createMakeRightOperation(info).withExplicitRecheck().forDeletion().withEventData(new EventData(
277-
EventItem.DOMAIN_DELETED)).execute();
276+
dp.createMakeRightOperation(info).withExplicitRecheck().forDeletion().execute();
278277
}
279278

280279
private Stream<DomainPresenceInfo> getActiveDomainPresenceInfos() {
@@ -290,9 +289,10 @@ private void activateDomain(DomainProcessor dp, DomainPresenceInfo info) {
290289
EventItem eventItem = getEventItem(info);
291290
MakeRightDomainOperation makeRight = dp.createMakeRightOperation(info).withExplicitRecheck();
292291
if (eventItem != null) {
293-
makeRight.withEventData(new EventData(eventItem)).interrupt();
292+
makeRight.withEventData(new EventData(eventItem)).interrupt().execute();
293+
} else if (!info.hasRetriableFailure()) {
294+
makeRight.execute();
294295
}
295-
makeRight.execute();
296296
}
297297

298298
private EventItem getEventItem(DomainPresenceInfo info) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private boolean wasNotRolling() {
200200
/**
201201
* Creates an asynchronous step to initialize the domain status, if needed, to indicate that the operator has
202202
* seen the domain and is now working on it.
203-
* @param hasEventData tue if the make right operation is associated with an event data
203+
* @param hasEventData true if the make right operation is associated with an event.
204204
*/
205205
public static Step createStatusInitializationStep(boolean hasEventData) {
206206
return new StatusInitializationStep(hasEventData);
@@ -593,7 +593,7 @@ void addDomainEvent(DomainCondition condition) {
593593
}
594594

595595
public static class StatusInitializationStep extends DomainStatusUpdaterStep {
596-
private boolean hasEventData;
596+
private final boolean hasEventData;
597597

598598
StatusInitializationStep(boolean hasEventData) {
599599
super();

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Defines the operation to log a ClusterCreated/Changed/Deleted event.
1111
*/
1212
public interface MakeRightClusterOperation extends MakeRightOperation<ClusterPresenceInfo> {
13+
1314
/**
1415
* Set the event data that is associated with this operation.
1516
*
@@ -26,11 +27,4 @@ public interface MakeRightClusterOperation extends MakeRightOperation<ClusterPre
2627
MakeRightClusterOperation interrupt();
2728

2829
MakeRightClusterOperation withExplicitRecheck();
29-
30-
/**
31-
* Get the event data associated with this make-right operation.
32-
*
33-
* @return the event data.
34-
*/
35-
EventHelper.EventData getEventData();
3630
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,17 @@ public interface MakeRightDomainOperation extends MakeRightOperation<DomainPrese
4444
*/
4545
MakeRightDomainOperation interrupt();
4646

47+
/**
48+
* Modifies the factory to indicate that this is a retry operation on a retriable failure.
49+
+
50+
+ @return the updated factory
51+
*/
52+
MakeRightDomainOperation retryOnFailure();
53+
4754
boolean isDeleting();
4855

56+
boolean isRetryOnFailure();
57+
4958
void setInspectionRun();
5059

5160
void setLiveInfo(@Nonnull DomainPresenceInfo info);
@@ -99,5 +108,4 @@ static Step createStepsToRerunWithIntrospection(Packet packet) {
99108
static Optional<MakeRightDomainOperation> fromPacket(Packet packet) {
100109
return Optional.ofNullable(packet.getValue(MAKE_RIGHT_DOMAIN_OPERATION));
101110
}
102-
103111
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import javax.annotation.Nonnull;
77

8+
import oracle.kubernetes.operator.helpers.EventHelper;
89
import oracle.kubernetes.operator.helpers.ResourcePresenceInfo;
910
import oracle.kubernetes.operator.work.Packet;
1011
import oracle.kubernetes.operator.work.PacketComponent;
@@ -15,6 +16,7 @@
1516
* or to log a ClusterCreated/Changed/Deleted event.
1617
*/
1718
public interface MakeRightOperation<T extends ResourcePresenceInfo> extends PacketComponent {
19+
1820
void execute();
1921

2022
@Nonnull
@@ -28,5 +30,12 @@ public interface MakeRightOperation<T extends ResourcePresenceInfo> extends Pack
2830

2931
boolean hasEventData();
3032

33+
/**
34+
* Get the event data associated with this make-right operation.
35+
*
36+
* @return the event data.
37+
*/
38+
EventHelper.EventData getEventData();
39+
3140
boolean isExplicitRecheck();
3241
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,10 @@ public Collection<ClusterResource> getClusterResources() {
10551055
return clusters.values();
10561056
}
10571057

1058+
public boolean hasRetriableFailure() {
1059+
return Optional.ofNullable(getDomain()).map(DomainResource::hasRetriableFailure).orElse(false);
1060+
}
1061+
10581062
/** Details about a specific managed server. */
10591063
public static class ServerInfo {
10601064
public final WlsServerConfig serverConfig;

operator/src/main/java/oracle/kubernetes/operator/makeright/MakeRightClusterOperationImpl.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import oracle.kubernetes.operator.helpers.ClusterPresenceInfo;
1515
import oracle.kubernetes.operator.helpers.EventHelper;
1616
import oracle.kubernetes.operator.helpers.EventHelper.ClusterResourceEventData;
17+
import oracle.kubernetes.operator.helpers.EventHelper.EventData;
1718
import oracle.kubernetes.operator.work.NextAction;
1819
import oracle.kubernetes.operator.work.Packet;
1920
import oracle.kubernetes.operator.work.Step;
@@ -105,7 +106,7 @@ private boolean isDeleting() {
105106
}
106107

107108
private EventHelper.EventItem getEventItem() {
108-
return Optional.ofNullable(getEventData()).map(EventHelper.EventData::getItem).orElse(null);
109+
return Optional.ofNullable(getEventData()).map(EventData::getItem).orElse(null);
109110
}
110111

111112
@Override
@@ -123,11 +124,6 @@ public boolean isExplicitRecheck() {
123124
return explicitRecheck;
124125
}
125126

126-
@Override
127-
public EventHelper.EventData getEventData() {
128-
return eventData;
129-
}
130-
131127
class StartPlanStep extends Step {
132128

133129
private final ClusterPresenceInfo info;

0 commit comments

Comments
 (0)