Avoid breaking the DequeuedMessage schema
⚒️ Publish Worker (v4) / build (supervisor) (push) Has been cancelled
⚒️ Publish Worker (v4) / build (supervisor) (push) Has been cancelled
This commit is contained in:
@@ -244,6 +244,12 @@ class ManagedSupervisor {
|
||||
}
|
||||
|
||||
try {
|
||||
if (!message.deployment.friendlyId) {
|
||||
// mostly a type guard, deployments always exists for deployed environments
|
||||
// a proper fix would be to use a discriminated union schema to differentiate between dequeued runs in dev and in deployed environments.
|
||||
throw new Error("Deployment is missing");
|
||||
}
|
||||
|
||||
await this.workloadManager.create({
|
||||
dequeuedAt: message.dequeuedAt,
|
||||
envId: message.environment.id,
|
||||
@@ -252,8 +258,8 @@ class ManagedSupervisor {
|
||||
machine: message.run.machine,
|
||||
orgId: message.organization.id,
|
||||
projectId: message.project.id,
|
||||
deploymentId: message.deployment.friendlyId,
|
||||
deploymentVersion: message.deployment.version,
|
||||
deploymentFriendlyId: message.deployment.friendlyId,
|
||||
deploymentVersion: message.backgroundWorker.version,
|
||||
runId: message.run.id,
|
||||
runFriendlyId: message.run.friendlyId,
|
||||
version: message.version,
|
||||
|
||||
@@ -72,7 +72,7 @@ export class DockerWorkloadManager implements WorkloadManager {
|
||||
`TRIGGER_DEQUEUED_AT_MS=${opts.dequeuedAt.getTime()}`,
|
||||
`TRIGGER_POD_SCHEDULED_AT_MS=${Date.now()}`,
|
||||
`TRIGGER_ENV_ID=${opts.envId}`,
|
||||
`TRIGGER_DEPLOYMENT_ID=${opts.deploymentId}`,
|
||||
`TRIGGER_DEPLOYMENT_ID=${opts.deploymentFriendlyId}`,
|
||||
`TRIGGER_DEPLOYMENT_VERSION=${opts.deploymentVersion}`,
|
||||
`TRIGGER_RUN_ID=${opts.runFriendlyId}`,
|
||||
`TRIGGER_SNAPSHOT_ID=${opts.snapshotFriendlyId}`,
|
||||
|
||||
@@ -125,7 +125,7 @@ export class KubernetesWorkloadManager implements WorkloadManager {
|
||||
},
|
||||
{
|
||||
name: "TRIGGER_DEPLOYMENT_ID",
|
||||
value: opts.deploymentId,
|
||||
value: opts.deploymentFriendlyId,
|
||||
},
|
||||
{
|
||||
name: "TRIGGER_DEPLOYMENT_VERSION",
|
||||
|
||||
@@ -29,7 +29,7 @@ export interface WorkloadManagerCreateOptions {
|
||||
envType: EnvironmentType;
|
||||
orgId: string;
|
||||
projectId: string;
|
||||
deploymentId: string;
|
||||
deploymentFriendlyId: string;
|
||||
deploymentVersion: string;
|
||||
runId: string;
|
||||
runFriendlyId: string;
|
||||
|
||||
@@ -562,10 +562,9 @@ export class DequeueSystem {
|
||||
// TODO: use a discriminated union schema to differentiate between dequeued runs in dev and in deployed environments.
|
||||
// Would help make the typechecking stricter
|
||||
deployment: {
|
||||
id: result.deployment?.id ?? "NO_DEPLOYMENT_DEV_ENV",
|
||||
friendlyId: result.deployment?.friendlyId ?? "NO_DEPLOYMENT_DEV_ENV",
|
||||
version: result.deployment?.version ?? "NO_DEPLOYMENT_DEV_ENV",
|
||||
imagePlatform: result.deployment?.imagePlatform ?? "NO_DEPLOYMENT_DEV_ENV",
|
||||
id: result.deployment?.id,
|
||||
friendlyId: result.deployment?.friendlyId,
|
||||
imagePlatform: result.deployment?.imagePlatform,
|
||||
},
|
||||
run: {
|
||||
id: lockedTaskRun.id,
|
||||
|
||||
@@ -246,9 +246,8 @@ export const DequeuedMessage = z.object({
|
||||
version: z.string(),
|
||||
}),
|
||||
deployment: z.object({
|
||||
id: z.string(),
|
||||
friendlyId: z.string(),
|
||||
version: z.string(),
|
||||
id: z.string().optional(),
|
||||
friendlyId: z.string().optional(),
|
||||
imagePlatform: z.string().optional(),
|
||||
}),
|
||||
run: z.object({
|
||||
|
||||
Reference in New Issue
Block a user