From a536ad49eaaed50362a1ce88c547f7a382228241 Mon Sep 17 00:00:00 2001 From: Joe Longendyke Date: Mon, 6 Dec 2021 12:37:28 +0900 Subject: [PATCH] Remove fatal error from docker secrets This commit fixes #242 by catching the error thrown by getSecrets(). The underlying issue exists in docker-secret and has to do with the serviceAccount secret installed automatically by kubernetes. --- package-lock.json | 2 +- utils/init/initDockerSecrets.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index ef91c52..2b444e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7754,4 +7754,4 @@ "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==" } } -} \ No newline at end of file +} diff --git a/utils/init/initDockerSecrets.js b/utils/init/initDockerSecrets.js index 4a66320..dda3b2a 100644 --- a/utils/init/initDockerSecrets.js +++ b/utils/init/initDockerSecrets.js @@ -3,14 +3,18 @@ const Logger = require('../Logger'); const logger = new Logger(); const initDockerSecrets = () => { - const secrets = getSecrets(); + try { + const secrets = getSecrets(); - for (const property in secrets) { - const upperProperty = property.toUpperCase(); + for (const property in secrets) { + const upperProperty = property.toUpperCase(); - process.env[upperProperty] = secrets[property]; + process.env[upperProperty] = secrets[property]; - logger.log(`${upperProperty} was overwritten with docker secret value`); + logger.log(`${upperProperty} was overwritten with docker secret value`); + } + } catch(e) { + logger.log('Failed to initialize docker secrets. Error: ' + e, 'ERROR'); } };