| 376 | 376 | | if (deployed.code !== 0) throw new Error(`wrangler deploy failed:\n${wranglerError(deployed.out)}`); |
| 377 | 377 | | result.version = dryRun ? "(dry run)" : versionFrom(deployed.out); |
| 378 | 378 | | result.ok = true; |
| 379 | + | if (unit.image && !dryRun) await reportContainers(unit, cwd, out); |
| 379 | 380 | | } catch (error) { |
| 380 | 381 | | result.note = String(error.message ?? error); |
| 381 | 382 | | } finally { |
| ⋯ |
| 387 | 388 | | return result; |
| 388 | 389 | | } |
| 389 | 390 | | |
| 391 | + | /** |
| 392 | + | * What Cloudflare runs for a unit's container applications after a deploy: |
| 393 | + | * each one's instance type, size, version and rollout, from `wrangler |
| 394 | + | * containers list`, so a deploy log says whether new settings took. Never |
| 395 | + | * fails the deploy. |
| 396 | + | */ |
| 397 | + | async function reportContainers(unit, cwd, out) { |
| 398 | + | try { |
| 399 | + | const listed = await wrangler(["containers", "list"], { cwd }); |
| 400 | + | const text = listed.out.slice(listed.out.indexOf("[")); |
| 401 | + | const apps = JSON.parse(text.slice(0, text.lastIndexOf("]") + 1)); |
| 402 | + | for (const app of apps.filter((a) => String(a.name ?? "").startsWith(`${unit.worker}-`))) { |
| 403 | + | const c = app.configuration ?? {}; |
| 404 | + | const disk = c.disk?.size_mb ?? c.disk_mb ?? c.disk?.size; |
| 405 | + | const size = [c.instance_type, c.vcpu != null && `${c.vcpu} vCPU`, c.memory_mib != null && `${c.memory_mib} MiB`, disk != null && `${disk} MB disk`].filter(Boolean).join(", "); |
| 406 | + | const rollout = app.active_rollout_id ? `rollout ${app.active_rollout_id} in progress` : "no rollout in progress"; |
| 407 | + | out.line(`container ${app.name}: ${size || JSON.stringify(c).slice(0, 200)}; version ${app.version ?? "?"}; ${app.instances ?? "?"} instances; ${rollout}`); |
| 408 | + | } |
| 409 | + | } catch (error) { |
| 410 | + | out.line(`could not read the container applications: ${error.message ?? error}`); |
| 411 | + | } |
| 412 | + | } |
| 413 | + | |
| 390 | 414 | | async function migrate(stack, units, migrations, opts) { |
| 391 | 415 | | const due = units.filter((u) => migrations[u.id]?.pending?.length); |
| 392 | 416 | | const broken = units.filter((u) => migrations[u.id]?.error); |