Skip to content

Commit 3756bf1

Browse files
authored
Owls 89909 - Fix for repeated introspection after a rolling restart of a MII domain because of image hash mismatch (#2418)
* OWLS-89909 - Fix for repeated introspection runs without any changes.
1 parent beb668a commit 3756bf1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ public NextAction onSuccess(Packet packet, CallResponse<V1ConfigMap> callRespons
328328
return doNext(replaceConfigMap(getNext()), packet);
329329
} else if (mustPatchCurrentMap(existingMap)) {
330330
return doNext(patchCurrentMap(existingMap, getNext()), packet);
331+
} else if (mustPatchImageHashInMap(existingMap, packet)) {
332+
return doNext(patchImageHashInCurrentMap(existingMap, packet, getNext()), packet);
331333
} else {
332334
logConfigMapExists();
333335
recordCurrentMap(packet, existingMap);
@@ -354,6 +356,11 @@ private boolean mustPatchCurrentMap(V1ConfigMap currentMap) {
354356
return KubernetesUtils.isMissingValues(getMapLabels(currentMap), getLabels());
355357
}
356358

359+
private boolean mustPatchImageHashInMap(V1ConfigMap currentMap, Packet packet) {
360+
return (currentMap.getData() != null) && Optional.ofNullable((String)packet.get(DOMAIN_INPUTS_HASH))
361+
.map(hash -> !hash.equals(currentMap.getData().get(DOMAIN_INPUTS_HASH))).orElse(false);
362+
}
363+
357364
private Map<String, String> getMapLabels(@NotNull V1ConfigMap map) {
358365
return Optional.ofNullable(map.getMetadata()).map(V1ObjectMeta::getLabels).orElseGet(Collections::emptyMap);
359366
}
@@ -374,6 +381,17 @@ private Step patchCurrentMap(V1ConfigMap currentMap, Step next) {
374381
new V1Patch(patchBuilder.build().toString()), createPatchResponseStep(next));
375382
}
376383

384+
private Step patchImageHashInCurrentMap(V1ConfigMap currentMap, Packet packet, Step next) {
385+
JsonPatchBuilder patchBuilder = Json.createPatchBuilder();
386+
387+
patchBuilder.add("/data/" + DOMAIN_INPUTS_HASH, (String)packet.get(DOMAIN_INPUTS_HASH));
388+
389+
return new CallBuilder()
390+
.patchConfigMapAsync(name, namespace,
391+
getDomainUidLabel(Optional.of(currentMap).map(V1ConfigMap::getMetadata).orElse(null)),
392+
new V1Patch(patchBuilder.build().toString()), createPatchResponseStep(next));
393+
}
394+
377395
private boolean labelsNotDefined(V1ConfigMap currentMap) {
378396
return Objects.requireNonNull(currentMap.getMetadata()).getLabels() == null;
379397
}
@@ -476,6 +494,7 @@ public NextAction apply(Packet packet) {
476494
if (loader.isTopologyNotValid()) {
477495
return doNext(reportTopologyErrorsAndStop(), packet);
478496
} else if (loader.getDomainConfig() == null) {
497+
loader.updateImageHashInPacket();
479498
return doNext(loader.createIntrospectionVersionUpdateStep(), packet);
480499
} else {
481500
LOGGER.fine(MessageKeys.WLS_CONFIGURATION_READ, timeSinceJobStart(packet), loader.getDomainConfig());
@@ -554,6 +573,10 @@ private void updatePacket() {
554573
copyToPacketAndFileIfPresent(DOMAIN_INPUTS_HASH, getModelInImageSpecHash());
555574
}
556575

576+
private void updateImageHashInPacket() {
577+
copyToPacketAndFileIfPresent(DOMAIN_INPUTS_HASH, getModelInImageSpecHash());
578+
}
579+
557580
private Step createIntrospectionVersionUpdateStep() {
558581
return DomainValidationSteps.createValidateDomainTopologyStep(
559582
createIntrospectorConfigMapContext().patchOnly().verifyConfigMap(conflictStep.getNext()));

0 commit comments

Comments
 (0)