Skip to content

Commit fc8ec40

Browse files
authored
3.3 branch - OWLS-97340 - HTTP warnings logged continuously after changing serverStartPolicy to NEVER (#2856)
* use up-to-date DomainPresenceInfo for creating StatusReaderStep if available * backport fix for OWLS-96905 to 3.3 branch
1 parent 933a613 commit fc8ec40

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ public NextAction apply(Packet packet) {
103103
AtomicInteger remainingServerHealthToRead = new AtomicInteger();
104104
packet.put(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ, remainingServerHealthToRead);
105105

106+
DomainPresenceInfo currentInfo =
107+
Optional.ofNullable(
108+
DomainProcessorImpl.getExistingDomainPresenceInfo(info.getNamespace(), info.getDomainUid()))
109+
.orElse(info);
110+
106111
Collection<StepAndPacket> startDetails =
107-
info.getServerPods()
112+
currentInfo.getServerPods()
108113
.map(pod -> createStatusReaderStep(packet, pod))
109114
.collect(Collectors.toList());
110115

operator/src/main/java/oracle/kubernetes/operator/steps/ManagedServersUpStep.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ private static Step scaleDownIfNecessary(
7171

7272
if (info.getDomain().isShuttingDown()) {
7373
insert(steps, createAvailableHookStep());
74-
factory.shutdownInfos.add(new ServerShutdownInfo(domainTopology.getAdminServerName(), null));
74+
Optional.ofNullable(domainTopology).ifPresent(
75+
wlsDomainConfig ->
76+
factory.shutdownInfos.add(new ServerShutdownInfo(wlsDomainConfig.getAdminServerName(), null)));
7577
}
7678

7779
List<ServerShutdownInfo> serversToStop = getServersToStop(info, factory.shutdownInfos);

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2019, 2022, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator;
@@ -57,8 +57,9 @@ class ServerStatusReaderTest extends HttpUserAgentTest {
5757
private final FiberTestSupport testSupport = new FiberTestSupport();
5858
private final List<Memento> mementos = new ArrayList<>();
5959
private final Domain domain =
60-
new Domain().withMetadata(new V1ObjectMeta().namespace(NS)).withSpec(new DomainSpec());
60+
new Domain().withMetadata(new V1ObjectMeta().namespace(NS)).withSpec(new DomainSpec().withDomainUid(UID));
6161
private final DomainPresenceInfo info = new DomainPresenceInfo(domain);
62+
private final Map<String, Map<String, DomainPresenceInfo>> presenceInfoMap = new HashMap<>();
6263

6364
@BeforeEach
6465
public void setUp() throws NoSuchFieldException {
@@ -69,6 +70,7 @@ public void setUp() throws NoSuchFieldException {
6970
mementos.add(ClientFactoryStub.install());
7071

7172
testSupport.addDomainPresenceInfo(info);
73+
mementos.add(StaticStubSupport.install(DomainProcessorImpl.class, "DOMAINS", presenceInfoMap));
7274
}
7375

7476
private V1Pod createPod(String serverName) {
@@ -134,6 +136,23 @@ void createDomainStatusReaderStep_initializesRemainingServersHealthRead_withNumS
134136
is(2));
135137
}
136138

139+
@Test
140+
void createDomainStatusReaderStep_usesInfoFromDomainProcessorIfAvailable() {
141+
info.setServerPod("server1", createPod("server1"));
142+
143+
DomainPresenceInfo latestInfo = new DomainPresenceInfo(domain);
144+
latestInfo.setServerPod("server1", createPod("server1"));
145+
latestInfo.setServerPod("server2", createPod("server2"));
146+
presenceInfoMap.put(NS, Map.of(UID, latestInfo));
147+
148+
Packet packet =
149+
testSupport.runSteps(ServerStatusReader.createDomainStatusReaderStep(info, 0, endStep));
150+
151+
assertThat(
152+
((AtomicInteger) packet.get(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ)).get(),
153+
is(2));
154+
}
155+
137156
@SuppressWarnings("unchecked")
138157
private Map<String, String> getServerStates(Packet packet) {
139158
return (Map<String, String>) packet.get(SERVER_STATE_MAP);

operator/src/test/java/oracle/kubernetes/operator/steps/ManagedServersUpStepTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2022, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.steps;
@@ -531,6 +531,13 @@ void whenShuttingDown_allowAdminServerNameInListOfServers() {
531531
"server3", ADMIN);
532532
}
533533

534+
@Test
535+
void whenShuttingDown_withNullWlsDomainConfig_ensureNoException() {
536+
configurator.setShuttingDown(true);
537+
538+
createNextStepWithNullWlsDomainConfig();
539+
}
540+
534541
@Test
535542
void whenClusterStartupDefinedWithPreCreateServerService_addAllToServers() {
536543
configureCluster("cluster1").withPrecreateServerService(true);
@@ -787,6 +794,14 @@ private Step createNextStep(List<String> servers) {
787794
return factory.createServerStep(domainPresenceInfo, config, serversUpStepFactory, nextStep);
788795
}
789796

797+
private Step createNextStepWithNullWlsDomainConfig() {
798+
configSupport.setAdminServerName(ADMIN);
799+
ManagedServersUpStep.NextStepFactory factory = factoryMemento.getOriginalValue();
800+
ServersUpStepFactory serversUpStepFactory = new ServersUpStepFactory(null, domain, domainPresenceInfo, false);
801+
List<DomainPresenceInfo.ServerShutdownInfo> ssi = new ArrayList<>();
802+
return factory.createServerStep(domainPresenceInfo, null, serversUpStepFactory, nextStep);
803+
}
804+
790805
private void addShutdownServerInfo(String serverName, List<String> servers,
791806
List<DomainPresenceInfo.ServerShutdownInfo> ssi) {
792807
if (!serverName.equals(configSupport.createDomainConfig().getAdminServerName()) && !servers.contains(serverName)) {

0 commit comments

Comments
 (0)