Skip to content

Commit 52f7503

Browse files
committed
Merge branch 'cherry-pick-2f8e3f37' into 'release/4.1'
Cherry-pick branch 'failureInfo' into 'release/4.1' See merge request weblogic-cloud/weblogic-kubernetes-operator!4551
2 parents 52a023b + 8f26885 commit 52f7503

File tree

15 files changed

+345
-21
lines changed

15 files changed

+345
-21
lines changed

documentation/domains/Domain.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@
265265
"description": "Human-readable message indicating details about last transition.",
266266
"type": "string"
267267
},
268+
"failureInfo": {
269+
"description": "Details about the failure. This field will only be set when the condition type is Failed.",
270+
"$ref": "#/definitions/DomainConditionFailureInfo"
271+
},
268272
"status": {
269273
"description": "The status of the condition. Can be True, False, Unknown.",
270274
"type": "string"
@@ -275,6 +279,23 @@
275279
"status"
276280
]
277281
},
282+
"DomainConditionFailureInfo": {
283+
"type": "object",
284+
"properties": {
285+
"introspectVersion": {
286+
"description": "The introspectVersion set when the Failed condition occurred.",
287+
"type": "string"
288+
},
289+
"introspectImage": {
290+
"description": "The image used by the introspector when the Failed condition occurred.",
291+
"type": "string"
292+
},
293+
"restartVersion": {
294+
"description": "The restartVersion set when the Failed condition occurred.",
295+
"type": "string"
296+
}
297+
}
298+
},
278299
"DomainCreationImage": {
279300
"type": "object",
280301
"properties": {

documentation/domains/Domain.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ The current status of the operation of the WebLogic domain. Updated automaticall
192192

193193
| Name | Type | Description |
194194
| --- | --- | --- |
195+
| `failureInfo` | [Domain Condition Failure Info](#domain-condition-failure-info) | Details about the failure. This field will only be set when the condition type is Failed. |
195196
| `lastTransitionTime` | DateTime | Last time the condition transitioned from one status to another. |
196197
| `message` | string | Human-readable message indicating details about last transition. |
197198
| `reason` | string | Unique, one-word, CamelCase reason for the condition's last transition. |
@@ -306,6 +307,14 @@ TopologySpreadConstraint specifies how to spread matching pods among the given t
306307
| `status` | string | The status of the condition. Can be True, False. |
307308
| `type` | string | The type of the condition. Valid types are Completed, Available, Failed, and Rolling. |
308309

310+
### Domain Condition Failure Info
311+
312+
| Name | Type | Description |
313+
| --- | --- | --- |
314+
| `introspectImage` | string | The image used by the introspector when the Failed condition occurred. |
315+
| `introspectVersion` | string | The introspectVersion set when the Failed condition occurred. |
316+
| `restartVersion` | string | The restartVersion set when the Failed condition occurred. |
317+
309318
### Server Health
310319

311320
| Name | Type | Description |

kubernetes/crd/domain-crd.yaml

Lines changed: 18 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: 01a3cdba6b993d2091f4c55f47ffb2a35debc51ee59d1de05ccd3735881d64f8
8+
weblogic.sha256: 33268f8aa3d7ece940cdfa9e06d55685f8fb45de1d8f4f5f9186bd059d3b8da9
99
name: domains.weblogic.oracle
1010
spec:
1111
group: weblogic.oracle
@@ -9745,6 +9745,23 @@ spec:
97459745
description: Human-readable message indicating details about
97469746
last transition.
97479747
type: string
9748+
failureInfo:
9749+
description: Details about the failure. This field will only
9750+
be set when the condition type is Failed.
9751+
type: object
9752+
properties:
9753+
introspectVersion:
9754+
description: The introspectVersion set when the Failed condition
9755+
occurred.
9756+
type: string
9757+
introspectImage:
9758+
description: The image used by the introspector when the
9759+
Failed condition occurred.
9760+
type: string
9761+
restartVersion:
9762+
description: The restartVersion set when the Failed condition
9763+
occurred.
9764+
type: string
97489765
status:
97499766
description: The status of the condition. Can be True, False,
97509767
Unknown.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ private boolean shouldContinue(MakeRightDomainOperation operation, DomainPresenc
390390
} else if (isDeleting(operation)) {
391391
return true;
392392
} else if (liveInfo.isDomainProcessingHalted(cachedInfo)) {
393-
return false;
393+
return liveInfo.isMustDomainProcessingRestart();
394394
} else if (isExplicitRecheckWithoutRetriableFailure(operation, liveInfo)
395395
|| liveInfo.isDomainGenerationChanged(cachedInfo)) {
396396
return true;

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2024, 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;
@@ -577,7 +577,8 @@ List<EventData> createDomainEvents() {
577577
void addFailure(DomainStatus status, DomainCondition condition) {
578578
addFailureCondition(status, condition);
579579
if (hasReachedRetryLimit(status, condition)) {
580-
addFailureCondition(status, new DomainCondition(FAILED).withReason(ABORTED).withMessage(getFatalMessage()));
580+
addFailureCondition(status, new DomainCondition(FAILED).withReason(ABORTED)
581+
.withFailureInfo(getDomain().getSpec()).withMessage(getFatalMessage()));
581582
}
582583
}
583584

@@ -748,11 +749,14 @@ private void setStatusConditions(DomainStatus status) {
748749
newConditions.apply();
749750

750751
if (isHasFailedPod()) {
751-
addFailure(status, new DomainCondition(FAILED).withReason(SERVER_POD).withMessage(getPodFailedMessage()));
752+
addFailure(status, new DomainCondition(FAILED).withReason(SERVER_POD)
753+
.withFailureInfo(getDomain().getSpec()).withMessage(getPodFailedMessage()));
752754
} else if (hasPodNotRunningInTime()) {
753-
addFailure(status, new DomainCondition(FAILED).withReason(SERVER_POD).withMessage(getPodNotRunningMessage()));
755+
addFailure(status, new DomainCondition(FAILED).withReason(SERVER_POD)
756+
.withFailureInfo(getDomain().getSpec()).withMessage(getPodNotRunningMessage()));
754757
} else if (hasPodNotReadyInTime()) {
755-
addFailure(status, new DomainCondition(FAILED).withReason(SERVER_POD).withMessage(getPodNotReadyMessage()));
758+
addFailure(status, new DomainCondition(FAILED).withReason(SERVER_POD)
759+
.withFailureInfo(getDomain().getSpec()).withMessage(getPodNotReadyMessage()));
756760
} else {
757761
status.removeConditionsMatching(c -> c.hasType(FAILED) && SERVER_POD == c.getReason());
758762
if (newConditions.allIntendedServersReady() && !stillHasPodPendingRestart(status)) {
@@ -1586,7 +1590,8 @@ public FailureStatusUpdaterContext(Packet packet, DomainStatusUpdaterStep status
15861590
@Override
15871591
void modifyStatus(DomainStatus status) {
15881592
removingReasons.forEach(status::markFailuresForRemoval);
1589-
addFailure(status, status.createAdjustedFailedCondition(reason, message, isInitializeDomainOnPV()));
1593+
addFailure(status, status.createAdjustedFailedCondition(reason, message, isInitializeDomainOnPV(),
1594+
getDomain().getSpec()));
15901595
status.addCondition(new DomainCondition(COMPLETED).withStatus(false), isInitializeDomainOnPV());
15911596
Optional.ofNullable(jobUid).ifPresent(status::setFailedIntrospectionUid);
15921597
status.removeMarkedFailures();

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

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2024, 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.helpers;
@@ -49,6 +49,7 @@
4949
import oracle.kubernetes.weblogic.domain.model.ClusterResource;
5050
import oracle.kubernetes.weblogic.domain.model.ClusterSpec;
5151
import oracle.kubernetes.weblogic.domain.model.ClusterStatus;
52+
import oracle.kubernetes.weblogic.domain.model.DomainConditionFailureInfo;
5253
import oracle.kubernetes.weblogic.domain.model.DomainResource;
5354
import oracle.kubernetes.weblogic.domain.model.DomainSpec;
5455
import oracle.kubernetes.weblogic.domain.model.DomainStatus;
@@ -138,6 +139,10 @@ public boolean isDomainGenerationChanged(DomainPresenceInfo cachedInfo) {
138139
return getGeneration(getDomain()).compareTo(getGeneration(cachedInfo.getDomain())) > 0;
139140
}
140141

142+
public boolean isMustDomainProcessingRestart() {
143+
return !failureInfoVersionsUnchanged();
144+
}
145+
141146
/**
142147
* Returns true if the state of the current domain presence info, when compared with the cached info for the same
143148
* domain, indicates that the make-right should not be run. The user has a number of options to resume processing
@@ -155,6 +160,21 @@ private boolean isDomainProcessingAborted() {
155160
.orElse(false);
156161
}
157162

163+
private DomainConditionFailureInfo findFailureInfo() {
164+
return Optional.ofNullable(getDomain()).map(DomainResource::getStatus)
165+
.map(DomainStatus::getFailureInfo).orElse(null);
166+
}
167+
168+
private boolean failureInfoVersionsUnchanged() {
169+
return Optional.ofNullable(findFailureInfo()).map(this::versionsUnchanged).orElse(true);
170+
}
171+
172+
private boolean versionsUnchanged(DomainConditionFailureInfo failureInfo) {
173+
return hasSameIntrospectVersion(failureInfo)
174+
&& hasSameRestartVersion(failureInfo)
175+
&& hasSameIntrospectImage(failureInfo);
176+
}
177+
158178
private boolean versionsUnchanged(DomainPresenceInfo cachedInfo) {
159179
return hasSameIntrospectVersion(cachedInfo)
160180
&& hasSameRestartVersion(cachedInfo)
@@ -176,10 +196,14 @@ private boolean isNewerThan(DomainPresenceInfo cachedInfo) {
176196
|| !KubernetesUtils.isFirstNewer(cachedInfo.getDomain().getMetadata(), getDomain().getMetadata());
177197
}
178198

179-
private boolean hasSameIntrospectVersion(DomainPresenceInfo cachedInfo) {
199+
private boolean hasSameIntrospectVersion(DomainPresenceInfo cachedInfo) {
180200
return Objects.equals(getIntrospectVersion(), cachedInfo.getIntrospectVersion());
181201
}
182202

203+
private boolean hasSameIntrospectVersion(DomainConditionFailureInfo failureInfo) {
204+
return Objects.equals(getIntrospectVersion(), failureInfo.getIntrospectVersion());
205+
}
206+
183207
private String getIntrospectVersion() {
184208
return Optional.ofNullable(getDomain())
185209
.map(DomainResource::getSpec)
@@ -191,6 +215,10 @@ private boolean hasSameRestartVersion(DomainPresenceInfo cachedInfo) {
191215
return Objects.equals(getRestartVersion(), cachedInfo.getRestartVersion());
192216
}
193217

218+
private boolean hasSameRestartVersion(DomainConditionFailureInfo failureInfo) {
219+
return Objects.equals(getRestartVersion(), failureInfo.getRestartVersion());
220+
}
221+
194222
private String getRestartVersion() {
195223
return Optional.ofNullable(getDomain())
196224
.map(DomainResource::getRestartVersion)
@@ -201,6 +229,10 @@ private boolean hasSameIntrospectImage(DomainPresenceInfo cachedInfo) {
201229
return Objects.equals(getIntrospectImage(), cachedInfo.getIntrospectImage());
202230
}
203231

232+
private boolean hasSameIntrospectImage(DomainConditionFailureInfo failureInfo) {
233+
return Objects.equals(getIntrospectImage(), failureInfo.getIntrospectImage());
234+
}
235+
204236
private String getIntrospectImage() {
205237
return Optional.ofNullable(getDomain())
206238
.map(DomainResource::getSpec)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2024, 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.helpers;
@@ -233,7 +233,7 @@ private void addDomainFailureStatus(Packet packet, RequestParams requestParams,
233233

234234
private void updateFailureStatus(
235235
@Nonnull DomainResource domain, RequestParams requestParams, ApiException apiException) {
236-
DomainCondition condition = new DomainCondition(FAILED).withReason(KUBERNETES)
236+
DomainCondition condition = new DomainCondition(FAILED).withFailureInfo(domain.getSpec()).withReason(KUBERNETES)
237237
.withMessage(createMessage(requestParams, apiException));
238238
addFailureStatus(domain, condition);
239239
}

operator/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainCondition.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2017, 2024, 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.weblogic.domain.model;
@@ -46,6 +46,11 @@ public class DomainCondition implements Comparable<DomainCondition>, PatchableCo
4646
@Expose
4747
private DomainFailureReason reason;
4848

49+
@Description("Details about the failure. This field will only be set when the condition type is Failed.")
50+
@SerializedName("failureInfo")
51+
@Expose
52+
private DomainConditionFailureInfo failureInfo;
53+
4954
@Description("The status of the condition. Can be True, False, Unknown.")
5055
@SerializedName("status")
5156
@Expose
@@ -76,6 +81,7 @@ public DomainCondition(@Nonnull DomainConditionType conditionType) {
7681
this.status = other.status;
7782
this.markedForDeletion = other.markedForDeletion;
7883
this.severity = other.severity;
84+
this.failureInfo = other.failureInfo;
7985
}
8086

8187
/**
@@ -198,6 +204,24 @@ public DomainCondition withStatus(boolean status) {
198204
return type;
199205
}
200206

207+
public DomainConditionFailureInfo getFailureInfo() {
208+
return failureInfo;
209+
}
210+
211+
public void setFailureInfo(DomainConditionFailureInfo failureInfo) {
212+
this.failureInfo = failureInfo;
213+
}
214+
215+
public DomainCondition withFailureInfo(DomainConditionFailureInfo failureInfo) {
216+
setFailureInfo(failureInfo);
217+
return this;
218+
}
219+
220+
public DomainCondition withFailureInfo(DomainSpec spec) {
221+
setFailureInfo(new DomainConditionFailureInfo(spec));
222+
return this;
223+
}
224+
201225
/**
202226
* Set the severity for the current FAILED condition. This is not allowed for other types.
203227
* @param severity the new severity value
@@ -246,6 +270,7 @@ public String toString() {
246270
Optional.ofNullable(reason).ifPresent(r -> sb.append(" reason: ").append(r));
247271
Optional.ofNullable(severity).ifPresent(m -> sb.append(" severity: ").append(m));
248272
Optional.ofNullable(message).ifPresent(m -> sb.append(" message: ").append(m));
273+
Optional.ofNullable(failureInfo).ifPresent(f -> sb.append(" failureInfo: ").append(f));
249274
return sb.toString();
250275
}
251276

@@ -257,6 +282,7 @@ public int hashCode() {
257282
.append(type)
258283
.append(status)
259284
.append(severity)
285+
.append(failureInfo)
260286
.toHashCode();
261287
}
262288

@@ -274,6 +300,7 @@ public boolean equals(Object other) {
274300
.append(type, rhs.type)
275301
.append(status, rhs.status)
276302
.append(severity, rhs.severity)
303+
.append(failureInfo, rhs.failureInfo)
277304
.isEquals();
278305
}
279306

@@ -295,7 +322,8 @@ int compareTransitionTime(DomainCondition thatCondition) {
295322
.withStringField("status", DomainCondition::getStatus)
296323
.withEnumField("reason", DomainCondition::getReason)
297324
.withEnumField("type", DomainCondition::getType)
298-
.withEnumField("severity", DomainCondition::getSeverity);
325+
.withEnumField("severity", DomainCondition::getSeverity)
326+
.withObjectField("failureInfo", DomainCondition::getFailureInfo, DomainConditionFailureInfo.getObjectPatch());
299327

300328
static ObjectPatch<DomainCondition> getObjectPatch() {
301329
return conditionPatch;

0 commit comments

Comments
 (0)