Skip to content

Commit 8e33339

Browse files
committed
pr feedback on instance_type
1 parent eb21f6e commit 8e33339

File tree

7 files changed

+16
-41
lines changed

7 files changed

+16
-41
lines changed

packages/containers-shared/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type RegistryLinkConfig = SharedContainerConfig & {
4141
export type InstanceTypeOrLimits =
4242
| {
4343
/** if undefined in config, defaults to instance_type */
44-
disk_size?: number;
44+
disk_mb?: number;
4545
vcpu?: number;
4646
memory_mib?: number;
4747
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ describe("getNormalizedContainerOptions", () => {
187187
});
188188
});
189189

190-
it("should handle (deprecated) disk size configuration", async () => {
190+
it("should handle custom limit configuration", async () => {
191191
mockIsDockerfile.mockReturnValue(false);
192192

193193
const config: Config = {
@@ -201,7 +201,9 @@ describe("getNormalizedContainerOptions", () => {
201201
class_name: "TestContainer",
202202
image: "registry.example.com/test:latest",
203203
configuration: {
204-
disk: { size: "5GiB" },
204+
disk: { size_mb: 5000 },
205+
memory_mib: 1024,
206+
vcpu: 2,
205207
},
206208
},
207209
],
@@ -224,7 +226,9 @@ describe("getNormalizedContainerOptions", () => {
224226
scheduling_policy: "default",
225227
rollout_step_percentage: 25,
226228
rollout_kind: "full_auto",
227-
disk_size: 5368709120,
229+
disk_mb: 5000,
230+
memory_mib: 1024,
231+
vcpu: 2,
228232
registry_link: "registry.example.com/test:latest",
229233
constraints: undefined,
230234
});

packages/wrangler/src/cloudchamber/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function maybeBuildContainer(
3737
},
3838
pathToDocker,
3939
!dryRun,
40-
"disk_size" in containerConfig ? containerConfig.disk_size : undefined
40+
"disk_mb" in containerConfig ? containerConfig.disk_mb : undefined
4141
);
4242

4343
if (buildResult.pushed) {

packages/wrangler/src/config/environment.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,9 @@ export type ContainerApp = {
114114
image?: string;
115115
labels?: { name: string; value: string }[];
116116
secrets?: { name: string; type: "env"; secret: string }[];
117-
disk?:
118-
| {
119-
/**
120-
* @deprecated Use `size_mb` instead.
121-
*/
122-
size: string;
123-
}
124-
| { size_mb: number };
117+
disk?: { size_mb: number };
125118
vcpu?: number;
126119
memory_mib?: number;
127-
/**
128-
* @deprecated Use `size_mb` instead.
129-
*/
130-
memory?: string;
131120
};
132121

133122
/**

packages/wrangler/src/config/validation.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,8 +2447,7 @@ function validateContainerApp(
24472447
containerAppOptional.instance_type &&
24482448
(containerAppOptional.configuration.disk !== undefined ||
24492449
containerAppOptional.configuration.vcpu !== undefined ||
2450-
containerAppOptional.configuration.memory_mib !== undefined ||
2451-
containerAppOptional.configuration.memory !== undefined)
2450+
containerAppOptional.configuration.memory_mib !== undefined)
24522451
) {
24532452
diagnostics.errors.push(
24542453
`Cannot set custom limits via "containers.configuration" and use preset "instance_type" limits at the same time.`

packages/wrangler/src/containers/config.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
SchedulingPolicy,
77
} from "@cloudflare/containers-shared";
88
import { UserError } from "../errors";
9-
import { parseByteSize } from "../parse";
109
import type { Config } from "../config";
1110
import type {
1211
ContainerNormalisedConfig,
@@ -59,28 +58,12 @@ export const getNormalizedContainerOptions = async (
5958
if (
6059
container.configuration?.disk !== undefined ||
6160
container.configuration?.vcpu !== undefined ||
62-
container.configuration?.memory_mib !== undefined ||
63-
// this is doubly deprecated, do we need to support this?
64-
container.configuration?.memory !== undefined
61+
container.configuration?.memory_mib !== undefined
6562
) {
66-
let normalisedDiskSize: number | undefined;
67-
if (container.configuration?.disk !== undefined) {
68-
normalisedDiskSize =
69-
"size" in container.configuration.disk
70-
? // // have i got the right units here?
71-
Math.round(
72-
parseByteSize(container.configuration.disk.size ?? "2GB")
73-
)
74-
: container.configuration.disk.size_mb;
75-
}
76-
7763
instanceTypeOrDisk = {
78-
disk_size: normalisedDiskSize,
64+
disk_mb: container.configuration.disk?.size_mb,
7965
vcpu: container.configuration?.vcpu,
80-
memory_mib:
81-
container.configuration.memory !== undefined
82-
? Math.round(parseByteSize(container.configuration?.memory))
83-
: container.configuration?.memory_mib,
66+
memory_mib: container.configuration?.memory_mib,
8467
};
8568
} else {
8669
instanceTypeOrDisk = {

packages/wrangler/src/containers/deploy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function containerConfigToAPIConfig(
199199
...("instance_type" in containerApp
200200
? { instance_type: containerApp.instance_type }
201201
: {
202-
disk: { size_mb: containerApp.disk_size },
202+
disk: { size_mb: containerApp.disk_mb },
203203
memory_mib: containerApp.memory_mib,
204204
vcpu: containerApp.vcpu,
205205
}),
@@ -509,7 +509,7 @@ const doAction = async (
509509
};
510510

511511
/**
512-
* clean up so we get a nicer diff
512+
* clean up fields so we get a nicer diff
513513
*/
514514
export function cleanPrevious(
515515
prev: CreateApplicationRequest,

0 commit comments

Comments
 (0)