Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh

Commit

A deploy of a unit with containers says, for each of its container applications, what Cloudflare runs after it: the instance type, vCPU, memory and disk, the version, how many instances, and whether a rollout is still going, from wrangler containers list. A deploy log then shows whether new container settings took; reading them never fails the deploy.

syntaqxcommitted Parente277e3fBrowse files
1 file+24−00/1 viewed
+24−0
376376 if (deployed.code !== 0) throw new Error(`wrangler deploy failed:\n${wranglerError(deployed.out)}`);
377377 result.version = dryRun ? "(dry run)" : versionFrom(deployed.out);
378378 result.ok = true;
379+ if (unit.image && !dryRun) await reportContainers(unit, cwd, out);
379380 } catch (error) {
380381 result.note = String(error.message ?? error);
381382 } finally {
387388 return result;
388389 }
389390
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+
390414 async function migrate(stack, units, migrations, opts) {
391415 const due = units.filter((u) => migrations[u.id]?.pending?.length);
392416 const broken = units.filter((u) => migrations[u.id]?.error);

Comments

Sign in to comment.