Skip to content

Commit

Permalink
MAINT-2602 Improve logging and exception reporting during upgrade pro…
Browse files Browse the repository at this point in the history
…cess
  • Loading branch information
pgwilliams authored and dmcgihtsdo committed Jul 31, 2024
1 parent a193fd7 commit 4c3eed3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,32 +176,35 @@ public synchronized void upgrade(String id, CodeSystem codeSystem, Integer newDe
logger.info("Rolling back any daily build content before upgrade.");
dailyBuildService.rollbackDailyBuildContent(codeSystem);
}
boolean upgradedSuccessfully = false;
try {
Branch newParentVersionBranch = branchService.findLatest(newParentVersion.getBranchPath());
Date newParentBaseTimepoint = newParentVersionBranch.getBase();
logger.info("Running upgrade of {} to {} version {}.", codeSystem, parentCodeSystem, newDependantVersion);
branchMergeService.rebaseToSpecificTimepointAndRemoveDuplicateContent(parentPath, newParentBaseTimepoint, branchPath, String.format("Upgrading extension to %s@%s.", parentPath, newParentVersion.getVersion()));
logger.info("Completed upgrade of {} to {} version {}.", codeSystem, parentCodeSystem, newDependantVersion);
logger.info("Completed rebase of {} to {} version {}.", codeSystem, parentCodeSystem, newDependantVersion);

if (contentAutomations) {
logger.info("Running upgrade content automations.");
logger.info("Running upgrade content automations on {}.", branchPath);
upgradeInactivationService.findAndUpdateDescriptionsInactivation(codeSystem);
upgradeInactivationService.findAndUpdateLanguageRefsets(codeSystem);
upgradeInactivationService.findAndUpdateAdditionalAxioms(codeSystem);
logger.info("Completed upgrade content automations.");
logger.info("Completed upgrade content automations on {}.", branchPath);
}

logger.info("Running integrity check on {}", branchPath);
logger.info("Running post upgrade integrity check on {}", branchPath);
Branch extensionBranch = branchService.findLatest(branchPath);
IntegrityIssueReport integrityReport = integrityService.findChangedComponentsWithBadIntegrityNotFixed(extensionBranch);
logger.info("Completed integrity check on {}", branchPath);
logger.info("Completed post upgrade integrity check on {}", branchPath);

logger.info("Running post upgrade metadata update on {}", branchPath);
updateBranchMetaData(branchPath, newParentVersion, extensionBranch, integrityReport.isEmpty());
logger.info("Upgrade completed on {}", branchPath);
if (job != null) {
job.setStatus(CodeSystemUpgradeJob.UpgradeStatus.COMPLETED);
}
} catch (ServiceException e) {
upgradedSuccessfully = true;
} catch (Exception e) {
logger.error("Upgrade on {} failed", branchPath, e);
if (job != null) {
job.setStatus(CodeSystemUpgradeJob.UpgradeStatus.FAILED);
job.setErrorMessage(e.getMessage());
Expand All @@ -214,6 +217,8 @@ public synchronized void upgrade(String id, CodeSystem codeSystem, Integer newDe
codeSystem.setDailyBuildAvailable(true);
codeSystemRepository.save(codeSystem);
}

logger.info("Upgrade {} on {}", upgradedSuccessfully?"completed":"unsuccessful", branchPath);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public void findAndUpdateDescriptionsInactivation(CodeSystem codeSystem) {

logger.info("{} descriptions found with inactive concepts but without concept non-current indicators", membersToSave.size());
if (!membersToSave.isEmpty()) {
//TODO What exception does this throw if we are unable to lock the branch?
try (Commit commit = branchService.openCommit(branchPath, branchMetadataHelper.getBranchLockMetadata("Concept non-current description inactivation"))) {
conceptUpdateHelper.doSaveBatchComponents(membersToSave, ReferenceSetMember.class, commit);
logger.info("Added {} concept non-current indicators for descriptions having inactive concepts. Member uuids: {}",
Expand Down

0 comments on commit 4c3eed3

Please sign in to comment.