diff --git a/operator/src/main/java/oracle/kubernetes/operator/NamespacedResources.java b/operator/src/main/java/oracle/kubernetes/operator/NamespacedResources.java index 70305f97f1a..77fb021e3e8 100644 --- a/operator/src/main/java/oracle/kubernetes/operator/NamespacedResources.java +++ b/operator/src/main/java/oracle/kubernetes/operator/NamespacedResources.java @@ -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. */ @@ -164,7 +167,7 @@ private Step getPodDisruptionBudgetListSteps() { } private Step createPodDisruptionBudgetListStep(List> processing) { - return new CallBuilder() + return new CallBuilder().withLabelSelectors(forDomainUidSelector(domainUid), getCreatedByOperatorSelector()) .listPodDisruptionBudgetAsync(namespace, new ListResponseStep<>(processing)); } diff --git a/operator/src/test/java/oracle/kubernetes/operator/DomainProcessorTest.java b/operator/src/test/java/oracle/kubernetes/operator/DomainProcessorTest.java index a3d07d0dc7a..3f5bd3d8131 100644 --- a/operator/src/test/java/oracle/kubernetes/operator/DomainProcessorTest.java +++ b/operator/src/test/java/oracle/kubernetes/operator/DomainProcessorTest.java @@ -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); @@ -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")