Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

only register last failed retry for dynamic secrets

Matheus Nogueira9d374fe503e1
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.ts
index 05568db225..360d3d1473 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
@@ -252,9 +252,6 @@ export const dynamicSecretLeaseQueueServiceFactory = ({
status: DynamicSecretStatus.FailedDeletion,
statusDetails: `${(error as Error)?.message?.slice(0, 255)} - Retrying automatically`
});
- if (providerType) {
- recordDynamicSecretOrphanedLeaseMetric({ provider: providerType });
- }
// only add to retry queue if this is not a retry, and if the error is not a DisableRotationErrors error
if (!isRetry && !(error instanceof DisableRotationErrors)) {
@@ -271,6 +268,10 @@ export const dynamicSecretLeaseQueueServiceFactory = ({
// we dont have to stop the retry job, because if we hit this point, its the last attempt and BullMQ will stop it after this point
await queueService.stopJobById(QueueName.DynamicSecretRevocation, leaseId);
+ if (providerType) {
+ recordDynamicSecretOrphanedLeaseMetric({ provider: providerType });
+ }
+
await $queueDynamicSecretLeaseRevocationFailedEmail(leaseId, dynamicSecretId);
}
}