Skip to content

Commit

Permalink
Owls 89909 - Fix for repeated introspection after a rolling restart o…
Browse files Browse the repository at this point in the history
…f a MII domain because of image hash mismatch (#2418)

* OWLS-89909 - Fix for repeated introspection runs without any changes.
  • Loading branch information
ankedia authored Jun 21, 2021
1 parent beb668a commit 3756bf1
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ public NextAction onSuccess(Packet packet, CallResponse<V1ConfigMap> callRespons
return doNext(replaceConfigMap(getNext()), packet);
} else if (mustPatchCurrentMap(existingMap)) {
return doNext(patchCurrentMap(existingMap, getNext()), packet);
} else if (mustPatchImageHashInMap(existingMap, packet)) {
return doNext(patchImageHashInCurrentMap(existingMap, packet, getNext()), packet);
} else {
logConfigMapExists();
recordCurrentMap(packet, existingMap);
Expand All @@ -354,6 +356,11 @@ private boolean mustPatchCurrentMap(V1ConfigMap currentMap) {
return KubernetesUtils.isMissingValues(getMapLabels(currentMap), getLabels());
}

private boolean mustPatchImageHashInMap(V1ConfigMap currentMap, Packet packet) {
return (currentMap.getData() != null) && Optional.ofNullable((String)packet.get(DOMAIN_INPUTS_HASH))
.map(hash -> !hash.equals(currentMap.getData().get(DOMAIN_INPUTS_HASH))).orElse(false);
}

private Map<String, String> getMapLabels(@NotNull V1ConfigMap map) {
return Optional.ofNullable(map.getMetadata()).map(V1ObjectMeta::getLabels).orElseGet(Collections::emptyMap);
}
Expand All @@ -374,6 +381,17 @@ private Step patchCurrentMap(V1ConfigMap currentMap, Step next) {
new V1Patch(patchBuilder.build().toString()), createPatchResponseStep(next));
}

private Step patchImageHashInCurrentMap(V1ConfigMap currentMap, Packet packet, Step next) {
JsonPatchBuilder patchBuilder = Json.createPatchBuilder();

patchBuilder.add("/data/" + DOMAIN_INPUTS_HASH, (String)packet.get(DOMAIN_INPUTS_HASH));

return new CallBuilder()
.patchConfigMapAsync(name, namespace,
getDomainUidLabel(Optional.of(currentMap).map(V1ConfigMap::getMetadata).orElse(null)),
new V1Patch(patchBuilder.build().toString()), createPatchResponseStep(next));
}

private boolean labelsNotDefined(V1ConfigMap currentMap) {
return Objects.requireNonNull(currentMap.getMetadata()).getLabels() == null;
}
Expand Down Expand Up @@ -476,6 +494,7 @@ public NextAction apply(Packet packet) {
if (loader.isTopologyNotValid()) {
return doNext(reportTopologyErrorsAndStop(), packet);
} else if (loader.getDomainConfig() == null) {
loader.updateImageHashInPacket();
return doNext(loader.createIntrospectionVersionUpdateStep(), packet);
} else {
LOGGER.fine(MessageKeys.WLS_CONFIGURATION_READ, timeSinceJobStart(packet), loader.getDomainConfig());
Expand Down Expand Up @@ -554,6 +573,10 @@ private void updatePacket() {
copyToPacketAndFileIfPresent(DOMAIN_INPUTS_HASH, getModelInImageSpecHash());
}

private void updateImageHashInPacket() {
copyToPacketAndFileIfPresent(DOMAIN_INPUTS_HASH, getModelInImageSpecHash());
}

private Step createIntrospectionVersionUpdateStep() {
return DomainValidationSteps.createValidateDomainTopologyStep(
createIntrospectorConfigMapContext().patchOnly().verifyConfigMap(conflictStep.getNext()));
Expand Down

0 comments on commit 3756bf1

Please sign in to comment.