mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 12:28:20 +00:00
move catch outside of the TX
This commit is contained in:
@@ -578,10 +578,10 @@ export const pamAccountServiceFactory = ({
|
|||||||
for (let i = 0; i < accounts.length; i += ROTATION_CONCURRENCY_LIMIT) {
|
for (let i = 0; i < accounts.length; i += ROTATION_CONCURRENCY_LIMIT) {
|
||||||
const batch = accounts.slice(i, i + ROTATION_CONCURRENCY_LIMIT);
|
const batch = accounts.slice(i, i + ROTATION_CONCURRENCY_LIMIT);
|
||||||
|
|
||||||
const rotationPromises = batch.map(async (account) =>
|
const rotationPromises = batch.map(async (account) => {
|
||||||
pamAccountDAL.transaction(async (tx) => {
|
|
||||||
let logResourceType = "unknown";
|
let logResourceType = "unknown";
|
||||||
try {
|
try {
|
||||||
|
await pamAccountDAL.transaction(async (tx) => {
|
||||||
const resource = await pamResourceDAL.findById(account.resourceId, tx);
|
const resource = await pamResourceDAL.findById(account.resourceId, tx);
|
||||||
if (!resource || !resource.encryptedRotationAccountCredentials) return;
|
if (!resource || !resource.encryptedRotationAccountCredentials) return;
|
||||||
logResourceType = resource.resourceType;
|
logResourceType = resource.resourceType;
|
||||||
@@ -645,6 +645,7 @@ export const pamAccountServiceFactory = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error, `Failed to rotate credentials for account [accountId=${account.id}]`);
|
logger.error(error, `Failed to rotate credentials for account [accountId=${account.id}]`);
|
||||||
|
|
||||||
@@ -659,14 +660,10 @@ export const pamAccountServiceFactory = ({
|
|||||||
plainText: Buffer.from(errorMessage)
|
plainText: Buffer.from(errorMessage)
|
||||||
});
|
});
|
||||||
|
|
||||||
await pamAccountDAL.updateById(
|
await pamAccountDAL.updateById(account.id, {
|
||||||
account.id,
|
|
||||||
{
|
|
||||||
rotationStatus: "failed",
|
rotationStatus: "failed",
|
||||||
encryptedLastRotationMessage: encryptedMessage
|
encryptedLastRotationMessage: encryptedMessage
|
||||||
},
|
});
|
||||||
tx
|
|
||||||
);
|
|
||||||
|
|
||||||
await auditLogService.createAuditLog({
|
await auditLogService.createAuditLog({
|
||||||
projectId: account.projectId,
|
projectId: account.projectId,
|
||||||
@@ -685,11 +682,8 @@ export const pamAccountServiceFactory = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
);
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await Promise.all(rotationPromises);
|
await Promise.all(rotationPromises);
|
||||||
|
|||||||
Reference in New Issue
Block a user