From 5e9f2bc063f2fb25d0c6ab73ef5819d81901ce37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20La=C5=A1=C5=A1=C3=A1k?= <73712209+mlassak@users.noreply.github.com> Date: Wed, 5 Oct 2022 23:58:50 +0200 Subject: [PATCH] modified logging of 404s for pvc, configmaps and secrets (#618) --- backend/src/routes/api/configmaps/index.ts | 4 +++- backend/src/routes/api/pvc/index.ts | 8 +++++--- backend/src/routes/api/secrets/index.ts | 12 +++++++----- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/backend/src/routes/api/configmaps/index.ts b/backend/src/routes/api/configmaps/index.ts index edac83342a..7c97e33d8b 100644 --- a/backend/src/routes/api/configmaps/index.ts +++ b/backend/src/routes/api/configmaps/index.ts @@ -21,7 +21,9 @@ module.exports = async (fastify: KubeFastifyInstance) => { e.message || res.message, e.code, ); - fastify.log.error(`Configmap ${cmName} could not be read, ${error}`); + if (res.statusCode !== 404) { + fastify.log.error(`Configmap ${cmName} could not be read, ${error}`); + } throw error; }); }, diff --git a/backend/src/routes/api/pvc/index.ts b/backend/src/routes/api/pvc/index.ts index 360ea4d072..b4655209c4 100644 --- a/backend/src/routes/api/pvc/index.ts +++ b/backend/src/routes/api/pvc/index.ts @@ -20,9 +20,11 @@ module.exports = async (fastify: KubeFastifyInstance) => { ); return pvcResponse.body; } catch (e) { - fastify.log.error( - `PVC ${pvcName} could not be read, ${e.response?.body?.message || e.message || e}`, - ); + if (e.statusCode !== 404) { + fastify.log.error( + `PVC ${pvcName} could not be read, ${e.response?.body?.message || e.message || e}`, + ); + } reply.send(e); } }, diff --git a/backend/src/routes/api/secrets/index.ts b/backend/src/routes/api/secrets/index.ts index c5f67383b3..42127d100b 100644 --- a/backend/src/routes/api/secrets/index.ts +++ b/backend/src/routes/api/secrets/index.ts @@ -20,11 +20,13 @@ module.exports = async (fastify: KubeFastifyInstance) => { ); return secretResponse.body; } catch (e) { - fastify.log.error( - `Secret ${secretName} could not be read, ${ - e.response?.body?.message || e.message || e - }`, - ); + if (e.statusCode !== 404) { + fastify.log.error( + `Secret ${secretName} could not be read, ${ + e.response?.body?.message || e.message || e + }`, + ); + } reply.send(e); } },