Skip to content

Commit 68648b7

Browse files
committed
show dump on change; remove double checksum
1 parent 5046966 commit 68648b7

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
public class AnnotationHelper {
1515
private static final boolean DEBUG = true;
1616
static final String SHA256_ANNOTATION = "weblogic.sha256";
17+
private static final String HASHED_STRING = "hashedString";
1718
private static Function<V1Pod, String> HASH_FUNCTION =
1819
pod -> DigestUtils.sha256Hex(Yaml.dump(pod));
1920

@@ -35,11 +36,15 @@ static void annotateForPrometheus(V1ObjectMeta meta, int httpPort) {
3536
static V1Pod withSha256Hash(V1Pod pod) {
3637
String dump = Yaml.dump(pod);
3738
pod.getMetadata().putAnnotationsItem(SHA256_ANNOTATION, HASH_FUNCTION.apply(pod));
38-
if (DEBUG) pod.getMetadata().putAnnotationsItem("hashedString", dump);
39+
if (DEBUG) pod.getMetadata().putAnnotationsItem(HASHED_STRING, dump);
3940
return pod;
4041
}
4142

4243
static String getHash(V1Pod pod) {
4344
return pod.getMetadata().getAnnotations().get(SHA256_ANNOTATION);
4445
}
46+
47+
static String getDebugString(V1Pod pod) {
48+
return pod.getMetadata().getAnnotations().get(HASHED_STRING);
49+
}
4550
}

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,7 @@ Step createPod(Step next) {
279279
}
280280

281281
private Step createPodAsync(ResponseStep<V1Pod> response) {
282-
return new CallBuilder().createPodAsync(getNamespace(), getPodModelWithChecksum(), response);
283-
}
284-
285-
private V1Pod getPodModelWithChecksum() {
286-
return AnnotationHelper.withSha256Hash(getPodModel());
282+
return new CallBuilder().createPodAsync(getNamespace(), getPodModel(), response);
287283
}
288284

289285
/**
@@ -367,11 +363,18 @@ private boolean mustPatchPod(V1Pod currentPod) {
367363
}
368364

369365
private boolean canUseCurrentPod(V1Pod currentPod) {
370-
return AnnotationHelper.getHash(getPodModel()).equals(AnnotationHelper.getHash(currentPod));
366+
boolean useCurrent =
367+
AnnotationHelper.getHash(getPodModel()).equals(AnnotationHelper.getHash(currentPod));
368+
if (!useCurrent && AnnotationHelper.getDebugString(currentPod) != null)
369+
LOGGER.info(
370+
MessageKeys.POD_DUMP,
371+
AnnotationHelper.getDebugString(currentPod),
372+
AnnotationHelper.getDebugString(getPodModel()));
373+
374+
return useCurrent;
371375
}
372376

373377
private String getReasonToRecycle(V1Pod currentPod) {
374-
375378
PodCompatibility compatibility = new PodCompatibility(getPodModel(), currentPod);
376379
return compatibility.getIncompatibility();
377380
}
@@ -573,11 +576,11 @@ public NextAction onSuccess(
573576
// ---------------------- model methods ------------------------------
574577

575578
private V1Pod createPodModel() {
576-
return withPatchableElements(AnnotationHelper.withSha256Hash(createPodRecipe()));
579+
return withNonHashedElements(AnnotationHelper.withSha256Hash(createPodRecipe()));
577580
}
578581

579582
// Adds labels and annotations to a pod, skipping any whose names begin with "weblogic."
580-
private V1Pod withPatchableElements(V1Pod pod) {
583+
V1Pod withNonHashedElements(V1Pod pod) {
581584
V1ObjectMeta metadata = pod.getMetadata();
582585
getPodLabels()
583586
.entrySet()

operator/src/main/java/oracle/kubernetes/operator/logging/MessageKeys.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,5 @@ private MessageKeys() {}
150150
public static final String CYCLING_POD = "WLSKO-0145";
151151
public static final String REPLICAS_EXCEEDS_TOTAL_CLUSTER_SERVER_COUNT = "WLSKO-0146";
152152
public static final String SYNC_RETRY = "WLSKO-0147";
153+
public static final String POD_DUMP = "WLSKO-0148";
153154
}

operator/src/main/resources/Operator.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,4 @@ WLSKO-0144=Unable to start domain with domainUID {0} in namespace {1} after {2}
146146
WLSKO-0145=Replacing pod {0} because: {1}
147147
WLSKO-0146=Replica request of {0} exceeds the maximum dynamic server count + server count of {1} configured for cluster {2}
148148
WLSKO-0147=Call {0} has failed with code {1}: message {2}. It has failed {3} times and will be retried up to {4} times.
149+
WLSKO-0148=Current Pod dump [{0}] vs expected pod [{1}].

0 commit comments

Comments
 (0)