grada-run 0.41.5 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +18 -8
- package/package.json +1 -1
- package/src/commands/add.js +93 -11
- package/src/commands/alerts.js +69 -31
- package/src/commands/apply.js +62 -10
- package/src/commands/db/backup.js +1 -2
- package/src/commands/db/connect.js +27 -14
- package/src/commands/db/enable-vector.js +19 -6
- package/src/commands/db/import.js +114 -22
- package/src/commands/db/migrate.js +77 -73
- package/src/commands/db/restore.js +38 -6
- package/src/commands/destroy.js +68 -6
- package/src/commands/diagnose.js +57 -32
- package/src/commands/doctor.js +5 -3
- package/src/commands/domain.js +55 -7
- package/src/commands/drift.js +2 -1
- package/src/commands/eject.js +13 -2
- package/src/commands/exec.js +9 -4
- package/src/commands/gc.js +135 -6
- package/src/commands/init.js +75 -9
- package/src/commands/logs.js +127 -38
- package/src/commands/mcp.js +3 -2
- package/src/commands/rollback.js +230 -74
- package/src/commands/secrets.js +251 -61
- package/src/commands/status.js +17 -8
- package/src/commands/sync-ai.js +4 -3
- package/src/commands/wake.js +45 -1
- package/src/data/action-pins.js +26 -0
- package/src/utils/addons.js +9 -6
- package/src/utils/ai-rules.js +3 -2
- package/src/utils/backup.js +16 -2
- package/src/utils/command.js +20 -0
- package/src/utils/db-tunnel.js +15 -5
- package/src/utils/detector.js +8 -0
- package/src/utils/ecs-runner.js +16 -3
- package/src/utils/frameworks.js +14 -2
- package/src/utils/generator.js +33 -16
- package/src/utils/prompts.js +20 -4
- package/src/utils/resolvers.js +74 -11
- package/src/utils/revision-discovery.js +19 -7
- package/templates/docker/nestjs.Dockerfile +2 -2
- package/templates/docker/nextjs.Dockerfile +3 -3
- package/templates/docker/node.Dockerfile +2 -2
- package/templates/docker/nuxt.Dockerfile +2 -2
- package/templates/docker/static.Dockerfile +1 -1
- package/templates/docker/svelte.Dockerfile +2 -2
- package/templates/github/deploy-lambda.yml +73 -11
- package/templates/github/deploy-static.yml +4 -3
- package/templates/github/deploy.yml +114 -12
- package/templates/github/drift.yml +74 -5
- package/templates/github/preview-lambda.yml +143 -13
- package/templates/github/preview.yml +141 -13
- package/templates/github/teardown.yml +77 -12
- package/templates/terraform/addons/bedrock.tf +6 -2
- package/templates/terraform/addons/s3.tf +33 -0
- package/templates/terraform/backend.tf +7 -0
- package/templates/terraform/cloudfront-lambda.tf +125 -6
- package/templates/terraform/cloudfront.tf +137 -10
- package/templates/terraform/database-mysql.tf +5 -1
- package/templates/terraform/database.tf +5 -1
- package/templates/terraform/main.tf +36 -1
- package/templates/terraform/network.tf +5 -2
- package/templates/terraform/oidc.tf +3 -2
- package/templates/terraform/secrets.tf +6 -4
- package/templates/terraform/worker.tf +7 -0
package/src/commands/rollback.js
CHANGED
|
@@ -6,12 +6,13 @@ import {
|
|
|
6
6
|
UpdateServiceCommand,
|
|
7
7
|
} from '@aws-sdk/client-ecs';
|
|
8
8
|
import color from 'picocolors';
|
|
9
|
+
import path from 'path';
|
|
9
10
|
import { intro, outro, spinner, select, isCancel } from '@clack/prompts';
|
|
10
11
|
import { trackEvent, flushTelemetry, trackSuccess, trackFailure, setActiveCommandName, resetActiveCommandName } from '../core/telemetry.js';
|
|
11
12
|
import { failCommand, failAwsError, failProjectNotInitialized, refuseIfNonInteractive, refuseUnknownFlags } from '../utils/command.js';
|
|
12
13
|
import { parseFlags, normalizeOptions, normalizeArgv } from '../utils/args.js';
|
|
13
14
|
import { isAuthError, handleAwsAuthError, resolveClient } from '../utils/aws.js';
|
|
14
|
-
import { resolveRegion, resolveProjectName, resolveCluster, resolveService, readFileSafe,
|
|
15
|
+
import { resolveRegion, resolveProjectName, resolveCluster, resolveService, readFileSafe, withWorkspaceNamespace, resolveCwd, guardComputeTarget, readResourceSuffix } from '../utils/resolvers.js';
|
|
15
16
|
import { requireManagedTree } from '../utils/terraform-metadata.js';
|
|
16
17
|
import { truncateSpinnerText } from '../utils/spinner-text.js';
|
|
17
18
|
import { guardSleepingEnv, resolveSleepTarget } from '../utils/sleep-state.js';
|
|
@@ -82,6 +83,7 @@ async function runRollbackMain(input = {}) {
|
|
|
82
83
|
let projectName;
|
|
83
84
|
let cluster;
|
|
84
85
|
let service;
|
|
86
|
+
let namespacedProject;
|
|
85
87
|
try {
|
|
86
88
|
cwd = resolveCwd(options);
|
|
87
89
|
region = resolveRegion(options, cwd);
|
|
@@ -89,8 +91,8 @@ async function runRollbackMain(input = {}) {
|
|
|
89
91
|
|
|
90
92
|
// Namespace cluster/service for PR-preview workspaces; explicit
|
|
91
93
|
// --cluster/--service flags still win inside the resolvers.
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
+
const namespacedOptions = withWorkspaceNamespace(options, cwd);
|
|
95
|
+
namespacedProject = namespacedOptions.projectName;
|
|
94
96
|
cluster = resolveCluster(namespacedOptions, cwd);
|
|
95
97
|
service = resolveService(namespacedOptions, cwd);
|
|
96
98
|
} catch {
|
|
@@ -175,6 +177,9 @@ async function runRollbackMain(input = {}) {
|
|
|
175
177
|
|
|
176
178
|
let targetTaskDefArn;
|
|
177
179
|
let targetRevisionNum;
|
|
180
|
+
// Case A only: the requested web revision's image, for worker
|
|
181
|
+
// pairing (BUG-153). Null in Case B and when undescribable.
|
|
182
|
+
let requestedWebImage = null;
|
|
178
183
|
|
|
179
184
|
if (options.revision !== undefined && options.revision !== null && String(options.revision).trim() !== '') {
|
|
180
185
|
// Case A: explicit revision.
|
|
@@ -231,6 +236,22 @@ async function runRollbackMain(input = {}) {
|
|
|
231
236
|
exitCode: 1,
|
|
232
237
|
});
|
|
233
238
|
}
|
|
239
|
+
// BUG-127: a NEWER explicit revision would silently
|
|
240
|
+
// roll FORWARD — rollback only moves to older revisions.
|
|
241
|
+
if (Number.isInteger(Number(targetRevisionNum)) && Number.isInteger(currentRevNum)
|
|
242
|
+
&& Number(targetRevisionNum) > currentRevNum) {
|
|
243
|
+
s.stop(color.red('Revision is newer than deployed.'));
|
|
244
|
+
return failCommand({
|
|
245
|
+
message: `\n✖ Revision ${targetRevisionNum} is newer than the deployed revision ${currentRevNum} — rollback only moves to older revisions.`,
|
|
246
|
+
hint: ' Deploy again to move forward, or request a revision older than the deployed one.\n',
|
|
247
|
+
event: 'rollback_run',
|
|
248
|
+
telemetry: { projectName, error_code: 'NEWER_REVISION_REQUESTED' },
|
|
249
|
+
reason: 'rollback-newer-revision',
|
|
250
|
+
resultExtra: { cluster, service, region },
|
|
251
|
+
exitCode: 1,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
requestedWebImage = descResp.taskDefinition.containerDefinitions?.[0]?.image ?? null;
|
|
234
255
|
s.stop(`Resolved revision ${targetRevisionNum}.`);
|
|
235
256
|
} else {
|
|
236
257
|
// Case B: discover eligible older revisions via the shared seam.
|
|
@@ -301,48 +322,194 @@ async function runRollbackMain(input = {}) {
|
|
|
301
322
|
}
|
|
302
323
|
}
|
|
303
324
|
|
|
325
|
+
// 1b. Worker rollback (BUG-85): deploys advance web AND worker,
|
|
326
|
+
// so a rollback must move both — otherwise the worker keeps the bad
|
|
327
|
+
// image. Explicit --service keeps single-service semantics (the
|
|
328
|
+
// escape hatch); workerless trees (no worker.tf) skip. Resolved
|
|
329
|
+
// BEFORE any update so a worker with no rollback history fails
|
|
330
|
+
// loud with zero half-state.
|
|
331
|
+
let workerTarget = null;
|
|
332
|
+
const explicitService = (typeof options.service === 'string' && options.service.trim() !== '')
|
|
333
|
+
|| (typeof options.serviceName === 'string' && options.serviceName.trim() !== '');
|
|
334
|
+
if (!explicitService && readFileSafe(path.join(cwd, 'terraform', 'worker.tf')) !== null) {
|
|
335
|
+
const workerService = `${namespacedProject}${readResourceSuffix(cwd)}-worker-service`;
|
|
336
|
+
const workerResp = await ecsClient.send(new DescribeServicesCommand({ cluster, services: [workerService] }));
|
|
337
|
+
const workerDesc = (workerResp.services || [])[0] || null;
|
|
338
|
+
if (!workerDesc || workerDesc.status !== 'ACTIVE') {
|
|
339
|
+
console.log(color.yellow(`⚠ Worker service ${workerService} not found or inactive — rolling back ${service} only.`));
|
|
340
|
+
} else {
|
|
341
|
+
const { family: workerFamily, revNum: workerCurrentRev } = parseFamilyAndRevision(workerDesc.taskDefinition);
|
|
342
|
+
const workerEligible = await discoverWithAdapter(createEcsRevisionAdapter(ecsClient), workerFamily, workerCurrentRev);
|
|
343
|
+
if (workerEligible.length === 0) {
|
|
344
|
+
s.stop(color.yellow('No previous worker revisions.'));
|
|
345
|
+
return failCommand({
|
|
346
|
+
message: `\n⚠ Family ${workerFamily} is on revision ${workerCurrentRev} with no previous ACTIVE revisions — refusing to roll back ${service} alone (the worker would keep the bad image).\n Deploy again to create worker rollback history, or re-run with --service ${service} to roll back the web service only.\n`,
|
|
347
|
+
tone: 'yellow',
|
|
348
|
+
event: 'rollback_run',
|
|
349
|
+
telemetry: { projectName, error_code: 'WORKER_NO_PRIOR_REVISIONS' },
|
|
350
|
+
reason: 'worker-no-prior-revisions',
|
|
351
|
+
resultExtra: { cluster, service, region },
|
|
352
|
+
exitCode: 1,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
// BUG-153: in Case A the worker target pairs with the
|
|
356
|
+
// REQUESTED web image (deploys pin both to the same SHA) —
|
|
357
|
+
// newest-previous regardless would skew the pairing. When
|
|
358
|
+
// no eligible worker revision carries the web image, fall
|
|
359
|
+
// back to newest-previous, loudly when both images are
|
|
360
|
+
// known and differ. Case B (newest-previous web) keeps
|
|
361
|
+
// newest-previous worker: paired by construction.
|
|
362
|
+
let workerTargetArn = pickNewestEligible(workerEligible);
|
|
363
|
+
let workerImageMatched = null;
|
|
364
|
+
if (requestedWebImage) {
|
|
365
|
+
const settled = await Promise.allSettled(
|
|
366
|
+
workerEligible.map((workerArn) => ecsClient.send(new DescribeTaskDefinitionCommand({ taskDefinition: workerArn })))
|
|
367
|
+
);
|
|
368
|
+
const withImages = workerEligible.map((workerArn, index) => ({
|
|
369
|
+
workerArn,
|
|
370
|
+
image: settled[index].status === 'fulfilled'
|
|
371
|
+
? settled[index].value?.taskDefinition?.containerDefinitions?.[0]?.image ?? null
|
|
372
|
+
: null,
|
|
373
|
+
}));
|
|
374
|
+
const match = withImages.find((entry) => entry.image === requestedWebImage);
|
|
375
|
+
if (match) {
|
|
376
|
+
workerTargetArn = match.workerArn;
|
|
377
|
+
workerImageMatched = true;
|
|
378
|
+
} else {
|
|
379
|
+
workerImageMatched = false;
|
|
380
|
+
const newestImage = withImages[0]?.image ?? null;
|
|
381
|
+
if (newestImage && newestImage !== requestedWebImage) {
|
|
382
|
+
console.log(color.yellow(`⚠ No worker revision carries the requested web image ${requestedWebImage} — rolling the worker back to newest-previous (${newestImage}) instead. Web and worker will run different images.`));
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
workerTarget = { service: workerService, taskDefArn: workerTargetArn, revision: workerTargetArn.split(':').pop(), imageMatched: workerImageMatched };
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
304
390
|
// 2. Trigger the rollback.
|
|
305
|
-
|
|
391
|
+
const triggerLabel = workerTarget
|
|
392
|
+
? `${service} to revision ${targetRevisionNum} and ${workerTarget.service} to revision ${workerTarget.revision}`
|
|
393
|
+
: `${service} to revision ${targetRevisionNum}`;
|
|
394
|
+
s.start(truncateSpinnerText(`Rolling back ${triggerLabel}...`));
|
|
306
395
|
await ecsClient.send(new UpdateServiceCommand({
|
|
307
396
|
cluster,
|
|
308
397
|
service,
|
|
309
398
|
taskDefinition: targetTaskDefArn,
|
|
310
399
|
forceNewDeployment: true,
|
|
311
400
|
}));
|
|
401
|
+
if (workerTarget) {
|
|
402
|
+
await ecsClient.send(new UpdateServiceCommand({
|
|
403
|
+
cluster,
|
|
404
|
+
service: workerTarget.service,
|
|
405
|
+
taskDefinition: workerTarget.taskDefArn,
|
|
406
|
+
forceNewDeployment: true,
|
|
407
|
+
}));
|
|
408
|
+
}
|
|
312
409
|
|
|
313
|
-
if (options.skipWait === true) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
410
|
+
if (options.skipWait === true || options.skipWait === 'true') {
|
|
411
|
+
const skipLabel = workerTarget
|
|
412
|
+
? `revision ${targetRevisionNum} (web) and ${workerTarget.revision} (worker)`
|
|
413
|
+
: `revision ${targetRevisionNum}`;
|
|
414
|
+
s.stop(`Rollback to ${skipLabel} triggered.`);
|
|
415
|
+
await trackSuccess('rollback_run', {
|
|
416
|
+
projectName,
|
|
417
|
+
targetRevision: String(targetRevisionNum),
|
|
418
|
+
skipWait: true,
|
|
419
|
+
...(workerTarget ? { workerTargetRevision: String(workerTarget.revision), workerImageMatched: workerTarget.imageMatched ?? undefined } : {}),
|
|
420
|
+
});
|
|
421
|
+
outro(color.green(`Rollback to ${skipLabel} initiated! 🚀`));
|
|
422
|
+
return {
|
|
423
|
+
ok: true, targetTaskDefArn, targetRevision: targetRevisionNum, cluster, service, region,
|
|
424
|
+
...(workerTarget ? { worker: { service: workerTarget.service, targetTaskDefArn: workerTarget.taskDefArn, targetRevision: workerTarget.revision } } : {}),
|
|
425
|
+
};
|
|
318
426
|
}
|
|
319
427
|
|
|
320
|
-
// 3. Monitor
|
|
321
|
-
// with live spinner updates on every non-terminal tick.
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
return { ok: true, targetTaskDefArn, targetRevision: targetRevisionNum, cluster, service, region };
|
|
339
|
-
}
|
|
428
|
+
// 3. Monitor each deployment until it stabilizes or times out,
|
|
429
|
+
// with live spinner updates on every non-terminal tick. Web
|
|
430
|
+
// first, then the worker; a worker failure names the completed
|
|
431
|
+
// web rollback so the half-state is never a mystery.
|
|
432
|
+
const webWait = await waitForPrimaryStable({
|
|
433
|
+
s, ecsClient, cluster, service, targetTaskDefArn, targetRevisionNum,
|
|
434
|
+
pollIntervalMs, timeoutMs, projectName, region,
|
|
435
|
+
});
|
|
436
|
+
if (!webWait.ok) return webWait.failure;
|
|
437
|
+
if (workerTarget) {
|
|
438
|
+
const workerWait = await waitForPrimaryStable({
|
|
439
|
+
s, ecsClient, cluster, service: workerTarget.service,
|
|
440
|
+
targetTaskDefArn: workerTarget.taskDefArn, targetRevisionNum: workerTarget.revision,
|
|
441
|
+
pollIntervalMs, timeoutMs, projectName, region,
|
|
442
|
+
doneNote: `${service} already rolled back to revision ${targetRevisionNum}`,
|
|
443
|
+
});
|
|
444
|
+
if (!workerWait.ok) return workerWait.failure;
|
|
445
|
+
}
|
|
340
446
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
447
|
+
const doneLabel = workerTarget
|
|
448
|
+
? `revision ${targetRevisionNum} (web) and ${workerTarget.revision} (worker)`
|
|
449
|
+
: `revision ${targetRevisionNum}`;
|
|
450
|
+
s.stop(color.green(`Rolled back to ${doneLabel}.`));
|
|
451
|
+
await trackSuccess('rollback_run', {
|
|
452
|
+
projectName,
|
|
453
|
+
targetRevision: String(targetRevisionNum),
|
|
454
|
+
...(workerTarget ? { workerTargetRevision: String(workerTarget.revision), workerImageMatched: workerTarget.imageMatched ?? undefined } : {}),
|
|
455
|
+
});
|
|
456
|
+
outro(color.green(workerTarget
|
|
457
|
+
? `Services successfully rolled back to ${doneLabel}! 🚀`
|
|
458
|
+
: `Service successfully rolled back to revision ${targetRevisionNum}! 🚀`));
|
|
459
|
+
return {
|
|
460
|
+
ok: true, targetTaskDefArn, targetRevision: targetRevisionNum, cluster, service, region,
|
|
461
|
+
...(workerTarget ? { worker: { service: workerTarget.service, targetTaskDefArn: workerTarget.taskDefArn, targetRevision: workerTarget.revision } } : {}),
|
|
462
|
+
};
|
|
463
|
+
} catch (error) {
|
|
464
|
+
if (isAuthError(error)) {
|
|
465
|
+
await trackFailure('rollback_run', { projectName, error_code: 'AUTH_EXPIRED' });
|
|
466
|
+
handleAwsAuthError(error, s, options);
|
|
467
|
+
return { ok: false, reason: 'auth-error', cluster, service, region };
|
|
468
|
+
}
|
|
469
|
+
s.stop(color.red('❌ Rollback failed.'));
|
|
470
|
+
return failAwsError({
|
|
471
|
+
event: 'rollback_run',
|
|
472
|
+
error,
|
|
473
|
+
telemetry: { projectName },
|
|
474
|
+
reason: 'error',
|
|
475
|
+
resultExtra: { cluster, service, region },
|
|
476
|
+
exitCode: 1,
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// Polls one service until its PRIMARY deployment settles on the target
|
|
482
|
+
// revision (or fails/times out). Shared by the web and worker waits;
|
|
483
|
+
// `doneNote` names already-completed work on the failure prints so a
|
|
484
|
+
// late worker failure never hides the finished web rollback.
|
|
485
|
+
async function waitForPrimaryStable({
|
|
486
|
+
s, ecsClient, cluster, service, targetTaskDefArn, targetRevisionNum,
|
|
487
|
+
pollIntervalMs, timeoutMs, projectName, region, doneNote = null,
|
|
488
|
+
}) {
|
|
489
|
+
const startTime = Date.now();
|
|
490
|
+
const deadline = startTime + timeoutMs;
|
|
491
|
+
while (true) {
|
|
492
|
+
const pollResp = await ecsClient.send(new DescribeServicesCommand({ cluster, services: [service] }));
|
|
493
|
+
const svc = (pollResp.services || [])[0] || null;
|
|
494
|
+
const primary = svc?.deployments?.find(
|
|
495
|
+
(d) => d.status === 'PRIMARY' && d.taskDefinition === targetTaskDefArn
|
|
496
|
+
);
|
|
497
|
+
|
|
498
|
+
if (primary && (primary.rolloutState === 'COMPLETED'
|
|
499
|
+
|| (primary.runningCount === primary.desiredCount
|
|
500
|
+
&& primary.desiredCount > 0
|
|
501
|
+
&& (svc.deployments || []).length === 1))) {
|
|
502
|
+
return { ok: true };
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
if (primary?.rolloutState === 'FAILED') {
|
|
506
|
+
s.stop(color.red('❌ Rollback deployment failed.'));
|
|
507
|
+
return {
|
|
508
|
+
ok: false,
|
|
509
|
+
failure: await failCommand({
|
|
344
510
|
print: () => {
|
|
345
511
|
console.log(color.red('\n✖ The rollback deployment failed to stabilize.'));
|
|
512
|
+
if (doneNote) console.log(color.yellow(` Note: ${doneNote}.`));
|
|
346
513
|
console.log(` Check service health with ${color.green('npx grada-run status')} and recent output with ${color.green('npx grada-run logs')}.\n`);
|
|
347
514
|
},
|
|
348
515
|
event: 'rollback_run',
|
|
@@ -350,35 +517,39 @@ async function runRollbackMain(input = {}) {
|
|
|
350
517
|
reason: 'rollout-failed',
|
|
351
518
|
resultExtra: { cluster, service, region },
|
|
352
519
|
exitCode: 1,
|
|
353
|
-
})
|
|
354
|
-
}
|
|
520
|
+
}),
|
|
521
|
+
};
|
|
522
|
+
}
|
|
355
523
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
524
|
+
const elapsedSec = Math.floor((Date.now() - startTime) / 1000);
|
|
525
|
+
// Every poll frame goes through the width budget: the
|
|
526
|
+
// crashing-container variant walls past 131 columns on long
|
|
527
|
+
// service names without it.
|
|
528
|
+
const progressStem = `Rolling back ${service} to revision ${targetRevisionNum}... [${elapsedSec}s]`;
|
|
529
|
+
if (!primary) {
|
|
530
|
+
s.message(truncateSpinnerText(`${progressStem} (registering deployment...)`));
|
|
531
|
+
} else {
|
|
532
|
+
const runningCount = primary.runningCount ?? 0;
|
|
533
|
+
const desiredCount = primary.desiredCount ?? 0;
|
|
534
|
+
const pendingCount = primary.pendingCount ?? 0;
|
|
535
|
+
const failedTasks = primary.failedTasks ?? 0;
|
|
536
|
+
if (failedTasks > 0) {
|
|
537
|
+
s.message(truncateSpinnerText(`${progressStem} (${runningCount}/${desiredCount} running, ${pendingCount} pending, ${failedTasks} failed ⚠️ — container crashing)`));
|
|
538
|
+
} else if (runningCount >= desiredCount && desiredCount > 0 && pendingCount === 0) {
|
|
539
|
+
s.message(truncateSpinnerText(`${progressStem} (${runningCount}/${desiredCount} running — draining previous tasks)`));
|
|
363
540
|
} else {
|
|
364
|
-
|
|
365
|
-
const desiredCount = primary.desiredCount ?? 0;
|
|
366
|
-
const pendingCount = primary.pendingCount ?? 0;
|
|
367
|
-
const failedTasks = primary.failedTasks ?? 0;
|
|
368
|
-
if (failedTasks > 0) {
|
|
369
|
-
s.message(truncateSpinnerText(`${progressStem} (${runningCount}/${desiredCount} running, ${pendingCount} pending, ${failedTasks} failed ⚠️ — container crashing)`));
|
|
370
|
-
} else if (runningCount >= desiredCount && desiredCount > 0 && pendingCount === 0) {
|
|
371
|
-
s.message(truncateSpinnerText(`${progressStem} (${runningCount}/${desiredCount} running — draining previous tasks)`));
|
|
372
|
-
} else {
|
|
373
|
-
s.message(truncateSpinnerText(`${progressStem} (${runningCount}/${desiredCount} running, ${pendingCount} pending)`));
|
|
374
|
-
}
|
|
541
|
+
s.message(truncateSpinnerText(`${progressStem} (${runningCount}/${desiredCount} running, ${pendingCount} pending)`));
|
|
375
542
|
}
|
|
543
|
+
}
|
|
376
544
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
545
|
+
if (Date.now() >= deadline) {
|
|
546
|
+
s.stop(color.yellow('⚠ Rollback timed out waiting for ECS stabilization.'));
|
|
547
|
+
return {
|
|
548
|
+
ok: false,
|
|
549
|
+
failure: await failCommand({
|
|
380
550
|
print: () => {
|
|
381
551
|
console.log(color.yellow('\n⚠ The rollback is still in progress.'));
|
|
552
|
+
if (doneNote) console.log(color.yellow(` Note: ${doneNote}.`));
|
|
382
553
|
console.log(` Check progress with ${color.green('npx grada-run status')}.\n`);
|
|
383
554
|
},
|
|
384
555
|
event: 'rollback_run',
|
|
@@ -386,26 +557,11 @@ async function runRollbackMain(input = {}) {
|
|
|
386
557
|
reason: 'rollout-timeout',
|
|
387
558
|
resultExtra: { cluster, service, region },
|
|
388
559
|
exitCode: 1,
|
|
389
|
-
})
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
await sleep(pollIntervalMs);
|
|
560
|
+
}),
|
|
561
|
+
};
|
|
393
562
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
await trackFailure('rollback_run', { projectName, error_code: 'AUTH_EXPIRED' });
|
|
397
|
-
handleAwsAuthError(error, s, options);
|
|
398
|
-
return { ok: false, reason: 'auth-error', cluster, service, region };
|
|
399
|
-
}
|
|
400
|
-
s.stop(color.red('❌ Rollback failed.'));
|
|
401
|
-
return failAwsError({
|
|
402
|
-
event: 'rollback_run',
|
|
403
|
-
error,
|
|
404
|
-
telemetry: { projectName },
|
|
405
|
-
reason: 'error',
|
|
406
|
-
resultExtra: { cluster, service, region },
|
|
407
|
-
exitCode: 1,
|
|
408
|
-
});
|
|
563
|
+
|
|
564
|
+
await sleep(pollIntervalMs);
|
|
409
565
|
}
|
|
410
566
|
}
|
|
411
567
|
|