fix: resolving provider not found error for secret rotation

This commit is contained in:
=
2024-07-03 20:39:02 +05:30
parent 3ac6b7be65
commit d7023881e5
2 changed files with 4 additions and 4 deletions
@@ -331,7 +331,7 @@ export const secretRotationQueueFactory = ({
logger.info("Finished rotating: rotation id: ", rotationId); logger.info("Finished rotating: rotation id: ", rotationId);
} catch (error) { } catch (error) {
logger.error(error); logger.error(error, "Failed to execute secret rotation");
if (error instanceof DisableRotationErrors) { if (error instanceof DisableRotationErrors) {
if (job.id) { if (job.id) {
await queue.stopRepeatableJobByJobId(QueueName.SecretRotation, job.id); await queue.stopRepeatableJobByJobId(QueueName.SecretRotation, job.id);
@@ -133,7 +133,7 @@ export const secretRotationServiceFactory = ({
creds: [] creds: []
}; };
const encData = infisicalSymmetricEncypt(JSON.stringify(unencryptedData)); const encData = infisicalSymmetricEncypt(JSON.stringify(unencryptedData));
const secretRotation = secretRotationDAL.transaction(async (tx) => { const secretRotation = await secretRotationDAL.transaction(async (tx) => {
const doc = await secretRotationDAL.create( const doc = await secretRotationDAL.create(
{ {
provider, provider,
@@ -148,13 +148,13 @@ export const secretRotationServiceFactory = ({
}, },
tx tx
); );
await secretRotationQueue.addToQueue(doc.id, doc.interval);
const outputSecretMapping = await secretRotationDAL.secretOutputInsertMany( const outputSecretMapping = await secretRotationDAL.secretOutputInsertMany(
Object.entries(outputs).map(([key, secretId]) => ({ key, secretId, rotationId: doc.id })), Object.entries(outputs).map(([key, secretId]) => ({ key, secretId, rotationId: doc.id })),
tx tx
); );
return { ...doc, outputs: outputSecretMapping, environment: folder.environment }; return { ...doc, outputs: outputSecretMapping, environment: folder.environment };
}); });
await secretRotationQueue.addToQueue(secretRotation.id, secretRotation.interval);
return secretRotation; return secretRotation;
}; };
@@ -212,9 +212,9 @@ export const secretRotationServiceFactory = ({
); );
const deletedDoc = await secretRotationDAL.transaction(async (tx) => { const deletedDoc = await secretRotationDAL.transaction(async (tx) => {
const strat = await secretRotationDAL.deleteById(rotationId, tx); const strat = await secretRotationDAL.deleteById(rotationId, tx);
await secretRotationQueue.removeFromQueue(strat.id, strat.interval);
return strat; return strat;
}); });
await secretRotationQueue.removeFromQueue(deletedDoc.id, deletedDoc.interval);
return { ...doc, ...deletedDoc }; return { ...doc, ...deletedDoc };
}; };