Skip to content

Commit 99c6522

Browse files
committed
Merge branch 'fix-k8s-api-network-restart-error-42' into 'release/4.2'
Introduce k8s network failure reason and remove previous network related error... See merge request weblogic-cloud/weblogic-kubernetes-operator!4831
2 parents 55de432 + db297fe commit 99c6522

File tree

14 files changed

+57
-2
lines changed

14 files changed

+57
-2
lines changed

documentation/domains/Domain.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@
238238
"DomainInvalid",
239239
"Introspection",
240240
"Kubernetes",
241+
"KubernetesNetworkException",
241242
"ServerPod",
242243
"PersistentVolumeClaim",
243244
"ReplicasTooHigh",

kubernetes/crd/domain-crd.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
weblogic.sha256: 3cad99b24fb84de65dc38d7734ce269fb7058c3b6aed32b85ef590e142921635
8+
weblogic.sha256: 8cd5a2176fe99b104c82048d750d42f1130341bdfdba825493bc64de45025424
99
name: domains.weblogic.oracle
1010
spec:
1111
group: weblogic.oracle
@@ -10322,6 +10322,7 @@ spec:
1032210322
- DomainInvalid
1032310323
- Introspection
1032410324
- Kubernetes
10325+
- KubernetesNetworkException
1032510326
- ServerPod
1032610327
- PersistentVolumeClaim
1032710328
- ReplicasTooHigh

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public PodListProcessing(String namespace, OffsetDateTime dateTime) {
6464

6565
@Override
6666
public NextAction onSuccess(Packet packet, CallResponse<V1PodList> callResponse) {
67+
clearExistingKubernetesNetworkException(packet);
6768
callResponse.getResult().getItems().stream()
6869
.filter(pod -> isStuck(pod, now))
6970
.forEach(pod -> addStuckPodToPacket(packet, pod));
@@ -156,6 +157,7 @@ public ForcedDeleteResponseStep(String name, String namespace, String domainUID)
156157
@Override
157158
@SuppressWarnings("try")
158159
public NextAction onSuccess(Packet packet, CallResponse<Object> callResponse) {
160+
clearExistingKubernetesNetworkException(packet);
159161
try (ThreadLoggingContext ignored =
160162
ThreadLoggingContext.setThreadContext().namespace(namespace).domainUid(domainUID)) {
161163
LOGGER.info(POD_FORCE_DELETED, name, namespace);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ static class MakeRightDomainStep<V> extends DefaultResponseStep<V> {
254254

255255
@Override
256256
public NextAction onSuccess(Packet packet, CallResponse<V> callResponse) {
257+
clearExistingKubernetesNetworkException(packet);
257258
MakeRightDomainOperation makeRightDomainOperation =
258259
(MakeRightDomainOperation)packet.get(MAKE_RIGHT_DOMAIN_OPERATION);
259260
if (makeRightDomainOperation != null) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ private class CrdPresenceResponseStep<L extends KubernetesListObject> extends D
212212

213213
@Override
214214
public NextAction onSuccess(Packet packet, CallResponse<L> callResponse) {
215+
clearExistingKubernetesNetworkException(packet);
215216
warnedOfCrdAbsence = false;
216217
crdPresenceCheckCount.set(0);
217218
return super.onSuccess(packet, callResponse);

operator/src/main/java/oracle/kubernetes/operator/helpers/PersistentVolumeClaimHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ private NextAction updateDomainStatus(Packet packet, CallResponse<V1PersistentVo
144144

145145
@Override
146146
public NextAction onSuccess(Packet packet, CallResponse<V1PersistentVolumeClaim> callResponse) {
147+
clearExistingKubernetesNetworkException(packet);
147148
logPersistentVolumeClaimCreated(messageKey);
148149
addPersistentVolumeClaimToRecord(callResponse.getResult());
149150
return doNext(packet);
@@ -164,6 +165,7 @@ public NextAction onFailure(Packet packet, CallResponse<V1PersistentVolumeClaim>
164165

165166
@Override
166167
public NextAction onSuccess(Packet packet, CallResponse<V1PersistentVolumeClaim> callResponse) {
168+
clearExistingKubernetesNetworkException(packet);
167169
DomainPresenceInfo info = packet.getSpi(DomainPresenceInfo.class);
168170
V1PersistentVolumeClaim persistentVolumeClaim = callResponse.getResult();
169171

operator/src/main/java/oracle/kubernetes/operator/helpers/PersistentVolumeHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ private NextAction updateDomainStatus(Packet packet, CallResponse<V1PersistentVo
133133

134134
@Override
135135
public NextAction onSuccess(Packet packet, CallResponse<V1PersistentVolume> callResponse) {
136+
clearExistingKubernetesNetworkException(packet);
136137
logPersistentVolumeCreated(messageKey);
137138
return doNext(packet);
138139
}
@@ -152,6 +153,7 @@ public NextAction onFailure(Packet packet, CallResponse<V1PersistentVolume> call
152153

153154
@Override
154155
public NextAction onSuccess(Packet packet, CallResponse<V1PersistentVolume> callResponse) {
156+
clearExistingKubernetesNetworkException(packet);
155157
DomainPresenceInfo info = packet.getSpi(DomainPresenceInfo.class);
156158
V1PersistentVolume persistentVolume = callResponse.getResult();
157159
if (persistentVolume == null) {

operator/src/main/java/oracle/kubernetes/operator/helpers/PodDisruptionBudgetHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ private NextAction updateDomainStatus(Packet packet, CallResponse<V1PodDisruptio
113113

114114
@Override
115115
public NextAction onSuccess(Packet packet, CallResponse<V1PodDisruptionBudget> callResponse) {
116+
clearExistingKubernetesNetworkException(packet);
116117
logPodDisruptionBudgetCreated(messageKey);
117118
addPodDisruptionBudgetToRecord(callResponse.getResult());
118119
return doNext(packet);
@@ -133,6 +134,7 @@ public NextAction onFailure(Packet packet, CallResponse<V1PodDisruptionBudget> c
133134

134135
@Override
135136
public NextAction onSuccess(Packet packet, CallResponse<V1PodDisruptionBudget> callResponse) {
137+
clearExistingKubernetesNetworkException(packet);
136138
V1PodDisruptionBudget podDisruptionBudget = callResponse.getResult();
137139
if (podDisruptionBudget == null) {
138140
removePodDisruptionBudgetFromRecord();
@@ -157,6 +159,7 @@ public NextAction onFailure(Packet packet, CallResponse<V1PodDisruptionBudget> c
157159

158160
@Override
159161
public NextAction onSuccess(Packet packet, CallResponse<V1PodDisruptionBudget> callResponse) {
162+
clearExistingKubernetesNetworkException(packet);
160163
logPodDisruptionBudgetPatched();
161164
return doNext(packet);
162165
}

operator/src/main/java/oracle/kubernetes/operator/helpers/ResponseStep.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
package oracle.kubernetes.operator.helpers;
55

6+
import java.net.ConnectException;
7+
import java.net.SocketTimeoutException;
68
import java.util.Collections;
79
import java.util.Optional;
810
import java.util.stream.Collectors;
@@ -25,6 +27,7 @@
2527
import oracle.kubernetes.operator.work.Packet;
2628
import oracle.kubernetes.operator.work.Step;
2729
import oracle.kubernetes.weblogic.domain.model.DomainCondition;
30+
import oracle.kubernetes.weblogic.domain.model.DomainFailureReason;
2831
import oracle.kubernetes.weblogic.domain.model.DomainResource;
2932

3033
import static oracle.kubernetes.common.CommonConstants.CRD;
@@ -37,6 +40,7 @@
3740
import static oracle.kubernetes.operator.calls.AsyncRequestStep.accessContinue;
3841
import static oracle.kubernetes.weblogic.domain.model.DomainConditionType.FAILED;
3942
import static oracle.kubernetes.weblogic.domain.model.DomainFailureReason.KUBERNETES;
43+
import static oracle.kubernetes.weblogic.domain.model.DomainFailureReason.KUBERNETES_NETWORK_EXCEPTION;
4044

4145
/**
4246
* Step to receive response of Kubernetes API server call.
@@ -80,6 +84,20 @@ public final void setPrevious(Step previousStep) {
8084
this.previousStep = previousStep;
8185
}
8286

87+
/**
88+
* Clear out any existing Kubernetes network exception (ConnectException and SocketTimeoutException).
89+
*
90+
* @param packet packet
91+
*/
92+
public static void clearExistingKubernetesNetworkException(Packet packet) {
93+
Optional.ofNullable(packet.getSpi(DomainPresenceInfo.class))
94+
.map(DomainPresenceInfo::getDomain)
95+
.map(DomainResource::getStatus)
96+
.ifPresent(status -> status.removeConditionsMatching(
97+
c -> c.hasType(FAILED) && KUBERNETES_NETWORK_EXCEPTION == c.getReason()));
98+
}
99+
100+
83101
@Override
84102
public final NextAction apply(Packet packet) {
85103
NextAction nextAction = getActionForCallResponse(packet);
@@ -233,7 +251,16 @@ private void addDomainFailureStatus(Packet packet, RequestParams requestParams,
233251

234252
private void updateFailureStatus(
235253
@Nonnull DomainResource domain, RequestParams requestParams, ApiException apiException) {
236-
DomainCondition condition = new DomainCondition(FAILED).withFailureInfo(domain.getSpec()).withReason(KUBERNETES)
254+
DomainFailureReason reason = KUBERNETES;
255+
if (apiException != null) {
256+
LOGGER.fine("updateFailureStatus: apiException: " + apiException.getCause());
257+
LOGGER.fine("updateFailureStatus: status code: " + apiException.getCode());
258+
}
259+
if (apiException != null && (apiException.getCause() instanceof ConnectException
260+
|| apiException.getCause() instanceof SocketTimeoutException)) {
261+
reason = DomainFailureReason.KUBERNETES_NETWORK_EXCEPTION;
262+
}
263+
DomainCondition condition = new DomainCondition(FAILED).withFailureInfo(domain.getSpec()).withReason(reason)
237264
.withMessage(createMessage(requestParams, apiException));
238265
addFailureStatus(domain, condition);
239266
}

operator/src/main/java/oracle/kubernetes/operator/helpers/SecretHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public NextAction onFailure(Packet packet, CallResponse<V1Secret> callResponse)
102102

103103
@Override
104104
public NextAction onSuccess(Packet packet, CallResponse<V1Secret> callResponse) {
105+
clearExistingKubernetesNetworkException(packet);
105106
V1Secret secret = callResponse.getResult();
106107
packet.getSpi(DomainPresenceInfo.class).setWebLogicCredentialsSecret(secret);
107108
insertAuthorizationSource(packet, secret);

0 commit comments

Comments
 (0)