Skip to content

Commit 064da04

Browse files
committed
refactor(supervisor): rename compute network_labels field to labels
Aligns with the compute provider's renamed `labels` field; the provider now promotes a configured subset to network policy. Behavior unchanged - still forwards a private-link label on create and restore.
1 parent 87608b1 commit 064da04

3 files changed

Lines changed: 21 additions & 25 deletions

File tree

.server-changes/compute-network-labels.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ area: supervisor
33
type: feature
44
---
55

6-
Forward per-VM network endpoint labels to compute runs on create and restore.
6+
Forward per-run identity labels to the compute provider on create and restore, letting network policy select runs (e.g. private link).

apps/supervisor/src/workloadManager/compute.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ export class ComputeWorkloadManager implements WorkloadManager {
133133
// Strip image digest - resolve by tag, not digest
134134
const imageRef = stripImageDigest(opts.image);
135135

136-
// Per-VM network endpoint labels, applied to the VM's network endpoint so
137-
// network policy can select it. Mirrors the label the Kubernetes workload
138-
// manager sets on the run pod.
139-
const networkLabels: Record<string, string> = {};
136+
// Labels forwarded to the compute provider for network-policy selection;
137+
// the provider promotes a configured subset to its network layer. Mirrors
138+
// the privatelink label the Kubernetes workload manager sets on the run pod.
139+
const labels: Record<string, string> = {};
140140
if (opts.hasPrivateLink) {
141-
networkLabels.privatelink = opts.orgId;
141+
labels.privatelink = opts.orgId;
142142
}
143143

144144
// Wide event: single canonical log line emitted in finally
@@ -181,9 +181,7 @@ export class ComputeWorkloadManager implements WorkloadManager {
181181
deploymentVersion: opts.deploymentVersion,
182182
machine: opts.machine.name,
183183
},
184-
...(Object.keys(networkLabels).length > 0
185-
? { network_labels: networkLabels }
186-
: {}),
184+
...(Object.keys(labels).length > 0 ? { labels } : {}),
187185
})
188186
);
189187

@@ -321,12 +319,12 @@ export class ComputeWorkloadManager implements WorkloadManager {
321319
TRIGGER_WORKER_INSTANCE_NAME: this.opts.runner.instanceName,
322320
};
323321

324-
// Carry the same network endpoint labels onto the restored VM (mirror of
325-
// the create path) so network policy keeps matching after a restore —
326-
// without them a restored run would lose its policy-based egress.
327-
const networkLabels: Record<string, string> = {};
322+
// Resupply the same labels on restore (mirror of the create path); the
323+
// provider doesn't persist them across a snapshot, so without this a
324+
// restored run would lose its policy-based network selection.
325+
const labels: Record<string, string> = {};
328326
if (opts.hasPrivateLink && opts.orgId) {
329-
networkLabels.privatelink = opts.orgId;
327+
labels.privatelink = opts.orgId;
330328
}
331329

332330
this.logger.verbose("restore request body", {
@@ -342,9 +340,7 @@ export class ComputeWorkloadManager implements WorkloadManager {
342340
metadata,
343341
cpu: opts.machine.cpu,
344342
memory_gb: opts.machine.memory,
345-
...(Object.keys(networkLabels).length > 0
346-
? { network_labels: networkLabels }
347-
: {}),
343+
...(Object.keys(labels).length > 0 ? { labels } : {}),
348344
})
349345
);
350346

internal-packages/compute/src/types.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export const InstanceCreateRequestSchema = z.object({
4242
cpu: z.number(),
4343
memory_gb: z.number(),
4444
metadata: z.record(z.unknown()).optional(),
45-
// Per-VM endpoint labels applied to the VM's network endpoint for
46-
// network-policy selection. Distinct from metadata, which is
47-
// observability-only.
48-
network_labels: z.record(z.string()).optional(),
45+
// Per-instance identity labels; the provider promotes a configured subset
46+
// to network-policy selection. Distinct from metadata, which is
47+
// observability-only and never selected on.
48+
labels: z.record(z.string()).optional(),
4949
});
5050
export type InstanceCreateRequest = z.infer<typeof InstanceCreateRequestSchema>;
5151

@@ -70,10 +70,10 @@ export const SnapshotRestoreRequestSchema = z.object({
7070
metadata: z.record(z.string()),
7171
cpu: z.number(),
7272
memory_gb: z.number(),
73-
// Per-VM endpoint labels applied to the restored endpoint for network-policy
74-
// selection. A restored VM must carry the same policy labels as a
75-
// freshly-booted one or its egress allows are lost.
76-
network_labels: z.record(z.string()).optional(),
73+
// Per-instance identity labels; the caller must resupply the same set as on
74+
// create. The provider doesn't persist them across a snapshot, so omitting
75+
// them drops the restored run's policy-based network selection.
76+
labels: z.record(z.string()).optional(),
7777
});
7878
export type SnapshotRestoreRequest = z.infer<typeof SnapshotRestoreRequestSchema>;
7979

0 commit comments

Comments
 (0)