Skip to content

Owls 89909 - Fix for repeated introspection after a rolling restart of a MII domain because of image hash mismatch #2418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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