Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions worker/src/utils/isolated-volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ export class IsolatedContainerVolume {
}
}

/**
* Derives the deterministic volume name for a given tenant and run.
* Downstream components can use this to reference an existing volume
* created by an upstream component in the same workflow execution.
*
* @param tenantId - Tenant identifier
* @param runId - Unique run/execution identifier
* @returns The volume name (e.g., `tenant-foo-run-bar`)
*/
static deriveVolumeName(tenantId: string, runId: string): string {
return `tenant-${tenantId}-run-${runId}`;
}

/**
* Creates the isolated volume and populates it with files.
*
Expand All @@ -72,9 +85,9 @@ export class IsolatedContainerVolume {
});
}

// Create unique volume name with timestamp to prevent collisions
const timestamp = Date.now();
this.volumeName = `tenant-${this.tenantId}-run-${this.runId}-${timestamp}`;
// Create deterministic volume name from tenantId + runId
// runId is unique per workflow execution, so no timestamp needed
this.volumeName = IsolatedContainerVolume.deriveVolumeName(this.tenantId, this.runId);

try {
// Create the volume with labels for tracking
Expand Down