Skip to content

Commit 33e30f8

Browse files
authored
Owls 103150 - Check that ServerStartupInfo is not empty to determine if the cluster is intentionally shut down (#3582)
* Check that ServerStartupInfo is not empty to determine if the cluster is intentionally shut down
1 parent 8ce9120 commit 33e30f8

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ private boolean isServerInThisCluster(String serverName) {
943943
}
944944

945945
private boolean isClusterIntentionallyShutDown() {
946-
return startedServers.isEmpty();
946+
return getInfo().getServerStartupInfo() != null && startedServers.isEmpty();
947947
}
948948

949949
private boolean sufficientServersReady() {

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.time.OffsetDateTime;
77
import java.util.ArrayList;
88
import java.util.Arrays;
9+
import java.util.Collection;
910
import java.util.Collections;
1011
import java.util.HashMap;
1112
import java.util.List;
@@ -101,6 +102,7 @@
101102
import static org.hamcrest.CoreMatchers.not;
102103
import static org.hamcrest.Matchers.containsInRelativeOrder;
103104
import static org.hamcrest.Matchers.equalTo;
105+
import static org.hamcrest.Matchers.hasItems;
104106
import static org.hamcrest.Matchers.is;
105107
import static org.hamcrest.Matchers.nullValue;
106108
import static org.hamcrest.junit.MatcherAssert.assertThat;
@@ -1718,6 +1720,27 @@ void whenDomainRecheckOrScheduleStatusUpdateAndAdminOnlyAndAdminServerIsNotReady
17181720
assertThat(getRecordedDomain(), hasCondition(AVAILABLE).withStatus(FALSE));
17191721
}
17201722

1723+
@Test
1724+
void whenServerStartupInfoIsNull_availableIsFalse() {
1725+
configureDomain().configureCluster(info, "cluster1").withReplicas(2);
1726+
info.getReferencedClusters().forEach(testSupport::defineResources);
1727+
1728+
defineScenario()
1729+
.withCluster("cluster1", "server1", "server2")
1730+
.build();
1731+
info.setServerStartupInfo(null);
1732+
1733+
updateDomainStatus();
1734+
1735+
assertThat(getClusterConditions(),
1736+
hasItems(new ClusterCondition(ClusterConditionType.AVAILABLE).withStatus(FALSE)));
1737+
}
1738+
1739+
private Collection<ClusterCondition> getClusterConditions() {
1740+
return testSupport.<ClusterResource>getResourceWithName(KubernetesTestSupport.CLUSTER, "cluster1")
1741+
.getStatus().getConditions();
1742+
}
1743+
17211744
@SuppressWarnings("SameParameterValue")
17221745
private ScenarioBuilder defineScenario() {
17231746
return new ScenarioBuilder();

0 commit comments

Comments
 (0)