Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
give restore lease revocations their own job id
DimitrisStaratzis4ba4e6a55197
diff --git a/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-queue.ts b/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-queue.tsindex 7baaa6d8fe..7e4e87be8d 100644--- a/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-queue.ts+++ b/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-queue.ts@@ -40,7 +40,7 @@ type TDynamicSecretLeaseQueueServiceFactoryDep = {export type TDynamicSecretLeaseQueueServiceFactory = {pruneDynamicSecret: (dynamicSecretCfgId: string) => Promise<void>;- setLeaseRevocation: (leaseId: string, dynamicSecretId: string, expiryAt: Date) => Promise<void>;+ setLeaseRevocation: (leaseId: string, dynamicSecretId: string, expiryAt: Date, jobId?: string) => Promise<void>;unsetLeaseRevocation: (leaseId: string) => Promise<void>;queueFailedRevocation: (leaseId: string, dynamicSecretId: string) => Promise<void>;};@@ -74,13 +74,13 @@ export const dynamicSecretLeaseQueueServiceFactory = ({);};- const setLeaseRevocation = async (leaseId: string, dynamicSecretId: string, expiryAt: Date) => {+ const setLeaseRevocation = async (leaseId: string, dynamicSecretId: string, expiryAt: Date, jobId = leaseId) => {await queueService.queue(QueueName.DynamicSecretRevocation,QueueJobs.DynamicSecretRevocation,{ leaseId, dynamicSecretId },{- jobId: leaseId,+ jobId,delay: Number(expiryAt) - Date.now(),attempts: 3,backoff: {diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.tsindex d3c4fa867d..76465012a8 100644--- a/backend/src/services/project/project-service.ts+++ b/backend/src/services/project/project-service.ts@@ -969,12 +969,18 @@ export const projectServiceFactory = ({// Revoking a lease that expired while the project was deleted fails because the project can't be// resolved, and its retries may have run out, so queue those revocations again. They're queued// before the restore so a queue failure leaves the project deleted and the restore retryable, and- // delayed so they run after it commits.+ // delayed so they run after it commits. Their own job id keeps an older retry, which stops the job+ // under the lease id when it gives up, from cancelling them.const expiredLeases = await dynamicSecretLeaseDAL.findExpiredByProjectId(project.id);const revokeAt = new Date(Date.now() + 60_000);await Promise.all(expiredLeases.map((lease) =>- dynamicSecretQueueService.setLeaseRevocation(lease.id, lease.dynamicSecretId, revokeAt)+ dynamicSecretQueueService.setLeaseRevocation(+ lease.id,+ lease.dynamicSecretId,+ revokeAt,+ `${lease.id}-restore`+ )));