From d9c55a6bdfc0cb3a20fee74f179c49d912cc0990 Mon Sep 17 00:00:00 2001 From: Jeff McCoy Date: Fri, 22 Dec 2023 00:53:56 -0600 Subject: [PATCH 1/2] fix: bind debug logs to fluent-client watch log handler --- src/lib/watch-processor.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/watch-processor.ts b/src/lib/watch-processor.ts index a41eddf5..f4c65c6b 100644 --- a/src/lib/watch-processor.ts +++ b/src/lib/watch-processor.ts @@ -3,8 +3,8 @@ import { K8s } from "kubernetes-fluent-client"; import { WatchPhase } from "kubernetes-fluent-client/dist/fluent/types"; - import { WatchCfg } from "kubernetes-fluent-client/dist/fluent/watch"; + import { Capability } from "./capability"; import Log from "./logger"; import { Binding, Event } from "./types"; @@ -37,15 +37,19 @@ async function runBinding(binding: Binding) { Log.error(e, "Watch failed after 3 attempts, giving up"); process.exit(1); }, + // pino binding explodes unless we wrap it + logFn: (obj: unknown, msg?: string, ...args: unknown[]) => Log.debug(obj, msg, ...args), }; // Watch the resource - await K8s(binding.model, binding.filters).Watch((obj, type) => { + await K8s(binding.model, binding.filters).Watch(async (obj, type) => { + Log.debug(obj, `Watch event ${type} received`); + // If the type matches the phase, call the watch callback if (phaseMatch.includes(type)) { try { - // This may be a promise, but we don't need to wait for it - void binding.watchCallback?.(obj, type); + // Perform the watch callback + await binding.watchCallback?.(obj, type); } catch (e) { // Errors in the watch callback should not crash the controller Log.error(e, "Error executing watch callback"); From 302d92c5f7d06b71e01e582ba881e594df8c07a5 Mon Sep 17 00:00:00 2001 From: Jeff McCoy Date: Fri, 22 Dec 2023 00:59:52 -0600 Subject: [PATCH 2/2] add kfc to debug source maps --- src/templates/settings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/templates/settings.json b/src/templates/settings.json index cb2bf502..240cfc43 100644 --- a/src/templates/settings.json +++ b/src/templates/settings.json @@ -3,6 +3,7 @@ "enableTurboSourcemaps": true, "resolveSourceMapLocations": [ "${workspaceFolder}/**", + "node_modules/kubernetes-fluent-client/**", "node_modules/pepr/**" ] }