Skip to content

Commit d2f2f72

Browse files
CC-5521: Revert to "dev" when instance type is absent (#9717)
* CC-5521: Revert to "dev" when instance type is absent When the instance_type field is absent in the wrangler config and no other vcpu, memory, or disk configuration is set, automatically populate the instance_type field with "dev". This way, deleting instance_type from wrangler.jsonc reverts the deployment back to dev. * Update packages/wrangler/src/cloudchamber/apply.ts * Update packages/wrangler/src/cloudchamber/apply.ts * test fix * test fix: image in container app config --------- Co-authored-by: Carmen Popoviciu <[email protected]>
1 parent 9b85137 commit d2f2f72

File tree

3 files changed

+242
-6
lines changed

3 files changed

+242
-6
lines changed

.changeset/easy-walls-raise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Containers should default to a "dev" instance type when no instance type is specified in the wrangler config

packages/wrangler/src/__tests__/cloudchamber/apply.test.ts

Lines changed: 214 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ describe("cloudchamber apply", () => {
123123
124124
│ [containers.configuration]
125125
│ image = \\"./Dockerfile\\"
126+
│ instance_type = \\"dev\\"
126127
127128
128129
│  SUCCESS  Created application my-container-app (Application ID: abc)
@@ -161,6 +162,13 @@ describe("cloudchamber apply", () => {
161162
scheduling_policy: SchedulingPolicy.DEFAULT,
162163
configuration: {
163164
image: "./Dockerfile",
165+
disk: {
166+
size: "2GB",
167+
size_mb: 2000,
168+
},
169+
vcpu: 0.0625,
170+
memory: "256MB",
171+
memory_mib: 256,
164172
},
165173
constraints: {
166174
tier: 3,
@@ -233,6 +241,13 @@ describe("cloudchamber apply", () => {
233241
scheduling_policy: SchedulingPolicy.DEFAULT,
234242
configuration: {
235243
image: "./Dockerfile",
244+
disk: {
245+
size: "2GB",
246+
size_mb: 2000,
247+
},
248+
vcpu: 0.0625,
249+
memory: "256MB",
250+
memory_mib: 256,
236251
},
237252
constraints: {
238253
tier: 1,
@@ -267,6 +282,7 @@ describe("cloudchamber apply", () => {
267282
268283
│ [containers.configuration]
269284
│ image = \\"other-app/Dockerfile\\"
285+
│ instance_type = \\"dev\\"
270286
271287
│ [containers.constraints]
272288
│ tier = 1
@@ -318,6 +334,13 @@ describe("cloudchamber apply", () => {
318334
scheduling_policy: SchedulingPolicy.DEFAULT,
319335
configuration: {
320336
image: "./Dockerfile",
337+
disk: {
338+
size: "2GB",
339+
size_mb: 2000,
340+
},
341+
vcpu: 0.0625,
342+
memory: "256MB",
343+
memory_mib: 256,
321344
},
322345
constraints: {
323346
tier: 1,
@@ -350,6 +373,7 @@ describe("cloudchamber apply", () => {
350373
351374
│ [containers.configuration]
352375
│ image = \\"other-app/Dockerfile\\"
376+
│ instance_type = \\"dev\\"
353377
354378
│ [containers.constraints]
355379
│ tier = 1
@@ -395,6 +419,13 @@ describe("cloudchamber apply", () => {
395419
scheduling_policy: SchedulingPolicy.DEFAULT,
396420
configuration: {
397421
image: "./Dockerfile",
422+
disk: {
423+
size: "2GB",
424+
size_mb: 2000,
425+
},
426+
vcpu: 0.0625,
427+
memory: "256MB",
428+
memory_mib: 256,
398429
},
399430
constraints: {
400431
tier: 1,
@@ -427,6 +458,7 @@ describe("cloudchamber apply", () => {
427458
428459
│ [containers.configuration]
429460
│ image = \\"other-app/Dockerfile\\"
461+
│ instance_type = \\"dev\\"
430462
431463
│ [containers.constraints]
432464
│ tier = 1
@@ -526,6 +558,13 @@ describe("cloudchamber apply", () => {
526558
secret: "SECRET_NAME_2",
527559
},
528560
],
561+
disk: {
562+
size: "2GB",
563+
size_mb: 2000,
564+
},
565+
vcpu: 0.0625,
566+
memory: "256MB",
567+
memory_mib: 256,
529568
},
530569
constraints: {
531570
tier: 1,
@@ -656,6 +695,13 @@ describe("cloudchamber apply", () => {
656695
secret: "SECRET_NAME_2",
657696
},
658697
],
698+
disk: {
699+
size: "2GB",
700+
size_mb: 2000,
701+
},
702+
vcpu: 0.0625,
703+
memory: "256MB",
704+
memory_mib: 256,
659705
},
660706

661707
constraints: {
@@ -759,6 +805,13 @@ describe("cloudchamber apply", () => {
759805
secret: "SECRET_NAME_2",
760806
},
761807
],
808+
disk: {
809+
size: "2GB",
810+
size_mb: 2000,
811+
},
812+
vcpu: 0.0625,
813+
memory: "256MB",
814+
memory_mib: 256,
762815
},
763816

764817
constraints: {
@@ -869,6 +922,13 @@ describe("cloudchamber apply", () => {
869922
secret: "SECRET_NAME_2",
870923
},
871924
],
925+
disk: {
926+
size: "2GB",
927+
size_mb: 2000,
928+
},
929+
vcpu: 0.0625,
930+
memory: "256MB",
931+
memory_mib: 256,
872932
},
873933

874934
constraints: {
@@ -972,6 +1032,13 @@ describe("cloudchamber apply", () => {
9721032
secret: "SECRET_NAME_2",
9731033
},
9741034
],
1035+
disk: {
1036+
size: "2GB",
1037+
size_mb: 2000,
1038+
},
1039+
vcpu: 0.0625,
1040+
memory: "256MB",
1041+
memory_mib: 256,
9751042
},
9761043

9771044
constraints: {
@@ -1027,6 +1094,13 @@ describe("cloudchamber apply", () => {
10271094
scheduling_policy: SchedulingPolicy.REGIONAL,
10281095
configuration: {
10291096
image: "./Dockerfile",
1097+
disk: {
1098+
size: "2GB",
1099+
size_mb: 2000,
1100+
},
1101+
vcpu: 0.0625,
1102+
memory: "256MB",
1103+
memory_mib: 256,
10301104
},
10311105
constraints: {
10321106
tier: 1,
@@ -1044,7 +1118,8 @@ describe("cloudchamber apply", () => {
10441118
├ EDIT my-container-app
10451119
10461120
│ [containers.configuration]
1047-
│ image = \\"./Dockerfile\\"
1121+
│ ...
1122+
│ instance_type = \\"dev\\"
10481123
10491124
│ + [containers.configuration.observability.logs]
10501125
│ + enabled = true
@@ -1093,6 +1168,13 @@ describe("cloudchamber apply", () => {
10931168
scheduling_policy: SchedulingPolicy.REGIONAL,
10941169
configuration: {
10951170
image: "./Dockerfile",
1171+
disk: {
1172+
size: "2GB",
1173+
size_mb: 2000,
1174+
},
1175+
vcpu: 0.0625,
1176+
memory: "256MB",
1177+
memory_mib: 256,
10961178
},
10971179
constraints: {
10981180
tier: 1,
@@ -1110,7 +1192,8 @@ describe("cloudchamber apply", () => {
11101192
├ EDIT my-container-app
11111193
11121194
│ [containers.configuration]
1113-
│ image = \\"./Dockerfile\\"
1195+
│ ...
1196+
│ instance_type = \\"dev\\"
11141197
11151198
│ + [containers.configuration.observability.logs]
11161199
│ + enabled = true
@@ -1164,6 +1247,13 @@ describe("cloudchamber apply", () => {
11641247
enabled: true,
11651248
},
11661249
},
1250+
disk: {
1251+
size: "2GB",
1252+
size_mb: 2000,
1253+
},
1254+
vcpu: 0.0625,
1255+
memory: "256MB",
1256+
memory_mib: 256,
11671257
},
11681258
constraints: {
11691259
tier: 1,
@@ -1233,6 +1323,13 @@ describe("cloudchamber apply", () => {
12331323
enabled: true,
12341324
},
12351325
},
1326+
disk: {
1327+
size: "2GB",
1328+
size_mb: 2000,
1329+
},
1330+
vcpu: 0.0625,
1331+
memory: "256MB",
1332+
memory_mib: 256,
12361333
},
12371334
constraints: {
12381335
tier: 1,
@@ -1301,6 +1398,13 @@ describe("cloudchamber apply", () => {
13011398
enabled: true,
13021399
},
13031400
},
1401+
disk: {
1402+
size: "2GB",
1403+
size_mb: 2000,
1404+
},
1405+
vcpu: 0.0625,
1406+
memory: "256MB",
1407+
memory_mib: 256,
13041408
},
13051409
constraints: {
13061410
tier: 1,
@@ -1372,6 +1476,13 @@ describe("cloudchamber apply", () => {
13721476
enabled: true,
13731477
},
13741478
},
1479+
disk: {
1480+
size: "2GB",
1481+
size_mb: 2000,
1482+
},
1483+
vcpu: 0.0625,
1484+
memory: "256MB",
1485+
memory_mib: 256,
13751486
},
13761487
constraints: {
13771488
tier: 1,
@@ -1444,6 +1555,13 @@ describe("cloudchamber apply", () => {
14441555
enabled: true,
14451556
},
14461557
},
1558+
disk: {
1559+
size: "2GB",
1560+
size_mb: 2000,
1561+
},
1562+
vcpu: 0.0625,
1563+
memory: "256MB",
1564+
memory_mib: 256,
14471565
},
14481566
constraints: {
14491567
tier: 1,
@@ -1491,6 +1609,13 @@ describe("cloudchamber apply", () => {
14911609
scheduling_policy: SchedulingPolicy.REGIONAL,
14921610
configuration: {
14931611
image: "./Dockerfile",
1612+
disk: {
1613+
size: "2GB",
1614+
size_mb: 2000,
1615+
},
1616+
vcpu: 0.0625,
1617+
memory: "256MB",
1618+
memory_mib: 256,
14941619
},
14951620
constraints: {
14961621
tier: 1,
@@ -1546,6 +1671,13 @@ describe("cloudchamber apply", () => {
15461671
enabled: false,
15471672
},
15481673
},
1674+
disk: {
1675+
size: "2GB",
1676+
size_mb: 2000,
1677+
},
1678+
vcpu: 0.0625,
1679+
memory: "256MB",
1680+
memory_mib: 256,
15491681
},
15501682
constraints: {
15511683
tier: 1,
@@ -1700,4 +1832,84 @@ describe("cloudchamber apply", () => {
17001832
expect(app.configuration?.instance_type).toEqual("standard");
17011833
/* eslint-enable */
17021834
});
1835+
1836+
test("falls back on dev instance type when instance type is absent", async () => {
1837+
setIsTTY(false);
1838+
writeWranglerConfig({
1839+
name: "my-container",
1840+
containers: [
1841+
{
1842+
name: "my-container-app",
1843+
instances: 4,
1844+
class_name: "DurableObjectClass",
1845+
image: "./Dockerfile",
1846+
constraints: {
1847+
tier: 2,
1848+
},
1849+
},
1850+
],
1851+
});
1852+
mockGetApplications([
1853+
{
1854+
id: "abc",
1855+
name: "my-container-app",
1856+
instances: 3,
1857+
created_at: new Date().toString(),
1858+
version: 1,
1859+
account_id: "1",
1860+
scheduling_policy: SchedulingPolicy.REGIONAL,
1861+
configuration: {
1862+
image: "./Dockerfile",
1863+
disk: {
1864+
size: "4GB",
1865+
size_mb: 4000,
1866+
},
1867+
vcpu: 0.25,
1868+
memory: "1024MB",
1869+
memory_mib: 1024,
1870+
},
1871+
constraints: {
1872+
tier: 3,
1873+
},
1874+
},
1875+
]);
1876+
const applicationReqBodyPromise = mockModifyApplication();
1877+
await runWrangler("cloudchamber apply --json");
1878+
/* eslint-disable */
1879+
expect(std.stdout).toMatchInlineSnapshot(`
1880+
"╭ Deploy a container application deploy changes to your application
1881+
1882+
│ Container application changes
1883+
1884+
├ EDIT my-container-app
1885+
1886+
│ [[containers]]
1887+
│ - instances = 3
1888+
│ + instances = 4
1889+
│ name = \\"my-container-app\\"
1890+
1891+
│ [containers.configuration]
1892+
│ image = \\"./Dockerfile\\"
1893+
│ - instance_type = \\"basic\\"
1894+
│ + instance_type = \\"dev\\"
1895+
1896+
│ [containers.constraints]
1897+
│ ...
1898+
│ - tier = 3
1899+
│ + tier = 2
1900+
1901+
├ Loading
1902+
1903+
1904+
│  SUCCESS  Modified application my-container-app
1905+
1906+
╰ Applied changes
1907+
1908+
"
1909+
`);
1910+
expect(std.stderr).toMatchInlineSnapshot(`""`);
1911+
const app = await applicationReqBodyPromise;
1912+
expect(app.configuration?.instance_type).toEqual("dev");
1913+
/* eslint-enable */
1914+
});
17031915
});

0 commit comments

Comments
 (0)