Skip to content

Commit bfe7096

Browse files
committed
fix custom instance limit units and add extra test
1 parent ae097b2 commit bfe7096

File tree

2 files changed

+86
-5
lines changed

2 files changed

+86
-5
lines changed

packages/wrangler/src/__tests__/containers/deploy.test.ts

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,91 @@ describe("wrangler deploy with containers", () => {
221221
`);
222222
});
223223

224+
it("should be able to deploy a new container with custom instance limits", async () => {
225+
// note no docker commands have been mocked here!
226+
mockGetVersion("Galaxy-Class");
227+
writeWranglerConfig({
228+
...DEFAULT_DURABLE_OBJECTS,
229+
containers: [
230+
{
231+
...DEFAULT_CONTAINER_FROM_REGISTRY,
232+
configuration: {
233+
vcpu: 1,
234+
memory_mib: 1000,
235+
disk: { size_mb: 2000 },
236+
},
237+
},
238+
],
239+
});
240+
241+
mockGetApplications([]);
242+
243+
mockCreateApplication({
244+
name: "my-container",
245+
max_instances: 10,
246+
scheduling_policy: SchedulingPolicy.DEFAULT,
247+
configuration: {
248+
image: "docker.io/hello:world",
249+
disk: {
250+
size_mb: 2000,
251+
},
252+
vcpu: 1,
253+
memory_mib: 1000,
254+
},
255+
});
256+
257+
await runWrangler("deploy index.js");
258+
259+
expect(std.out).toMatchInlineSnapshot(`
260+
"Total Upload: xx KiB / gzip: xx KiB
261+
Worker Startup Time: 100 ms
262+
Your Worker has access to the following bindings:
263+
Binding Resource
264+
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
265+
266+
Uploaded test-name (TIMINGS)
267+
Deployed test-name triggers (TIMINGS)
268+
https://test-name.test-sub-domain.workers.dev
269+
Current Version ID: Galaxy-Class"
270+
`);
271+
expect(std.err).toMatchInlineSnapshot(`""`);
272+
273+
expect(cliStd.stdout).toMatchInlineSnapshot(`
274+
"╭ Deploy a container application deploy changes to your application
275+
276+
│ Container application changes
277+
278+
├ NEW my-container
279+
280+
│ [[containers]]
281+
│ name = \\"my-container\\"
282+
│ scheduling_policy = \\"default\\"
283+
│ instances = 0
284+
│ max_instances = 10
285+
286+
│ [containers.configuration]
287+
│ image = \\"docker.io/hello:world\\"
288+
│ memory_mib = 1_000
289+
│ vcpu = 1
290+
291+
│ [containers.configuration.disk]
292+
│ size_mb = 2_000
293+
294+
│ [containers.constraints]
295+
│ tier = 1
296+
297+
│ [containers.durable_objects]
298+
│ namespace_id = \\"1\\"
299+
300+
301+
│ SUCCESS Created application my-container (Application ID: undefined)
302+
303+
╰ Applied changes
304+
305+
"
306+
`);
307+
});
308+
224309
it("should resolve the docker build context path based on the dockerfile location, if image_build_context is not provided", async () => {
225310
vi.stubEnv("WRANGLER_DOCKER_BIN", "/usr/bin/docker");
226311
mockGetVersion("Galaxy-Class");
@@ -1364,8 +1449,6 @@ function mockModifyApplication(expected?: Partial<Application>) {
13641449
http.patch("*/applications/:id", async ({ request }) => {
13651450
const json = await request.json();
13661451
if (expected !== undefined) {
1367-
// console.dir("expected" + JSON.stringify(expected, null, 2));
1368-
// console.dir("json" + JSON.stringify(json, null, 2));
13691452
expect(json).toMatchObject(expected);
13701453
}
13711454
expect((json as CreateApplicationRequest).name).toBeUndefined();
@@ -1386,8 +1469,6 @@ function mockCreateApplicationRollout(expected?: Record<string, unknown>) {
13861469
http.post("*/applications/:id/rollouts", async ({ request }) => {
13871470
const json = await request.json();
13881471
if (expected !== undefined) {
1389-
// console.dir("expected" + JSON.stringify(expected, null, 2));
1390-
// console.dir("json" + JSON.stringify(json, null, 2));
13911472
expect(json).toMatchObject(expected);
13921473
}
13931474
return HttpResponse.json({

packages/wrangler/src/containers/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function containerConfigToCreateRequest(
167167
...("instance_type" in containerApp
168168
? { instance_type: containerApp.instance_type }
169169
: {
170-
disk: { size_mb: containerApp.disk_bytes / (1024 * 1024) },
170+
disk: { size_mb: containerApp.disk_bytes / (1000 * 1000) },
171171
memory_mib: containerApp.memory_mib,
172172
vcpu: containerApp.vcpu,
173173
}),

0 commit comments

Comments
 (0)