Merge pull request 'Run multi-target commands in parallel' (#75) from parallel-targets into main
CI / UI screenshots (before/after) (push) Skipped
CI / Test (jest) (push) Successful in 20s
CI / Lint (eslint) (push) Successful in 29s
CI / Security (npm audit) (push) Successful in 15s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m1s
CI / Integration (api) (push) Successful in 2m50s
CI / UI (playwright) (push) Successful in 1m56s
CI / Deploy (push) Successful in 14s
CI / Deploy worker (push) Successful in 8s
CI / Notify (push) Successful in 3s
CI / UI screenshots (before/after) (push) Skipped
CI / Test (jest) (push) Successful in 20s
CI / Lint (eslint) (push) Successful in 29s
CI / Security (npm audit) (push) Successful in 15s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m1s
CI / Integration (api) (push) Successful in 2m50s
CI / UI (playwright) (push) Successful in 1m56s
CI / Deploy (push) Successful in 14s
CI / Deploy worker (push) Successful in 8s
CI / Notify (push) Successful in 3s
This commit was merged in pull request #75.
This commit is contained in:
commit
a945cd80d3
4 files changed
+63
-33
No files matched your search
@@ -1263,13 +1263,17 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Execute command on each target worker and wait for results
|
||||
const results = [];
|
||||
let sentCount = 0;
|
||||
// Per-step timeout override: step.timeout (seconds) overrides global default
|
||||
const stepTimeoutMs = step.timeout
|
||||
? Math.min(Math.max(parseInt(step.timeout, 10) * 1000, 5000), 600000)
|
||||
: COMMAND_TIMEOUT_MS;
|
||||
// Per-step retry: step.retries (default 0) with step.retryDelayMs (default 2000)
|
||||
const maxRetries = Math.min(parseInt(step.retries || 0, 10), 5);
|
||||
const retryDelayMs = Math.min(parseInt(step.retryDelayMs || 2000, 10), 30000);
|
||||
|
||||
for (const workerId of targetWorkerIds) {
|
||||
// Runs the command on one worker (with retries): { sent, success }.
|
||||
const runOnWorker = async (workerId) => {
|
||||
const workerWs = workers.get(workerId);
|
||||
|
||||
if (!workerWs || workerWs.readyState !== WebSocket.OPEN) {
|
||||
await addExecutionLog(executionId, {
|
||||
step: stepNumber,
|
||||
@@ -1277,13 +1281,10 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
|
||||
worker_id: workerId,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
continue;
|
||||
return { sent: false, success: false };
|
||||
}
|
||||
sentCount++;
|
||||
|
||||
// Send command to worker
|
||||
let commandId = crypto.randomUUID();
|
||||
|
||||
await addExecutionLog(executionId, {
|
||||
step: stepNumber,
|
||||
action: 'command_sent',
|
||||
@@ -1292,12 +1293,6 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
|
||||
command_id: commandId,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
|
||||
// Per-step timeout override: step.timeout (seconds) overrides global default
|
||||
const stepTimeoutMs = step.timeout
|
||||
? Math.min(Math.max(parseInt(step.timeout, 10) * 1000, 5000), 600000)
|
||||
: COMMAND_TIMEOUT_MS;
|
||||
|
||||
sendCommandToWorker(workerWs, {
|
||||
type: 'execute_command',
|
||||
execution_id: executionId,
|
||||
@@ -1307,10 +1302,6 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
|
||||
timeout: stepTimeoutMs
|
||||
});
|
||||
|
||||
// Per-step retry: step.retries (default 0) with step.retryDelayMs (default 2000)
|
||||
const maxRetries = Math.min(parseInt(step.retries || 0, 10), 5);
|
||||
const retryDelayMs = Math.min(parseInt(step.retryDelayMs || 2000, 10), 30000);
|
||||
|
||||
let result;
|
||||
let attempt = 0;
|
||||
while (true) {
|
||||
@@ -1340,13 +1331,25 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
|
||||
});
|
||||
commandId = retryCommandId; // update for next waitForCommandResult call
|
||||
}
|
||||
results.push(result);
|
||||
return { sent: true, success: !!result.success };
|
||||
};
|
||||
|
||||
if (!result.success) {
|
||||
// Command failed after all retries, workflow should stop
|
||||
return false;
|
||||
// All targets at once (#26), so one slow or hung worker doesn't hold up the
|
||||
// rest. `parallel: false` keeps the old one-at-a-time order for rolling changes,
|
||||
// stopping at the first failure.
|
||||
let outcomes;
|
||||
if (step.parallel === false) {
|
||||
outcomes = [];
|
||||
for (const workerId of targetWorkerIds) {
|
||||
const o = await runOnWorker(workerId);
|
||||
outcomes.push(o);
|
||||
if (o.sent && !o.success) return false;
|
||||
}
|
||||
} else {
|
||||
outcomes = await Promise.all(targetWorkerIds.map(runOnWorker));
|
||||
if (outcomes.some(o => o.sent && !o.success)) return false;
|
||||
}
|
||||
const sentCount = outcomes.filter(o => o.sent).length;
|
||||
|
||||
// If every target worker was offline, treat as step failure
|
||||
if (sentCount === 0) {
|
||||
|
||||
Reference in new issue
Block a user