diff --git a/.changeset/famous-coats-chew.md b/.changeset/famous-coats-chew.md new file mode 100644 index 000000000000..9e07ea7022b0 --- /dev/null +++ b/.changeset/famous-coats-chew.md @@ -0,0 +1,6 @@ +--- +"@cloudflare/containers-shared": patch +"wrangler": patch +--- + +Add the option to allow all tiers when creating a container diff --git a/packages/containers-shared/src/types.ts b/packages/containers-shared/src/types.ts index 6088c57a6963..c64630105527 100644 --- a/packages/containers-shared/src/types.ts +++ b/packages/containers-shared/src/types.ts @@ -68,7 +68,7 @@ export type SharedContainerConfig = { constraints: { regions?: string[]; cities?: string[]; - tier: number; + tier: number | undefined; }; observability: { logs_enabled: boolean }; } & InstanceTypeOrLimits; diff --git a/packages/wrangler/src/__tests__/containers/config.test.ts b/packages/wrangler/src/__tests__/containers/config.test.ts index 1c14a91c948d..5334ff4bdb03 100644 --- a/packages/wrangler/src/__tests__/containers/config.test.ts +++ b/packages/wrangler/src/__tests__/containers/config.test.ts @@ -542,4 +542,33 @@ describe("getNormalizedContainerOptions", () => { expect(result[0]).toHaveProperty("image_build_context"); expect(result[0]).not.toHaveProperty("image_uri"); }); + + it("should be able to specify all tiers", async () => { + writeFileSync("Dockerfile", "FROM scratch"); + const config: Config = { + name: "test-worker", + containers: [ + { + class_name: "TestContainer", + image: `${getCloudflareContainerRegistry()}/test:latest`, + name: "test-container", + constraints: { + tier: -1, + }, + }, + ], + durable_objects: { + bindings: [ + { + name: "TEST_DO", + class_name: "TestContainer", + }, + ], + }, + } as Partial as Config; + + const result = await getNormalizedContainerOptions(config); + expect(result).toHaveLength(1); + expect(result[0].constraints.tier).toBeUndefined(); + }); }); diff --git a/packages/wrangler/src/containers/config.ts b/packages/wrangler/src/containers/config.ts index 6258f0cb1cef..e1da51ee6418 100644 --- a/packages/wrangler/src/containers/config.ts +++ b/packages/wrangler/src/containers/config.ts @@ -58,7 +58,13 @@ export const getNormalizedContainerOptions = async ( scheduling_policy: (container.scheduling_policy ?? SchedulingPolicy.DEFAULT) as SchedulingPolicy, constraints: { - tier: container.constraints?.tier ?? 1, + // if the tier is -1, then we allow all tiers + // Wrangler will default an input value to 1. The API, however, will + // treat an undefined value to mean no constraints on tier (i.e. "all tiers") + tier: + container.constraints?.tier === -1 + ? undefined + : container.constraints?.tier ?? 1, regions: container.constraints?.regions?.map((region) => region.toUpperCase() ),