Skip to content

Commit c22acc6

Browse files
authored
default max_instances to 1 (#10533)
1 parent a565291 commit c22acc6

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

.changeset/moody-terms-drive.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+
If unset, containers.max_instances should default to 1 instead of 0.

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,41 @@ describe("getNormalizedContainerOptions", () => {
197197
});
198198
});
199199

200+
it("should default max_instances and rollout_step_percentage accordingly", async () => {
201+
writeFileSync("Dockerfile", "FROM scratch");
202+
203+
const config: Config = {
204+
name: "test-worker",
205+
configPath: "./wrangler.toml",
206+
topLevelName: "test-worker",
207+
containers: [
208+
{
209+
class_name: "TestContainer",
210+
image: path.resolve("./Dockerfile"),
211+
name: "test-container",
212+
},
213+
],
214+
durable_objects: {
215+
bindings: [
216+
{
217+
name: "TEST_DO",
218+
class_name: "TestContainer",
219+
},
220+
],
221+
},
222+
} as Partial<Config> as Config;
223+
224+
const result = await getNormalizedContainerOptions(config, {});
225+
226+
expect(result).toHaveLength(1);
227+
expect(result[0]).toMatchObject({
228+
name: "test-container",
229+
class_name: "TestContainer",
230+
max_instances: 1,
231+
rollout_step_percentage: 100,
232+
});
233+
});
234+
200235
it("should handle custom limit configuration", async () => {
201236
// deprecated path for setting custom limits
202237
const config: Config = {

packages/wrangler/src/containers/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const getNormalizedContainerOptions = async (
8888
const shared: Omit<SharedContainerConfig, "disk_size" | "instance_type"> = {
8989
name: container.name,
9090
class_name: container.class_name,
91-
max_instances: container.max_instances ?? 0,
91+
max_instances: container.max_instances ?? 1,
9292
scheduling_policy: (container.scheduling_policy ??
9393
SchedulingPolicy.DEFAULT) as SchedulingPolicy,
9494
constraints: {

0 commit comments

Comments
 (0)