mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 07:26:45 +00:00
Merge pull request #4680 from Infisical/fix/debug-log
feat: added debug log for kms
This commit is contained in:
@@ -742,23 +742,27 @@ export const kmsServiceFactory = ({
|
|||||||
if (!project.kmsSecretManagerEncryptedDataKey) {
|
if (!project.kmsSecretManagerEncryptedDataKey) {
|
||||||
const lock = await keyStore
|
const lock = await keyStore
|
||||||
.acquireLock([KeyStorePrefixes.KmsProjectDataKeyCreation, projectId], 3000, { retryCount: 0 })
|
.acquireLock([KeyStorePrefixes.KmsProjectDataKeyCreation, projectId], 3000, { retryCount: 0 })
|
||||||
.catch(() => null);
|
.catch((err) => {
|
||||||
|
logger.error(err, "KMS. Failed to acquire lock.");
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
await keyStore.waitTillReady({
|
await keyStore.waitTillReady({
|
||||||
key: `${KeyStorePrefixes.WaitUntilReadyKmsProjectDataKeyCreation}${projectId}`,
|
key: `${KeyStorePrefixes.WaitUntilReadyKmsProjectDataKeyCreation}${projectId}`,
|
||||||
keyCheckCb: (val) => val === "true",
|
keyCheckCb: (val) => val === "true",
|
||||||
waitingCb: () => logger.debug("KMS. Waiting for secret manager data key to be created"),
|
waitingCb: () => logger.info("KMS. Waiting for secret manager data key to be created"),
|
||||||
delay: 500
|
delay: 500
|
||||||
});
|
});
|
||||||
|
|
||||||
project = await projectDAL.findById(projectId, trx);
|
project = await projectDAL.findById(projectId, trx);
|
||||||
} else {
|
} else {
|
||||||
|
logger.info(`KMS. Generating KMS key for project ${projectId}`);
|
||||||
const projectDataKey = await (trx || projectDAL).transaction(async (tx) => {
|
const projectDataKey = await (trx || projectDAL).transaction(async (tx) => {
|
||||||
project = await projectDAL.findById(projectId, tx);
|
project = await projectDAL.findById(projectId, tx);
|
||||||
if (project.kmsSecretManagerEncryptedDataKey) {
|
if (project.kmsSecretManagerEncryptedDataKey) {
|
||||||
return;
|
return project.kmsSecretManagerEncryptedDataKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataKey = crypto.randomBytes(32);
|
const dataKey = crypto.randomBytes(32);
|
||||||
|
|||||||
Reference in New Issue
Block a user