Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/easy-walls-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Containers should default to a "dev" instance type when no instance type is specified in the wrangler config
216 changes: 214 additions & 2 deletions packages/wrangler/src/__tests__/cloudchamber/apply.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ describe("cloudchamber apply", () => {
│ [containers.configuration]
│ image = \\"./Dockerfile\\"
│ instance_type = \\"dev\\"
│  SUCCESS  Created application my-container-app (Application ID: abc)
Expand Down Expand Up @@ -161,6 +162,13 @@ describe("cloudchamber apply", () => {
scheduling_policy: SchedulingPolicy.DEFAULT,
configuration: {
image: "./Dockerfile",
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 3,
Expand Down Expand Up @@ -233,6 +241,13 @@ describe("cloudchamber apply", () => {
scheduling_policy: SchedulingPolicy.DEFAULT,
configuration: {
image: "./Dockerfile",
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand Down Expand Up @@ -267,6 +282,7 @@ describe("cloudchamber apply", () => {
│ [containers.configuration]
│ image = \\"other-app/Dockerfile\\"
│ instance_type = \\"dev\\"
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -318,6 +334,13 @@ describe("cloudchamber apply", () => {
scheduling_policy: SchedulingPolicy.DEFAULT,
configuration: {
image: "./Dockerfile",
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand Down Expand Up @@ -350,6 +373,7 @@ describe("cloudchamber apply", () => {
│ [containers.configuration]
│ image = \\"other-app/Dockerfile\\"
│ instance_type = \\"dev\\"
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -395,6 +419,13 @@ describe("cloudchamber apply", () => {
scheduling_policy: SchedulingPolicy.DEFAULT,
configuration: {
image: "./Dockerfile",
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand Down Expand Up @@ -427,6 +458,7 @@ describe("cloudchamber apply", () => {
│ [containers.configuration]
│ image = \\"other-app/Dockerfile\\"
│ instance_type = \\"dev\\"
│ [containers.constraints]
│ tier = 1
Expand Down Expand Up @@ -526,6 +558,13 @@ describe("cloudchamber apply", () => {
secret: "SECRET_NAME_2",
},
],
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand Down Expand Up @@ -656,6 +695,13 @@ describe("cloudchamber apply", () => {
secret: "SECRET_NAME_2",
},
],
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},

constraints: {
Expand Down Expand Up @@ -759,6 +805,13 @@ describe("cloudchamber apply", () => {
secret: "SECRET_NAME_2",
},
],
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},

constraints: {
Expand Down Expand Up @@ -869,6 +922,13 @@ describe("cloudchamber apply", () => {
secret: "SECRET_NAME_2",
},
],
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},

constraints: {
Expand Down Expand Up @@ -972,6 +1032,13 @@ describe("cloudchamber apply", () => {
secret: "SECRET_NAME_2",
},
],
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},

constraints: {
Expand Down Expand Up @@ -1027,6 +1094,13 @@ describe("cloudchamber apply", () => {
scheduling_policy: SchedulingPolicy.REGIONAL,
configuration: {
image: "./Dockerfile",
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand All @@ -1044,7 +1118,8 @@ describe("cloudchamber apply", () => {
├ EDIT my-container-app
│ [containers.configuration]
│ image = \\"./Dockerfile\\"
│ ...
│ instance_type = \\"dev\\"
│ + [containers.configuration.observability.logs]
│ + enabled = true
Expand Down Expand Up @@ -1093,6 +1168,13 @@ describe("cloudchamber apply", () => {
scheduling_policy: SchedulingPolicy.REGIONAL,
configuration: {
image: "./Dockerfile",
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand All @@ -1110,7 +1192,8 @@ describe("cloudchamber apply", () => {
├ EDIT my-container-app
│ [containers.configuration]
│ image = \\"./Dockerfile\\"
│ ...
│ instance_type = \\"dev\\"
│ + [containers.configuration.observability.logs]
│ + enabled = true
Expand Down Expand Up @@ -1164,6 +1247,13 @@ describe("cloudchamber apply", () => {
enabled: true,
},
},
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand Down Expand Up @@ -1233,6 +1323,13 @@ describe("cloudchamber apply", () => {
enabled: true,
},
},
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand Down Expand Up @@ -1301,6 +1398,13 @@ describe("cloudchamber apply", () => {
enabled: true,
},
},
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand Down Expand Up @@ -1372,6 +1476,13 @@ describe("cloudchamber apply", () => {
enabled: true,
},
},
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand Down Expand Up @@ -1444,6 +1555,13 @@ describe("cloudchamber apply", () => {
enabled: true,
},
},
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand Down Expand Up @@ -1491,6 +1609,13 @@ describe("cloudchamber apply", () => {
scheduling_policy: SchedulingPolicy.REGIONAL,
configuration: {
image: "./Dockerfile",
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand Down Expand Up @@ -1546,6 +1671,13 @@ describe("cloudchamber apply", () => {
enabled: false,
},
},
disk: {
size: "2GB",
size_mb: 2000,
},
vcpu: 0.0625,
memory: "256MB",
memory_mib: 256,
},
constraints: {
tier: 1,
Expand Down Expand Up @@ -1700,4 +1832,84 @@ describe("cloudchamber apply", () => {
expect(app.configuration?.instance_type).toEqual("standard");
/* eslint-enable */
});

test("falls back on dev instance type when instance type is absent", async () => {
setIsTTY(false);
writeWranglerConfig({
name: "my-container",
containers: [
{
name: "my-container-app",
instances: 4,
class_name: "DurableObjectClass",
image: "./Dockerfile",
constraints: {
tier: 2,
},
},
],
});
mockGetApplications([
{
id: "abc",
name: "my-container-app",
instances: 3,
created_at: new Date().toString(),
version: 1,
account_id: "1",
scheduling_policy: SchedulingPolicy.REGIONAL,
configuration: {
image: "./Dockerfile",
disk: {
size: "4GB",
size_mb: 4000,
},
vcpu: 0.25,
memory: "1024MB",
memory_mib: 1024,
},
constraints: {
tier: 3,
},
},
]);
const applicationReqBodyPromise = mockModifyApplication();
await runWrangler("cloudchamber apply --json");
/* eslint-disable */
expect(std.stdout).toMatchInlineSnapshot(`
"╭ Deploy a container application deploy changes to your application
│ Container application changes
├ EDIT my-container-app
│ [[containers]]
│ - instances = 3
│ + instances = 4
│ name = \\"my-container-app\\"
│ [containers.configuration]
│ image = \\"./Dockerfile\\"
│ - instance_type = \\"basic\\"
│ + instance_type = \\"dev\\"
│ [containers.constraints]
│ ...
│ - tier = 3
│ + tier = 2
├ Loading
│  SUCCESS  Modified application my-container-app
╰ Applied changes

"
`);
expect(std.stderr).toMatchInlineSnapshot(`""`);
const app = await applicationReqBodyPromise;
expect(app.configuration?.instance_type).toEqual("dev");
/* eslint-enable */
});
});
Loading
Loading