diff --git a/docs/030_user-guide/120_customization.md b/docs/030_user-guide/120_customization.md index 7b8747da8..107f83181 100644 --- a/docs/030_user-guide/120_customization.md +++ b/docs/030_user-guide/120_customization.md @@ -37,7 +37,7 @@ The Watch configuration is a part of the Pepr module that allows you to watch fo | `PEPR_RETRYMAX` | The maximum number of times to retry the watch, the retry count is reset on success. | default: `"5"` | | `PEPR_RETRYDELAYSECONDS` | The delay between retries in seconds. | default: `"10"` | | `PEPR_RESYNCINTERVALSECONDS` | Amount of seconds to wait before a forced-resyncing of the watch list | default: `"300"` (5 mins) | -| `PEPR_ALLOWWATCHBOOKMARKS` | Whether to allow [watch bookmarks](https://kubernetes.io/docs/reference/using-api/api-concepts/#watch-bookmarks).| default: `"true"` or `"false"` | + ## Customizing with Helm diff --git a/package-lock.json b/package-lock.json index 0e1f95a45..c6b8bfe89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@types/ramda": "0.30.0", "express": "4.19.2", "fast-json-patch": "3.1.1", - "kubernetes-fluent-client": "2.5.1", + "kubernetes-fluent-client": "2.6.0", "pino": "9.1.0", "pino-pretty": "11.0.0", "prom-client": "15.1.2", @@ -5718,9 +5718,9 @@ } }, "node_modules/kubernetes-fluent-client": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/kubernetes-fluent-client/-/kubernetes-fluent-client-2.5.1.tgz", - "integrity": "sha512-qxascLHTHjGnEl/ulhKl114nHhb8mSsreZXW5gluFvQVhDW3KBSBKzPEZZUwLE7/UergnDvh/sy1uvqUrspHLQ==", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/kubernetes-fluent-client/-/kubernetes-fluent-client-2.6.0.tgz", + "integrity": "sha512-sE8i6Yjlne/KWr2klZTOih0RADMHmVZQt7L7+x+RPYT4JHXQUlY8w43y4/4PXq9XkVR5cwj52oj7ouqWTZ3SCw==", "dependencies": { "@kubernetes/client-node": "1.0.0-rc4", "byline": "5.0.0", diff --git a/package.json b/package.json index 61c0df9b9..41b0006c8 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@types/ramda": "0.30.0", "express": "4.19.2", "fast-json-patch": "3.1.1", - "kubernetes-fluent-client": "2.5.1", + "kubernetes-fluent-client": "2.6.0", "pino": "9.1.0", "pino-pretty": "11.0.0", "prom-client": "15.1.2", diff --git a/src/lib/watch-processor.test.ts b/src/lib/watch-processor.test.ts index 03ad47dac..e484862c5 100644 --- a/src/lib/watch-processor.test.ts +++ b/src/lib/watch-processor.test.ts @@ -121,17 +121,6 @@ describe("WatchProcessor", () => { expect(exitSpy).toHaveBeenCalledWith(1); }); - it("should watch for the resource_update event", async () => { - mockEvents.mockImplementation((eventName: string | symbol, listener: (msg: string) => void) => { - if (eventName === WatchEvent.RESOURCE_VERSION) { - expect(listener).toBeInstanceOf(Function); - listener("45"); - } - }); - - setupWatch(capabilities); - }); - it("should watch for the give_up event", async () => { const exitSpy = jest.spyOn(process, "exit").mockImplementation(() => { return undefined as never; @@ -227,11 +216,21 @@ describe("logEvent function", () => { expect(Log.debug).toHaveBeenCalledWith(`Watch event ${WatchEvent.CONNECT} received. ${url}.`); }); - it("should handle BOOKMARK events", () => { - const mockObj = { id: "123", type: "Pod" } as KubernetesObject; - const message = "Changes up to the given resourceVersion have been sent"; - logEvent(WatchEvent.BOOKMARK, message, mockObj); - expect(Log.debug).toHaveBeenCalledWith(mockObj, `Watch event ${WatchEvent.BOOKMARK} received. ${message}.`); + it("should handle LIST_ERROR events", () => { + const message = "LIST_ERROR"; + logEvent(WatchEvent.LIST_ERROR, message); + expect(Log.debug).toHaveBeenCalledWith(`Watch event ${WatchEvent.LIST_ERROR} received. ${message}.`); + }); + it("should handle LIST events", () => { + const podList = { + kind: "PodList", + apiVersion: "v1", + metadata: { resourceVersion: "10245" }, + items: [], + }; + const message = JSON.stringify(podList, undefined, 2); + logEvent(WatchEvent.LIST, message); + expect(Log.debug).toHaveBeenCalledWith(`Watch event ${WatchEvent.LIST} received. ${message}.`); }); it("should handle DATA_ERROR events", () => { diff --git a/src/lib/watch-processor.ts b/src/lib/watch-processor.ts index 126ff2e7e..f7c2af770 100644 --- a/src/lib/watch-processor.ts +++ b/src/lib/watch-processor.ts @@ -15,7 +15,6 @@ const watchCfg: WatchCfg = { resyncIntervalSec: process.env.PEPR_RESYNCINTERVALSECONDS ? parseInt(process.env.PEPR_RESYNCINTERVALSECONDS, 10) : 300, - allowWatchBookmarks: process.env.PEPR_ALLOWWATCHBOOKMARKS === "false" ? false : true, }; // Map the event to the watch phase @@ -95,14 +94,7 @@ async function runBinding(binding: Binding, capabilityNamespaces: string[]) { watcher.events.on(WatchEvent.CONNECT, url => logEvent(WatchEvent.CONNECT, url)); - watcher.events.on(WatchEvent.BOOKMARK, obj => - logEvent(WatchEvent.BOOKMARK, "Changes up to the given resourceVersion have been sent", obj), - ); - watcher.events.on(WatchEvent.DATA_ERROR, err => logEvent(WatchEvent.DATA_ERROR, err.message)); - watcher.events.on(WatchEvent.RESOURCE_VERSION, resourceVersion => - logEvent(WatchEvent.RESOURCE_VERSION, `${resourceVersion}`), - ); watcher.events.on(WatchEvent.RECONNECT, (err, retryCount) => logEvent(WatchEvent.RECONNECT, err ? `Reconnecting after ${retryCount} attempts` : ""), ); @@ -110,9 +102,9 @@ async function runBinding(binding: Binding, capabilityNamespaces: string[]) { watcher.events.on(WatchEvent.GIVE_UP, err => logEvent(WatchEvent.GIVE_UP, err.message)); watcher.events.on(WatchEvent.ABORT, err => logEvent(WatchEvent.ABORT, err.message)); watcher.events.on(WatchEvent.OLD_RESOURCE_VERSION, err => logEvent(WatchEvent.OLD_RESOURCE_VERSION, err)); - watcher.events.on(WatchEvent.RESYNC, err => logEvent(WatchEvent.RESYNC, err.message)); watcher.events.on(WatchEvent.NETWORK_ERROR, err => logEvent(WatchEvent.NETWORK_ERROR, err.message)); - + watcher.events.on(WatchEvent.LIST_ERROR, err => logEvent(WatchEvent.LIST_ERROR, err.message)); + watcher.events.on(WatchEvent.LIST, list => logEvent(WatchEvent.LIST, JSON.stringify(list, undefined, 2))); // Start the watch try { await watcher.start();