Skip to content

Commit 5158391

Browse files
ankediarjeberhard
authored andcommitted
OWLS-93960- Fix to avoid NPE when non-operator PodDisruptionBudgets are present in the domain namespace.
1 parent c2cce0b commit 5158391

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
import oracle.kubernetes.operator.work.Step;
2828
import oracle.kubernetes.weblogic.domain.model.DomainList;
2929

30+
import static oracle.kubernetes.operator.LabelConstants.forDomainUidSelector;
31+
import static oracle.kubernetes.operator.LabelConstants.getCreatedByOperatorSelector;
32+
3033
/**
3134
* A Class to manage listing Kubernetes resources associated with a namespace and doing processing on them.
3235
*/
@@ -164,7 +167,7 @@ private Step getPodDisruptionBudgetListSteps() {
164167
}
165168

166169
private Step createPodDisruptionBudgetListStep(List<Consumer<V1beta1PodDisruptionBudgetList>> processing) {
167-
return new CallBuilder()
170+
return new CallBuilder().withLabelSelectors(forDomainUidSelector(domainUid), getCreatedByOperatorSelector())
168171
.listPodDisruptionBudgetAsync(namespace, new ListResponseStep<>(processing));
169172
}
170173

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,18 @@ void whenDomainShutDown_ignoreNonOperatorPodDisruptionBudgets() {
367367
assertThat(getRunningPDBs(), contains(createNonOperatorPodDisruptionBudget()));
368368
}
369369

370+
@Test
371+
void whenMakeRightExecuted_ignoreNonOperatorPodDisruptionBudgets() {
372+
defineServerResources(ADMIN_NAME);
373+
Arrays.stream(MANAGED_SERVER_NAMES).forEach(this::defineServerResources);
374+
testSupport.defineResources(createNonOperatorPodDisruptionBudget());
375+
376+
DomainPresenceInfo info = new DomainPresenceInfo(domain);
377+
processor.createMakeRightOperation(info).interrupt().withExplicitRecheck().execute();
378+
379+
assertThat(info.getPodDisruptionBudget(CLUSTER), notNullValue());
380+
}
381+
370382
@Test
371383
void whenClusterReplicas2_server3WithAlwaysPolicy_establishMatchingPresence() {
372384
domainConfigurator.configureCluster(CLUSTER).withReplicas(2);
@@ -684,7 +696,7 @@ private V1beta1PodDisruptionBudget createNonOperatorPodDisruptionBudget() {
684696
.putLabelsItem(CREATEDBYOPERATOR_LABEL, "false")
685697
.putLabelsItem(DOMAINNAME_LABEL, DomainProcessorTestSetup.UID)
686698
.putLabelsItem(DOMAINUID_LABEL, DomainProcessorTestSetup.UID)
687-
.putLabelsItem(CLUSTERNAME_LABEL, CLUSTER))
699+
.putLabelsItem(DOMAINUID_LABEL, DomainProcessorTestSetup.UID))
688700
.spec(new V1beta1PodDisruptionBudgetSpec()
689701
.selector(new V1LabelSelector()
690702
.putMatchLabelsItem(CREATEDBYOPERATOR_LABEL, "false")

0 commit comments

Comments
 (0)