Skip to content

Backport fix for OWLS 95240 (PR #2691) to release/3.3 #2692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017, 2021, Oracle and/or its affiliates.
// Copyright (c) 2017, 2022, Oracle and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

package oracle.kubernetes.operator.steps;
Expand All @@ -15,6 +15,7 @@
import java.util.stream.Collectors;
import javax.annotation.Nonnull;

import io.kubernetes.client.openapi.models.V1Pod;
import oracle.kubernetes.operator.DomainStatusUpdater;
import oracle.kubernetes.operator.MakeRightDomainOperation;
import oracle.kubernetes.operator.ProcessingConstants;
Expand All @@ -41,6 +42,7 @@
import static oracle.kubernetes.operator.DomainStatusUpdater.MANAGED_SERVERS_STARTING_PROGRESS_REASON;
import static oracle.kubernetes.operator.DomainStatusUpdater.createProgressingStartedEventStep;
import static oracle.kubernetes.operator.helpers.EventHelper.createEventStep;
import static oracle.kubernetes.operator.helpers.PodHelper.getPodServerName;

public class ManagedServersUpStep extends Step {
static final String SERVERS_UP_MSG =
Expand Down Expand Up @@ -118,7 +120,7 @@ public NextAction apply(Packet packet) {
LOGGER.fine(SERVERS_UP_MSG, factory.domain.getDomainUid(), getRunningServers(info));
}

Optional.ofNullable(config).ifPresent(wlsDomainConfig -> addServersToFactory(factory, wlsDomainConfig));
Optional.ofNullable(config).ifPresent(wlsDomainConfig -> addServersToFactory(factory, wlsDomainConfig, info));

info.setServerStartupInfo(factory.getStartupInfos());
info.setServerShutdownInfo(factory.getShutdownInfos());
Expand All @@ -130,7 +132,8 @@ public NextAction apply(Packet packet) {
packet);
}

private void addServersToFactory(@Nonnull ServersUpStepFactory factory, @Nonnull WlsDomainConfig wlsDomainConfig) {
private void addServersToFactory(@Nonnull ServersUpStepFactory factory, @Nonnull WlsDomainConfig wlsDomainConfig,
DomainPresenceInfo info) {
Set<String> clusteredServers = new HashSet<>();

List<ServerConfig> pendingServers = new ArrayList<>();
Expand All @@ -145,6 +148,15 @@ private void addServersToFactory(@Nonnull ServersUpStepFactory factory, @Nonnull
for (ServerConfig serverConfig : pendingServers) {
factory.addServerIfNeeded(serverConfig.wlsServerConfig, serverConfig.wlsClusterConfig);
}

info.getServerPods().filter(pod -> !factory.getServers().contains(getPodServerName(pod)))
.filter(pod -> !getPodServerName(pod).equals(wlsDomainConfig.getAdminServerName()))
.forEach(pod -> shutdownServersNotPresentInDomainConfig(factory, pod));
}

private void shutdownServersNotPresentInDomainConfig(ServersUpStepFactory factory, V1Pod pod) {
WlsServerConfig serverConfig = new WlsServerConfig(getPodServerName(pod), pod.getMetadata().getName(), 0);
factory.addShutdownInfo(new ServerShutdownInfo(serverConfig, pod.getMetadata().getClusterName(), null, false));
}

private void addClusteredServersToFactory(
Expand Down Expand Up @@ -258,6 +270,10 @@ Collection<DomainPresenceInfo.ServerShutdownInfo> getShutdownInfos() {
return shutdownInfos;
}

Collection<String> getServers() {
return servers;
}

private void addStartupInfo(ServerStartupInfo startupInfo) {
if (startupInfos == null) {
startupInfos = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018, 2021, Oracle and/or its affiliates.
// Copyright (c) 2018, 2022, Oracle and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

package oracle.kubernetes.operator.steps;
Expand Down Expand Up @@ -191,6 +191,9 @@ static final class ReadHealthWithHttpStep extends Step {
@Override
public NextAction apply(Packet packet) {
ReadHealthProcessing processing = new ReadHealthProcessing(packet, service, pod);
if (processing.getWlsServerConfig() == null) {
return doNext(packet);
}
return doNext(createRequestStep(processing.createRequest(), new RecordHealthStep(getNext())), packet);
}

Expand Down Expand Up @@ -381,4 +384,4 @@ private static void logReadFailure(Packet packet) {
MessageKeys.WLS_HEALTH_READ_FAILED,
packet.get(ProcessingConstants.SERVER_NAME));
}
}
}
Loading