From a2902cb16f30c187dbd51b4f79004ab2a5ab5881 Mon Sep 17 00:00:00 2001 From: Barrett LaFrance Date: Wed, 13 Mar 2024 16:53:32 -0500 Subject: [PATCH 1/2] chore: make select log messages more explicit --- journey/pepr-deploy.ts | 2 +- src/lib/filter.ts | 19 ++++++++++++++++++- src/lib/mutate-processor.ts | 4 ++-- src/lib/validate-processor.ts | 4 ++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/journey/pepr-deploy.ts b/journey/pepr-deploy.ts index 8a240d7e..de721953 100644 --- a/journey/pepr-deploy.ts +++ b/journey/pepr-deploy.ts @@ -73,7 +73,7 @@ export function peprDeploy() { await until(() => state.done) // completes only if conditions are met, so... getting here means success! - }, 5000); + }, 10000); }); describe("should display the UUIDs of the deployed modules", testUUID); diff --git a/src/lib/filter.ts b/src/lib/filter.ts index d2d67a53..b1c410ee 100644 --- a/src/lib/filter.ts +++ b/src/lib/filter.ts @@ -51,7 +51,24 @@ export function shouldSkipRequest(binding: Binding, req: AdmissionRequest, capab (combinedNamespaces.length && !combinedNamespaces.includes(req.namespace || "")) || (!namespaces.includes(req.namespace || "") && capabilityNamespaces.length !== 0 && namespaces.length !== 0) ) { - logger.debug("Namespace does not match"); + + let type = "", label = "" + + if (binding.isMutate) { + type = "Mutate" + label = binding.mutateCallback!.name + } + else if (binding.isValidate) { + type = "Validate" + label = binding.validateCallback!.name + } + else if (binding.isWatch) { + type = "Watch" + label = binding.watchCallback!.name + } + + logger.debug(`${type} binding (${label}) does not match request namespace "${req.namespace}"`) + return true; } diff --git a/src/lib/mutate-processor.ts b/src/lib/mutate-processor.ts index 97532b9e..a619f723 100644 --- a/src/lib/mutate-processor.ts +++ b/src/lib/mutate-processor.ts @@ -55,7 +55,7 @@ export async function mutateProcessor( } const label = action.mutateCallback.name; - Log.info(actionMetadata, `Processing matched action ${label}`); + Log.info(actionMetadata, `Processing mutation action (${label})`); matchedAction = true; @@ -79,7 +79,7 @@ export async function mutateProcessor( // Run the action await action.mutateCallback(wrapped); - Log.info(actionMetadata, `Action succeeded`); + Log.info(actionMetadata, `Mutation action succeeded (${label})`); // Add annotations to the request to indicate that the capability succeeded updateStatus("succeeded"); diff --git a/src/lib/validate-processor.ts b/src/lib/validate-processor.ts index 7d7f8f3a..c850f2cc 100644 --- a/src/lib/validate-processor.ts +++ b/src/lib/validate-processor.ts @@ -46,7 +46,7 @@ export async function validateProcessor( } const label = action.validateCallback.name; - Log.info(actionMetadata, `Processing matched action ${label}`); + Log.info(actionMetadata, `Processing validation action (${label})`); try { // Run the validation callback, if it fails set allowed to false @@ -61,7 +61,7 @@ export async function validateProcessor( }; } - Log.info(actionMetadata, `Validation Action completed: ${resp.allowed ? "allowed" : "denied"}`); + Log.info(actionMetadata, `Validation action complete (${label}): ${resp.allowed ? "allowed" : "denied"}`); } catch (e) { // If any validation throws an error, note the failure in the Response Log.error(actionMetadata, `Action failed: ${JSON.stringify(e)}`); From d9d17e1818f5ddf5963f5806a837a6f170d84fcb Mon Sep 17 00:00:00 2001 From: Barrett LaFrance Date: Wed, 13 Mar 2024 17:01:03 -0500 Subject: [PATCH 2/2] fix: format --- src/lib/filter.ts | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/lib/filter.ts b/src/lib/filter.ts index b1c410ee..42194537 100644 --- a/src/lib/filter.ts +++ b/src/lib/filter.ts @@ -51,23 +51,21 @@ export function shouldSkipRequest(binding: Binding, req: AdmissionRequest, capab (combinedNamespaces.length && !combinedNamespaces.includes(req.namespace || "")) || (!namespaces.includes(req.namespace || "") && capabilityNamespaces.length !== 0 && namespaces.length !== 0) ) { - - let type = "", label = "" + let type = ""; + let label = ""; if (binding.isMutate) { - type = "Mutate" - label = binding.mutateCallback!.name - } - else if (binding.isValidate) { - type = "Validate" - label = binding.validateCallback!.name - } - else if (binding.isWatch) { - type = "Watch" - label = binding.watchCallback!.name + type = "Mutate"; + label = binding.mutateCallback!.name; + } else if (binding.isValidate) { + type = "Validate"; + label = binding.validateCallback!.name; + } else if (binding.isWatch) { + type = "Watch"; + label = binding.watchCallback!.name; } - logger.debug(`${type} binding (${label}) does not match request namespace "${req.namespace}"`) + logger.debug(`${type} binding (${label}) does not match request namespace "${req.namespace}"`); return true; }