Skip to content

Commit

Permalink
OWLS-93960 - NPE fix in PodDisruptionBudgetHelper (#2633)
Browse files Browse the repository at this point in the history
* OWLS-93960- Fix to avoid NPE when non-operator PodDisruptionBudgets are present in the domain namespace.

* Remove the DOMAINUID_LABEL and DOMAINNAME_LABEL label from PDB.
  • Loading branch information
ankedia authored Nov 22, 2021
1 parent a929cf3 commit e7bde67
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import oracle.kubernetes.operator.work.Step;
import oracle.kubernetes.weblogic.domain.model.DomainList;

import static oracle.kubernetes.operator.LabelConstants.forDomainUidSelector;
import static oracle.kubernetes.operator.LabelConstants.getCreatedByOperatorSelector;

/**
* A Class to manage listing Kubernetes resources associated with a namespace and doing processing on them.
*/
Expand Down Expand Up @@ -164,7 +167,7 @@ private Step getPodDisruptionBudgetListSteps() {
}

private Step createPodDisruptionBudgetListStep(List<Consumer<V1beta1PodDisruptionBudgetList>> processing) {
return new CallBuilder()
return new CallBuilder().withLabelSelectors(forDomainUidSelector(domainUid), getCreatedByOperatorSelector())
.listPodDisruptionBudgetAsync(namespace, new ListResponseStep<>(processing));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,18 @@ void whenDomainShutDown_ignoreNonOperatorPodDisruptionBudgets() {
assertThat(getRunningPDBs(), contains(createNonOperatorPodDisruptionBudget()));
}

@Test
void whenMakeRightExecuted_ignoreNonOperatorPodDisruptionBudgets() {
defineServerResources(ADMIN_NAME);
Arrays.stream(MANAGED_SERVER_NAMES).forEach(this::defineServerResources);
testSupport.defineResources(createNonOperatorPodDisruptionBudget());

DomainPresenceInfo info = new DomainPresenceInfo(domain);
processor.createMakeRightOperation(info).interrupt().withExplicitRecheck().execute();

assertThat(info.getPodDisruptionBudget(CLUSTER), notNullValue());
}

@Test
void whenClusterReplicas2_server3WithAlwaysPolicy_establishMatchingPresence() {
domainConfigurator.configureCluster(CLUSTER).withReplicas(2);
Expand Down Expand Up @@ -732,10 +744,7 @@ private V1beta1PodDisruptionBudget createNonOperatorPodDisruptionBudget() {
.name("do-not-delete-pdb")
.namespace(NS)
.putLabelsItem("serviceType", "SERVER")
.putLabelsItem(CREATEDBYOPERATOR_LABEL, "false")
.putLabelsItem(DOMAINNAME_LABEL, DomainProcessorTestSetup.UID)
.putLabelsItem(DOMAINUID_LABEL, DomainProcessorTestSetup.UID)
.putLabelsItem(CLUSTERNAME_LABEL, CLUSTER))
.putLabelsItem(CREATEDBYOPERATOR_LABEL, "false"))
.spec(new V1beta1PodDisruptionBudgetSpec()
.selector(new V1LabelSelector()
.putMatchLabelsItem(CREATEDBYOPERATOR_LABEL, "false")
Expand Down

0 comments on commit e7bde67

Please sign in to comment.