Skip to content

Commit 1a627e3

Browse files
authored
Backport use of down plan when domain has deletionTimestamp (#3499)
1 parent 2810d99 commit 1a627e3

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,14 +1009,21 @@ private String getNamespace() {
10091009

10101010
@Override
10111011
public Step createSteps() {
1012+
boolean deleteInProgress = deleting || domainHasDeletionTimestamp();
10121013
Step strategy =
1013-
new StartPlanStep(liveInfo, deleting ? createDomainDownPlan(liveInfo) : createDomainUpPlan(liveInfo));
1014-
if (deleting || getDomain() == null) {
1014+
new StartPlanStep(liveInfo,
1015+
deleteInProgress ? createDomainDownPlan(liveInfo) : createDomainUpPlan(liveInfo));
1016+
if (deleteInProgress || getDomain() == null) {
10151017
return strategy;
10161018
} else {
10171019
return DomainValidationSteps.createDomainValidationSteps(getNamespace(), strategy);
10181020
}
10191021
}
1022+
1023+
private boolean domainHasDeletionTimestamp() {
1024+
return Optional.ofNullable(liveInfo.getDomain()).map(Domain::getMetadata)
1025+
.map(V1ObjectMeta::getDeletionTimestamp).isPresent();
1026+
}
10201027
}
10211028

10221029
private static boolean isGenerationChanged(DomainPresenceInfo liveInfo, DomainPresenceInfo cachedInfo) {

operator/src/test/java/oracle/kubernetes/operator/DomainProcessorTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,21 @@ void whenDomainShutDown_removeAllPodsServicesAndPodDisruptionBudgets() {
340340
assertThat(getRunningPDBs(), empty());
341341
}
342342

343+
@Test
344+
void whenDomainMarkedForDeletion_removeAllPodsServicesAndPodDisruptionBudgets() {
345+
defineServerResources(ADMIN_NAME);
346+
Arrays.stream(MANAGED_SERVER_NAMES).forEach(this::defineServerResources);
347+
348+
domain.getMetadata().setDeletionTimestamp(OffsetDateTime.now());
349+
DomainPresenceInfo info = new DomainPresenceInfo(domain);
350+
// MakeRightOperation is created without forDeletion() similar to list or MODIFIED watch
351+
processor.createMakeRightOperation(info).interrupt().withExplicitRecheck().execute();
352+
353+
assertThat(getRunningServices(), empty());
354+
assertThat(getRunningPods(), empty());
355+
assertThat(getRunningPDBs(), empty());
356+
}
357+
343358
@Test
344359
void whenDomainShutDown_ignoreNonOperatorServices() {
345360
defineServerResources(ADMIN_NAME);

0 commit comments

Comments
 (0)