Skip to content

Commit

Permalink
use tenants as guidance for task progress count length
Browse files Browse the repository at this point in the history
  • Loading branch information
rlindner81 committed Apr 24, 2024
1 parent 466c66c commit d42b591
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/submodules/capMultitenancy.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ const _cdsUpgrade = async (
body: JSON.stringify({ tenants, ...(doAutoUndeploy && autoUndeployOptions) }),
});
const upgradeResponseData = await _safeMaterializeJson(upgradeResponse, "upgrade");
const upgradeTenantEntries = upgradeResponseData.tenants && Object.entries(upgradeResponseData.tenants);
assert(upgradeTenantEntries, "no tenants found in response for upgrade\n%j", upgradeResponseData);
const jobId = isMtxs ? upgradeResponseData.ID : upgradeResponseData.jobID;
console.log("started upgrade on server with jobId %s polling interval %isec", jobId, POLL_FREQUENCY / 1000);

Expand All @@ -226,8 +228,9 @@ const _cdsUpgrade = async (
console.log("polled status %s for jobId %s", status, jobId);
if (isMtxs) {
const taskSummary = _getTaskSummary(tasks ?? []);
const [queued, running, failed, finished] = taskSummary;
console.log("task progress is queued/running: %i/%i | failed/finished: %i/%i", queued, running, failed, finished);
const countLength = String(upgradeTenantEntries.length - 1).length;
const [queued, running, failed, finished] = taskSummary.map((count) => String(count).padStart(countLength, "0"));
console.log("task progress is queued/running: %s/%s | failed/finished: %s/%s", queued, running, failed, finished);
if (!lastTaskSummary || lastTaskSummary.some((index, value) => taskSummary[index] !== value)) {
const currentTime = Date.now();
if (currentTime - (lastTimeOfChange ?? currentTime) >= CDS_CHANGE_TIMEOUT) {
Expand All @@ -244,8 +247,6 @@ const _cdsUpgrade = async (
}

if (isMtxs) {
const tenants = upgradeResponseData.tenants;
assert(tenants, "no tenants found in response for upgrade\n%j", upgradeResponseData);
const { tasks } = pollJobResponseData || {};
const taskMap = (tasks ?? []).reduce((accumulator, task) => {
const { ID } = task;
Expand All @@ -254,7 +255,7 @@ const _cdsUpgrade = async (
}, {});
let hasError = false;
const table = [["tenantId", "status", "message"]].concat(
Object.entries(tenants).map(([tenantId, { ID: taskId }]) => {
upgradeTenantEntries.map(([tenantId, { ID: taskId }]) => {
const { status, error } = taskMap[taskId];
hasError |= !status || error;
return [tenantId, status, error || ""];
Expand Down

0 comments on commit d42b591

Please sign in to comment.