diff --git a/package-lock.json b/package-lock.json index 5cee0dc33..15dd7112a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "license": "private", "dependencies": { "@aws-sdk/client-ecr": "^3.817.0", - "@kubernetes/client-node": "^0.22.3", + "@kubernetes/client-node": "^1.0.0", "@snyk/dep-graph": "^2.9.0", "async": "^3.2.6", "bunyan": "^1.8.15", @@ -2224,25 +2224,46 @@ } }, "node_modules/@kubernetes/client-node": { - "version": "0.22.3", - "resolved": "https://registry.npmjs.org/@kubernetes/client-node/-/client-node-0.22.3.tgz", - "integrity": "sha512-dG8uah3+HDJLpJEESshLRZlAZ4PgDeV9mZXT0u1g7oy4KMRzdZ7n5g0JEIlL6QhK51/2ztcIqURAnjfjJt6Z+g==", - "dependencies": { - "byline": "^5.0.0", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@kubernetes/client-node/-/client-node-1.0.0.tgz", + "integrity": "sha512-a8NSvFDSHKFZ0sR1hbPSf8IDFNJwctEU5RodSCNiq/moRXWmrdmqhb1RRQzF+l+TSBaDgHw3YsYNxxE92STBzw==", + "license": "Apache-2.0", + "dependencies": { + "@types/js-yaml": "^4.0.1", + "@types/node": "^22.0.0", + "@types/node-fetch": "^2.6.9", + "@types/stream-buffers": "^3.0.3", + "@types/tar": "^6.1.1", + "@types/ws": "^8.5.4", + "form-data": "^4.0.0", "isomorphic-ws": "^5.0.0", "js-yaml": "^4.1.0", "jsonpath-plus": "^10.2.0", - "request": "^2.88.0", + "node-fetch": "^2.6.9", + "openid-client": "^6.1.3", "rfc4648": "^1.3.0", "stream-buffers": "^3.0.2", "tar": "^7.0.0", - "tslib": "^2.4.1", + "tmp-promise": "^3.0.2", + "tslib": "^2.5.0", "ws": "^8.18.0" - }, - "optionalDependencies": { - "openid-client": "^6.1.3" } }, + "node_modules/@kubernetes/client-node/node_modules/@types/node": { + "version": "22.16.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.16.5.tgz", + "integrity": "sha512-bJFoMATwIGaxxx8VJPeM8TonI8t579oRvgAuT8zFugJsJZgzqv0Fu8Mhp68iecjzG7cnN3mO2dJQ5uUM2EFrgQ==", + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@kubernetes/client-node/node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "license": "MIT" + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -3209,6 +3230,12 @@ "pretty-format": "^26.0.0" } }, + "node_modules/@types/js-yaml": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz", + "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==", + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -3255,6 +3282,16 @@ "undici-types": "~6.19.2" } }, + "node_modules/@types/node-fetch": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.12.tgz", + "integrity": "sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "form-data": "^4.0.0" + } + }, "node_modules/@types/responselike": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", @@ -3283,6 +3320,34 @@ "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==", "dev": true }, + "node_modules/@types/stream-buffers": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@types/stream-buffers/-/stream-buffers-3.0.7.tgz", + "integrity": "sha512-azOCy05sXVXrO+qklf0c/B07H/oHaIuDDAiHPVwlk3A9Ek+ksHyTeMajLZl3r76FxpPpxem//4Te61G1iW3Giw==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/tar": { + "version": "6.1.13", + "resolved": "https://registry.npmjs.org/@types/tar/-/tar-6.1.13.tgz", + "integrity": "sha512-IznnlmU5f4WcGTh2ltRu/Ijpmk8wiWXfF0VA4s+HPjHZgvFggk1YaIkbo5krX/zUCzWF8N/l4+W/LNxnvAJ8nw==", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "minipass": "^4.0.0" + } + }, + "node_modules/@types/tar/node_modules/minipass": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz", + "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==", + "license": "ISC", + "engines": { + "node": ">=8" + } + }, "node_modules/@types/treeify": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@types/treeify/-/treeify-1.0.3.tgz", @@ -3297,6 +3362,15 @@ "@types/node": "*" } }, + "node_modules/@types/ws": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", + "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/yargs": { "version": "17.0.33", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", @@ -3894,14 +3968,6 @@ "safer-buffer": "~2.1.0" } }, - "node_modules/assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/astral-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", @@ -3919,20 +3985,8 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, - "node_modules/aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==", - "engines": { - "node": "*" - } - }, - "node_modules/aws4": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz", - "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==" + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" }, "node_modules/b4a": { "version": "1.6.7", @@ -4333,14 +4387,6 @@ "safe-json-stringify": "~1" } }, - "node_modules/byline": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/byline/-/byline-5.0.0.tgz", - "integrity": "sha512-s6webAy+R4SR8XVuJWt2V2rGvhnrhxN+9S15GNuTK3wKPOXFF6RNc+8ug2XhH+2s4f+uudG4kUVYmYOQWL2g0Q==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/cacheable-lookup": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", @@ -4470,11 +4516,6 @@ } ] }, - "node_modules/caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==" - }, "node_modules/chalk": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", @@ -4614,6 +4655,7 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", "dependencies": { "delayed-stream": "~1.0.0" }, @@ -4786,17 +4828,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", - "dependencies": { - "assert-plus": "^1.0.0" - }, - "engines": { - "node": ">=0.10" - } - }, "node_modules/debug": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", @@ -4911,6 +4942,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", "engines": { "node": ">=0.4.0" } @@ -5089,15 +5121,6 @@ "safe-buffer": "~5.1.0" } }, - "node_modules/ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", - "dependencies": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" - } - }, "node_modules/ejs": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", @@ -5227,6 +5250,21 @@ "node": ">= 0.4" } }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -5638,19 +5676,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" - }, - "node_modules/extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==", - "engines": [ - "node >=0.6.0" - ] - }, "node_modules/fadge": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/fadge/-/fadge-0.0.1.tgz", @@ -5708,7 +5733,8 @@ "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true }, "node_modules/fast-diff": { "version": "1.3.0", @@ -5739,7 +5765,8 @@ "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true }, "node_modules/fast-levenshtein": { "version": "2.0.6", @@ -5891,25 +5918,20 @@ "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", "dev": true }, - "node_modules/forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==", - "engines": { - "node": "*" - } - }, "node_modules/form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", + "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "license": "MIT", "dependencies": { "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", "mime-types": "^2.1.12" }, "engines": { - "node": ">= 0.12" + "node": ">= 6" } }, "node_modules/from": { @@ -6044,14 +6066,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", - "dependencies": { - "assert-plus": "^1.0.0" - } - }, "node_modules/git-raw-commits": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-4.0.0.tgz", @@ -6211,47 +6225,6 @@ "gunzip-maybe": "bin.js" } }, - "node_modules/har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==", - "engines": { - "node": ">=4" - } - }, - "node_modules/har-validator": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", - "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", - "deprecated": "this library is no longer supported", - "dependencies": { - "ajv": "^6.12.3", - "har-schema": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/har-validator/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/har-validator/node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" - }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -6282,6 +6255,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", @@ -6315,20 +6303,6 @@ "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz", "integrity": "sha512-dTxcvPXqPvXBQpq5dUr6mEMJX4oIEFv6bwom3FDwKRDsuIjjJGANqhBuoAn9c1RQJIdAKav33ED65E2ys+87QQ==" }, - "node_modules/http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", - "dependencies": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - }, - "engines": { - "node": ">=0.8", - "npm": ">=1.3.7" - } - }, "node_modules/http2-wrapper": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", @@ -6615,11 +6589,6 @@ "node": ">=8" } }, - "node_modules/is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" - }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -6638,11 +6607,6 @@ "ws": "*" } }, - "node_modules/isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" - }, "node_modules/istanbul-lib-coverage": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", @@ -7881,7 +7845,6 @@ "version": "6.0.11", "resolved": "https://registry.npmjs.org/jose/-/jose-6.0.11.tgz", "integrity": "sha512-QxG7EaliDARm1O1S8BGakqncGT9s25bKL1WSf6/oa17Tkqwi8D2ZNglqCF+DsYF88/rV66Q/Q2mFAy697E1DUg==", - "optional": true, "funding": { "url": "https://github.com/sponsors/panva" } @@ -7903,11 +7866,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==" - }, "node_modules/jsep": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/jsep/-/jsep-1.4.0.tgz", @@ -7957,11 +7915,6 @@ "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", "dev": true }, - "node_modules/json-schema": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", - "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" - }, "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", @@ -7977,7 +7930,8 @@ "node_modules/json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", + "dev": true }, "node_modules/json5": { "version": "2.2.3", @@ -8044,20 +7998,6 @@ "node": "*" } }, - "node_modules/jsprim": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", - "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", - "dependencies": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.4.0", - "verror": "1.10.0" - }, - "engines": { - "node": ">=0.6.0" - } - }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -8440,6 +8380,7 @@ "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", "engines": { "node": ">= 0.6" } @@ -8448,6 +8389,7 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", "dependencies": { "mime-db": "1.52.0" }, @@ -8636,6 +8578,26 @@ "integrity": "sha512-qN8v/s2PAJwGUtr1/hYTpNKlD6Y9rc4p8KSmJXyGdYGZsDGKXrGThikLFP9OCHFeLeEpQzPwiAtdIvBLqm//Hw==", "dev": true }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -8700,19 +8662,10 @@ "node": ">=8" } }, - "node_modules/oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "engines": { - "node": "*" - } - }, "node_modules/oauth4webapi": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/oauth4webapi/-/oauth4webapi-3.5.1.tgz", "integrity": "sha512-txg/jZQwcbaF7PMJgY7aoxc9QuCxHVFMiEkDIJ60DwDz3PbtXPQnrzo+3X4IRYGChIwWLabRBRpf1k9hO9+xrQ==", - "optional": true, "funding": { "url": "https://github.com/sponsors/panva" } @@ -8779,7 +8732,6 @@ "version": "6.5.0", "resolved": "https://registry.npmjs.org/openid-client/-/openid-client-6.5.0.tgz", "integrity": "sha512-fAfYaTnOYE2kQCqEJGX9KDObW2aw7IQy4jWpU/+3D3WoCFLbix5Hg6qIPQ6Js9r7f8jDUmsnnguRNCSw4wU/IQ==", - "optional": true, "dependencies": { "jose": "^6.0.10", "oauth4webapi": "^3.5.1" @@ -9007,11 +8959,6 @@ "through2": "^2.0.3" } }, - "node_modules/performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" - }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -9331,17 +9278,6 @@ "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", "integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==" }, - "node_modules/psl": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.15.0.tgz", - "integrity": "sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==", - "dependencies": { - "punycode": "^2.3.1" - }, - "funding": { - "url": "https://github.com/sponsors/lupomontero" - } - }, "node_modules/pump": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", @@ -9365,6 +9301,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, "engines": { "node": ">=6" } @@ -9385,19 +9322,6 @@ } ] }, - "node_modules/qs": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", - "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", - "engines": { - "node": ">=0.6" - } - }, - "node_modules/querystringify": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" - }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -9459,46 +9383,6 @@ "url": "https://github.com/sponsors/mysticatea" } }, - "node_modules/request": { - "version": "2.88.2", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", - "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", - "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", - "dependencies": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/request/node_modules/uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", - "bin": { - "uuid": "bin/uuid" - } - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -9517,11 +9401,6 @@ "node": ">=0.10.0" } }, - "node_modules/requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" - }, "node_modules/resolve": { "version": "1.22.10", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", @@ -10122,30 +10001,6 @@ "nan": "^2.20.0" } }, - "node_modules/sshpk": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.18.0.tgz", - "integrity": "sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ==", - "dependencies": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - }, - "bin": { - "sshpk-conv": "bin/sshpk-conv", - "sshpk-sign": "bin/sshpk-sign", - "sshpk-verify": "bin/sshpk-verify" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/stack-utils": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", @@ -10568,6 +10423,15 @@ "node": ">=14.14" } }, + "node_modules/tmp-promise": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/tmp-promise/-/tmp-promise-3.0.3.tgz", + "integrity": "sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ==", + "license": "MIT", + "dependencies": { + "tmp": "^0.2.0" + } + }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -10585,27 +10449,11 @@ "node": ">=8.0" } }, - "node_modules/tough-cookie": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", - "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==", - "dependencies": { - "psl": "^1.1.33", - "punycode": "^2.1.1", - "universalify": "^0.2.0", - "url-parse": "^1.5.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/tough-cookie/node_modules/universalify": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", - "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", - "engines": { - "node": ">= 4.0.0" - } + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" }, "node_modules/treeify": { "version": "1.1.0", @@ -10787,17 +10635,6 @@ "node": ">=0.6.11 <=0.7.0 || >=0.7.3" } }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", - "dependencies": { - "safe-buffer": "^5.0.1" - }, - "engines": { - "node": "*" - } - }, "node_modules/tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", @@ -10907,19 +10744,11 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, "dependencies": { "punycode": "^2.1.0" } }, - "node_modules/url-parse": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", - "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", - "dependencies": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - } - }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -10968,19 +10797,6 @@ "resolved": "https://registry.npmjs.org/varint/-/varint-6.0.0.tgz", "integrity": "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==" }, - "node_modules/verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==", - "engines": [ - "node >=0.6.0" - ], - "dependencies": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - } - }, "node_modules/vscode-languageserver-textdocument": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz", @@ -11000,6 +10816,22 @@ "makeerror": "1.0.12" } }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index a65a6ff7e..f036d48e8 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ }, "dependencies": { "@aws-sdk/client-ecr": "^3.817.0", - "@kubernetes/client-node": "^0.22.3", + "@kubernetes/client-node": "^1.0.0", "@snyk/dep-graph": "^2.9.0", "async": "^3.2.6", "bunyan": "^1.8.15", diff --git a/src/supervisor/agent.ts b/src/supervisor/agent.ts index 285e57859..81f40b4c2 100644 --- a/src/supervisor/agent.ts +++ b/src/supervisor/agent.ts @@ -21,10 +21,10 @@ async function getSnykMonitorDeploymentUid( ): Promise { try { const attemptedApiCall = await retryKubernetesApiRequestIndefinitely( - () => k8sApi.appsClient.readNamespacedDeployment(name, namespace), + () => k8sApi.appsClient.readNamespacedDeployment({ name, namespace }), config.MAX_RETRY_BACKOFF_DURATION_SECONDS, ); - return attemptedApiCall.body.metadata?.uid; + return attemptedApiCall.metadata?.uid; } catch (error) { logger.error( { error, namespace, deploymentName: name }, diff --git a/src/supervisor/watchers/handlers/argo-rollout.ts b/src/supervisor/watchers/handlers/argo-rollout.ts index 7337ec43a..596e242e6 100644 --- a/src/supervisor/watchers/handlers/argo-rollout.ts +++ b/src/supervisor/watchers/handlers/argo-rollout.ts @@ -1,4 +1,3 @@ -import { IncomingMessage } from 'http'; import { deleteWorkload } from './workload'; import { WorkloadKind } from '../../types'; import { @@ -20,10 +19,7 @@ import { trimWorkload } from '../../workload-sanitization'; export async function paginatedNamespacedArgoRolloutList( namespace: string, -): Promise<{ - response: IncomingMessage; - body: V1alpha1RolloutList; -}> { +): Promise { const rolloutList = new V1alpha1RolloutList(); rolloutList.apiVersion = 'argoproj.io/v1alpha1'; rolloutList.kind = 'RolloutList'; @@ -32,26 +28,26 @@ export async function paginatedNamespacedArgoRolloutList( return await paginatedNamespacedList( namespace, rolloutList, - async ( - namespace: string, - pretty?: string, - _allowWatchBookmarks?: boolean, - _continue?: string, - fieldSelector?: string, - labelSelector?: string, - limit?: number, - ) => - k8sApi.customObjectsClient.listNamespacedCustomObject( - 'argoproj.io', - 'v1alpha1', - namespace, - 'rollouts', - pretty, - false, - _continue, - fieldSelector, - labelSelector, - limit, + async (batchRequest: { + namespace: string; + pretty?: string; + _allowWatchBookmarks?: boolean; + _continue?: string; + fieldSelector?: string; + labelSelector?: string; + limit?: number; + }) => + k8sApi.customObjectsClient.listNamespacedCustomObject({ + group: 'argoproj.io', + version: 'v1alpha1', + namespace: namespace, + plural: 'rollouts', + pretty: batchRequest.pretty, + allowWatchBookmarks: false, + _continue: batchRequest._continue, + fieldSelector: batchRequest.fieldSelector, + labelSelector: batchRequest.labelSelector, + limit: batchRequest.limit, /** * The K8s client's listNamespacedCustomObject() doesn't allow to specify * the type of the response body and returns the generic "object" type, @@ -61,14 +57,11 @@ export async function paginatedNamespacedArgoRolloutList( * Type 'Promise<{ response: IncomingMessage; ***body: object;*** }>' is not assignable to type * 'Promise<{ response: IncomingMessage; ***body: KubernetesListObject<...>;*** }>' */ - ) as any, + }) as any, ); } -export async function paginatedClusterArgoRolloutList(): Promise<{ - response: IncomingMessage; - body: V1alpha1RolloutList; -}> { +export async function paginatedClusterArgoRolloutList(): Promise { const rolloutList = new V1alpha1RolloutList(); rolloutList.apiVersion = 'argoproj.io/v1'; rolloutList.kind = 'RolloutList'; @@ -76,25 +69,25 @@ export async function paginatedClusterArgoRolloutList(): Promise<{ return await paginatedClusterList( rolloutList, - async ( - _allowWatchBookmarks?: boolean, - _continue?: string, - fieldSelector?: string, - labelSelector?: string, - limit?: number, - pretty?: string, - ) => - k8sApi.customObjectsClient.listClusterCustomObject( - 'argoproj.io', - 'v1alpha1', - 'rollouts', - pretty, - false, - _continue, - fieldSelector, - labelSelector, - limit, - ) as any, + async (clusterRequest: { + _allowWatchBookmarks?: boolean; + _continue?: string; + fieldSelector?: string; + labelSelector?: string; + limit?: number; + pretty?: string; + }) => + k8sApi.customObjectsClient.listClusterCustomObject({ + group: 'argoproj.io', + version: 'v1alpha1', + plural: 'rollouts', + pretty: clusterRequest.pretty, + allowWatchBookmarks: false, + _continue: clusterRequest._continue, + fieldSelector: clusterRequest.fieldSelector, + labelSelector: clusterRequest.labelSelector, + limit: clusterRequest.limit, + }) as any, ); } @@ -109,23 +102,32 @@ export async function argoRolloutWatchHandler( // Perform lookup for known supported kinds: https://github.com/argoproj/argo-rollouts/blob/master/rollout/templateref.go#L40-L52 case 'Deployment': { const deployResult = await retryKubernetesApiRequest(() => - k8sApi.appsClient.readNamespacedDeployment(workloadName, namespace), + k8sApi.appsClient.readNamespacedDeployment({ + name: workloadName, + namespace, + }), ); - rollout.spec.template = deployResult.body.spec?.template; + rollout.spec.template = deployResult.spec?.template; break; } case 'ReplicaSet': { const replicaSetResult = await retryKubernetesApiRequest(() => - k8sApi.appsClient.readNamespacedReplicaSet(workloadName, namespace), + k8sApi.appsClient.readNamespacedReplicaSet({ + name: workloadName, + namespace, + }), ); - rollout.spec.template = replicaSetResult.body.spec?.template; + rollout.spec.template = replicaSetResult.spec?.template; break; } case 'PodTemplate': { const podTemplateResult = await retryKubernetesApiRequest(() => - k8sApi.coreClient.readNamespacedPodTemplate(workloadName, namespace), + k8sApi.coreClient.readNamespacedPodTemplate({ + name: workloadName, + namespace, + }), ); - rollout.spec.template = podTemplateResult.body.template; + rollout.spec.template = podTemplateResult.template; break; } default: @@ -186,21 +188,20 @@ export async function isNamespacedArgoRolloutSupported( const resourceVersion = undefined; // List anything in the cluster const timeoutSeconds = 10; // Don't block the snyk-monitor indefinitely const attemptedApiCall = await retryKubernetesApiRequest(() => - k8sApi.customObjectsClient.listNamespacedCustomObject( - 'argoproj.io', - 'v1alpha1', - namespace, - 'rollouts', - pretty, - false, - continueToken, - fieldSelector, - labelSelector, - limit, - resourceVersion, - undefined, - timeoutSeconds, - ), + k8sApi.customObjectsClient.listNamespacedCustomObject({ + group: 'argoproj.io', + version: 'v1alpha1', + namespace: namespace, + plural: 'rollouts', + pretty: pretty, + allowWatchBookmarks: false, + _continue: continueToken, + fieldSelector: fieldSelector, + labelSelector: labelSelector, + limit: limit, + resourceVersion: resourceVersion, + timeoutSeconds: timeoutSeconds, + }), ); return ( attemptedApiCall !== undefined && @@ -228,20 +229,19 @@ export async function isClusterArgoRolloutSupported(): Promise { const resourceVersion = undefined; // List anything in the cluster const timeoutSeconds = 10; // Don't block the snyk-monitor indefinitely const attemptedApiCall = await retryKubernetesApiRequest(() => - k8sApi.customObjectsClient.listClusterCustomObject( - 'argoproj.io', - 'v1alpha1', - 'rollouts', - pretty, - false, - continueToken, - fieldSelector, - labelSelector, - limit, - resourceVersion, - undefined, - timeoutSeconds, - ), + k8sApi.customObjectsClient.listClusterCustomObject({ + group: 'argoproj.io', + version: 'v1alpha1', + plural: 'rollouts', + pretty: pretty, + allowWatchBookmarks: false, + _continue: continueToken, + fieldSelector: fieldSelector, + labelSelector: labelSelector, + limit: limit, + resourceVersion: resourceVersion, + timeoutSeconds: timeoutSeconds, + }), ); return ( attemptedApiCall !== undefined && diff --git a/src/supervisor/watchers/handlers/cron-job.ts b/src/supervisor/watchers/handlers/cron-job.ts index c0e2210e1..4013a8662 100644 --- a/src/supervisor/watchers/handlers/cron-job.ts +++ b/src/supervisor/watchers/handlers/cron-job.ts @@ -2,7 +2,6 @@ import { V1CronJob, V1CronJobList } from '@kubernetes/client-node'; import { deleteWorkload } from './workload'; import { WorkloadKind } from '../../types'; import { FALSY_WORKLOAD_NAME_MARKER } from './types'; -import { IncomingMessage } from 'http'; import { k8sApi } from '../../cluster'; import { paginatedClusterList, paginatedNamespacedList } from './pagination'; import { @@ -15,10 +14,7 @@ import { deleteWorkloadFromScanQueue } from './queue'; export async function paginatedNamespacedCronJobList( namespace: string, -): Promise<{ - response: IncomingMessage; - body: V1CronJobList; -}> { +): Promise { const v1CronJobList = new V1CronJobList(); v1CronJobList.apiVersion = 'batch/v1'; v1CronJobList.kind = 'CronJobList'; @@ -31,10 +27,7 @@ export async function paginatedNamespacedCronJobList( ); } -export async function paginatedClusterCronJobList(): Promise<{ - response: IncomingMessage; - body: V1CronJobList; -}> { +export async function paginatedClusterCronJobList(): Promise { const v1CronJobList = new V1CronJobList(); v1CronJobList.apiVersion = 'batch/v1'; v1CronJobList.kind = 'CronJobList'; diff --git a/src/supervisor/watchers/handlers/daemon-set.ts b/src/supervisor/watchers/handlers/daemon-set.ts index 7823a0f50..b5e18cd2f 100644 --- a/src/supervisor/watchers/handlers/daemon-set.ts +++ b/src/supervisor/watchers/handlers/daemon-set.ts @@ -2,7 +2,6 @@ import { V1DaemonSet, V1DaemonSetList } from '@kubernetes/client-node'; import { deleteWorkload } from './workload'; import { WorkloadKind } from '../../types'; import { FALSY_WORKLOAD_NAME_MARKER } from './types'; -import { IncomingMessage } from 'http'; import { k8sApi } from '../../cluster'; import { paginatedClusterList, paginatedNamespacedList } from './pagination'; import { @@ -15,10 +14,7 @@ import { deleteWorkloadFromScanQueue } from './queue'; export async function paginatedNamespacedDaemonSetList( namespace: string, -): Promise<{ - response: IncomingMessage; - body: V1DaemonSetList; -}> { +): Promise { const v1DaemonSetList = new V1DaemonSetList(); v1DaemonSetList.apiVersion = 'apps/v1'; v1DaemonSetList.kind = 'DaemonSetList'; @@ -31,10 +27,7 @@ export async function paginatedNamespacedDaemonSetList( ); } -export async function paginatedClusterDaemonSetList(): Promise<{ - response: IncomingMessage; - body: V1DaemonSetList; -}> { +export async function paginatedClusterDaemonSetList(): Promise { const v1DaemonSetList = new V1DaemonSetList(); v1DaemonSetList.apiVersion = 'apps/v1'; v1DaemonSetList.kind = 'DaemonSetList'; diff --git a/src/supervisor/watchers/handlers/deployment-config.ts b/src/supervisor/watchers/handlers/deployment-config.ts index f81944c85..0a6f84b79 100644 --- a/src/supervisor/watchers/handlers/deployment-config.ts +++ b/src/supervisor/watchers/handlers/deployment-config.ts @@ -1,4 +1,3 @@ -import { IncomingMessage } from 'http'; import { deleteWorkload } from './workload'; import { WorkloadKind } from '../../types'; import { @@ -20,10 +19,7 @@ import { trimWorkload } from '../../workload-sanitization'; export async function paginatedNamespacedDeploymentConfigList( namespace: string, -): Promise<{ - response: IncomingMessage; - body: V1DeploymentConfigList; -}> { +): Promise { const v1DeploymentConfigList = new V1DeploymentConfigList(); v1DeploymentConfigList.apiVersion = 'apps.openshift.io/v1'; v1DeploymentConfigList.kind = 'DeploymentConfigList'; @@ -32,26 +28,28 @@ export async function paginatedNamespacedDeploymentConfigList( return await paginatedNamespacedList( namespace, v1DeploymentConfigList, - async ( - namespace: string, - pretty?: string, - _allowWatchBookmarks?: boolean, - _continue?: string, - fieldSelector?: string, - labelSelector?: string, - limit?: number, - ) => + async (batchRequest: { + namespace: string; + pretty?: string; + _allowWatchBookmarks?: boolean; + _continue?: string; + fieldSelector?: string; + labelSelector?: string; + limit?: number; + }) => k8sApi.customObjectsClient.listNamespacedCustomObject( - 'apps.openshift.io', - 'v1', - namespace, - 'deploymentconfigs', - pretty, - false, - _continue, - fieldSelector, - labelSelector, - limit, + { + group: 'apps.openshift.io', + version: 'v1', + namespace: namespace, + plural: 'deploymentconfigs', + pretty: batchRequest.pretty, + allowWatchBookmarks: false, + _continue: batchRequest._continue, + fieldSelector: batchRequest.fieldSelector, + labelSelector: batchRequest.labelSelector, + limit: batchRequest.limit, + }, /** * The K8s client's listNamespacedCustomObject() doesn't allow to specify * the type of the response body and returns the generic "object" type, @@ -65,10 +63,7 @@ export async function paginatedNamespacedDeploymentConfigList( ); } -export async function paginatedClusterDeploymentConfigList(): Promise<{ - response: IncomingMessage; - body: V1DeploymentConfigList; -}> { +export async function paginatedClusterDeploymentConfigList(): Promise { const v1DeploymentConfigList = new V1DeploymentConfigList(); v1DeploymentConfigList.apiVersion = 'apps.openshift.io/v1'; v1DeploymentConfigList.kind = 'DeploymentConfigList'; @@ -76,25 +71,25 @@ export async function paginatedClusterDeploymentConfigList(): Promise<{ return await paginatedClusterList( v1DeploymentConfigList, - async ( - _allowWatchBookmarks?: boolean, - _continue?: string, - fieldSelector?: string, - labelSelector?: string, - limit?: number, - pretty?: string, - ) => - k8sApi.customObjectsClient.listClusterCustomObject( - 'apps.openshift.io', - 'v1', - 'deploymentconfigs', - pretty, - false, - _continue, - fieldSelector, - labelSelector, - limit, - ) as any, + async (clusterRequest: { + _allowWatchBookmarks?: boolean; + _continue?: string; + fieldSelector?: string; + labelSelector?: string; + limit?: number; + pretty?: string; + }) => + k8sApi.customObjectsClient.listClusterCustomObject({ + group: 'apps.openshift.io', + version: 'v1', + plural: 'deploymentconfigs', + pretty: clusterRequest.pretty, + allowWatchBookmarks: false, + _continue: clusterRequest._continue, + fieldSelector: clusterRequest.fieldSelector, + labelSelector: clusterRequest.labelSelector, + limit: clusterRequest.limit, + }) as any, ); } @@ -154,21 +149,21 @@ export async function isNamespacedDeploymentConfigSupported( const resourceVersion = undefined; // List anything in the cluster const timeoutSeconds = 10; // Don't block the snyk-monitor indefinitely const attemptedApiCall = await retryKubernetesApiRequest(() => - k8sApi.customObjectsClient.listNamespacedCustomObject( - 'apps.openshift.io', - 'v1', - namespace, - 'deploymentconfigs', - pretty, - false, - continueToken, - fieldSelector, - labelSelector, - limit, - resourceVersion, - undefined, - timeoutSeconds, - ), + k8sApi.customObjectsClient.listNamespacedCustomObject({ + group: 'apps.openshift.io', + version: 'v1', + namespace: namespace, + plural: 'deploymentconfigs', + pretty: pretty, + allowWatchBookmarks: false, + _continue: continueToken, + fieldSelector: fieldSelector, + labelSelector: labelSelector, + limit: limit, + resourceVersion: resourceVersion, + resourceVersionMatch: undefined, + timeoutSeconds: timeoutSeconds, + }), ); return ( attemptedApiCall !== undefined && @@ -196,20 +191,20 @@ export async function isClusterDeploymentConfigSupported(): Promise { const resourceVersion = undefined; // List anything in the cluster const timeoutSeconds = 10; // Don't block the snyk-monitor indefinitely const attemptedApiCall = await retryKubernetesApiRequest(() => - k8sApi.customObjectsClient.listClusterCustomObject( - 'apps.openshift.io', - 'v1', - 'deploymentconfigs', - pretty, - false, - continueToken, - fieldSelector, - labelSelector, - limit, - resourceVersion, - undefined, - timeoutSeconds, - ), + k8sApi.customObjectsClient.listClusterCustomObject({ + group: 'apps.openshift.io', + version: 'v1', + plural: 'deploymentconfigs', + pretty: pretty, + allowWatchBookmarks: false, + _continue: continueToken, + fieldSelector: fieldSelector, + labelSelector: labelSelector, + limit: limit, + resourceVersion: resourceVersion, + resourceVersionMatch: undefined, + timeoutSeconds: timeoutSeconds, + }), ); return ( attemptedApiCall !== undefined && diff --git a/src/supervisor/watchers/handlers/deployment.ts b/src/supervisor/watchers/handlers/deployment.ts index 4fc72487d..75800c011 100644 --- a/src/supervisor/watchers/handlers/deployment.ts +++ b/src/supervisor/watchers/handlers/deployment.ts @@ -2,7 +2,6 @@ import { V1Deployment, V1DeploymentList } from '@kubernetes/client-node'; import { deleteWorkload } from './workload'; import { WorkloadKind } from '../../types'; import { FALSY_WORKLOAD_NAME_MARKER } from './types'; -import { IncomingMessage } from 'http'; import { k8sApi } from '../../cluster'; import { paginatedClusterList, paginatedNamespacedList } from './pagination'; import { @@ -15,10 +14,7 @@ import { deleteWorkloadFromScanQueue } from './queue'; export async function paginatedNamespacedDeploymentList( namespace: string, -): Promise<{ - response: IncomingMessage; - body: V1DeploymentList; -}> { +): Promise { const v1DeploymentList = new V1DeploymentList(); v1DeploymentList.apiVersion = 'apps/v1'; v1DeploymentList.kind = 'DeploymentList'; @@ -31,10 +27,7 @@ export async function paginatedNamespacedDeploymentList( ); } -export async function paginatedClusterDeploymentList(): Promise<{ - response: IncomingMessage; - body: V1DeploymentList; -}> { +export async function paginatedClusterDeploymentList(): Promise { const v1DeploymentList = new V1DeploymentList(); v1DeploymentList.apiVersion = 'apps/v1'; v1DeploymentList.kind = 'DeploymentList'; diff --git a/src/supervisor/watchers/handlers/error.ts b/src/supervisor/watchers/handlers/error.ts index 3d99a451a..5e43792a7 100644 --- a/src/supervisor/watchers/handlers/error.ts +++ b/src/supervisor/watchers/handlers/error.ts @@ -1,35 +1,15 @@ import type { Informer, KubernetesObject } from '@kubernetes/client-node'; import { logger } from '../../../common/logger'; -import { - RETRYABLE_NETWORK_ERROR_CODES, - RETRYABLE_NETWORK_ERROR_MESSAGES, -} from '../types'; - -type InformerError = Partial<{ code: string; message: string }>; export function restartableErrorHandler( informer: Informer, logContext: Record, ) { - return function handler(error: InformerError): void { - const code = error.code || ''; - const message = error.message || ''; - logContext.code = code; - if ( - RETRYABLE_NETWORK_ERROR_CODES.includes(code) || - RETRYABLE_NETWORK_ERROR_MESSAGES.includes(message) - ) { - logger.debug(logContext, 'informer error occurred, restarting informer'); - - // Restart informer after 1sec - setTimeout(async () => { - await informer.start(); - }, 1000); - } else { - logger.error( - { ...logContext, error }, - 'unexpected informer error event occurred', - ); - } + return function handler(err: KubernetesObject): void { + logger.error(err); + // Restart informer after 1sec + setTimeout(async () => { + await informer.start(); + }, 1000); }; } diff --git a/src/supervisor/watchers/handlers/index.ts b/src/supervisor/watchers/handlers/index.ts index 822707d60..1232fe0ec 100644 --- a/src/supervisor/watchers/handlers/index.ts +++ b/src/supervisor/watchers/handlers/index.ts @@ -6,7 +6,7 @@ import * as deploymentConfig from './deployment-config'; import * as rollout from './argo-rollout'; import { kubeConfig } from '../../cluster'; import * as kubernetesApiWrappers from '../../kuberenetes-api-wrappers'; -import { FALSY_WORKLOAD_NAME_MARKER, KubernetesInformerVerb } from './types'; +import { FALSY_WORKLOAD_NAME_MARKER } from './types'; import { workloadWatchMetadata } from './informer-config'; import { restartableErrorHandler } from './error'; import { isExcludedNamespace } from '../internal-namespaces'; @@ -87,22 +87,24 @@ export async function setupNamespacedInformer( informer.on(ERROR, restartableErrorHandler(informer, logContext)); for (const informerVerb of Object.keys(workloadMetadata.handlers)) { - informer.on( - informerVerb as KubernetesInformerVerb, - async (watchedWorkload) => { - try { - await workloadMetadata.handlers[informerVerb](watchedWorkload); - } catch (error) { - const name = - (watchedWorkload.metadata && watchedWorkload.metadata.name) || - FALSY_WORKLOAD_NAME_MARKER; - logger.warn( - { ...logContext, error, workloadName: name }, - 'could not execute the namespaced informer handler for a workload', - ); + informer.on(informerVerb, async (watchedWorkload) => { + try { + const handler = workloadMetadata.handlers[informerVerb]; + if (handler === undefined) { + throw new Error(`Undefined handler for "${informerVerb}"`); } - }, - ); + + await handler(watchedWorkload); + } catch (error) { + const name = + (watchedWorkload.metadata && watchedWorkload.metadata.name) || + FALSY_WORKLOAD_NAME_MARKER; + logger.warn( + { ...logContext, error, workloadName: name }, + 'could not execute the namespaced informer handler for a workload', + ); + } + }); } await informer.start(); @@ -145,29 +147,31 @@ export async function setupClusterInformer( loggedListMethod, ); - informer.on(ERROR, restartableErrorHandler(informer, logContext)); + //informer.on(ERROR, restartableErrorHandler(informer, logContext)); for (const informerVerb of Object.keys(workloadMetadata.handlers)) { - informer.on( - informerVerb as KubernetesInformerVerb, - async (watchedWorkload) => { - try { - if (isExcludedNamespace(watchedWorkload.metadata?.namespace || '')) { - return; - } - - await workloadMetadata.handlers[informerVerb](watchedWorkload); - } catch (error) { - const name = - (watchedWorkload.metadata && watchedWorkload.metadata.name) || - FALSY_WORKLOAD_NAME_MARKER; - logger.warn( - { ...logContext, error, workloadName: name }, - 'could not execute the cluster informer handler for a workload', - ); + informer.on(informerVerb, async (watchedWorkload) => { + try { + if (isExcludedNamespace(watchedWorkload.metadata?.namespace || '')) { + return; } - }, - ); + + const handler = workloadMetadata.handlers[informerVerb]; + if (handler == undefined) { + throw new Error('Unefined handler for ' + informerVerb); + } + + await handler(watchedWorkload); + } catch (error) { + const name = + (watchedWorkload.metadata && watchedWorkload.metadata.name) || + FALSY_WORKLOAD_NAME_MARKER; + logger.warn( + { ...logContext, error, workloadName: name }, + 'could not execute the cluster informer handler for a workload', + ); + } + }); } await informer.start(); diff --git a/src/supervisor/watchers/handlers/job.ts b/src/supervisor/watchers/handlers/job.ts index d4ecae041..8a519c19d 100644 --- a/src/supervisor/watchers/handlers/job.ts +++ b/src/supervisor/watchers/handlers/job.ts @@ -2,7 +2,6 @@ import { V1Job, V1JobList } from '@kubernetes/client-node'; import { deleteWorkload } from './workload'; import { WorkloadKind } from '../../types'; import { FALSY_WORKLOAD_NAME_MARKER } from './types'; -import { IncomingMessage } from 'http'; import { k8sApi } from '../../cluster'; import { paginatedClusterList, paginatedNamespacedList } from './pagination'; import { @@ -13,10 +12,9 @@ import { import { trimWorkload } from '../../workload-sanitization'; import { deleteWorkloadFromScanQueue } from './queue'; -export async function paginatedNamespacedJobList(namespace: string): Promise<{ - response: IncomingMessage; - body: V1JobList; -}> { +export async function paginatedNamespacedJobList( + namespace: string, +): Promise { const v1JobList = new V1JobList(); v1JobList.apiVersion = 'batch/v1'; v1JobList.kind = 'JobList'; @@ -29,10 +27,7 @@ export async function paginatedNamespacedJobList(namespace: string): Promise<{ ); } -export async function paginatedClusterJobList(): Promise<{ - response: IncomingMessage; - body: V1JobList; -}> { +export async function paginatedClusterJobList(): Promise { const v1JobList = new V1JobList(); v1JobList.apiVersion = 'batch/v1'; v1JobList.kind = 'JobList'; diff --git a/src/supervisor/watchers/handlers/namespace.ts b/src/supervisor/watchers/handlers/namespace.ts index c33992f6d..34f118a24 100644 --- a/src/supervisor/watchers/handlers/namespace.ts +++ b/src/supervisor/watchers/handlers/namespace.ts @@ -9,7 +9,6 @@ import { V1NamespaceList, V1ListMeta, } from '@kubernetes/client-node'; -import { IncomingMessage } from 'http'; import sleep from 'sleep-promise'; import { logger } from '../../../common/logger'; import { storeNamespace, deleteNamespace } from '../../../state'; @@ -86,16 +85,15 @@ export async function trackNamespace(namespace: string): Promise { try { return await retryKubernetesApiRequest(async () => { logger.info({}, 'retrying k8s api request'); - const reply = await k8sApi.coreClient.readNamespace(namespace); + const reply = await k8sApi.coreClient.readNamespace({ + name: namespace, + }); const list = new V1NamespaceList(); list.apiVersion = 'v1'; list.kind = 'NamespaceList'; - list.items = new Array(reply.body); + list.items = new Array(reply); list.metadata = new V1ListMeta(); - return { - response: reply.response, - body: list, - }; + return list; }); } catch (error) { logger.error({ ...logContext, error }, 'error while listing namespace'); @@ -117,10 +115,7 @@ export async function trackNamespace(namespace: string): Promise { await informer.start(); } -async function paginatedNamespaceList(): Promise<{ - response: IncomingMessage; - body: V1NamespaceList; -}> { +async function paginatedNamespaceList(): Promise { const v1NamespaceList = new V1NamespaceList(); v1NamespaceList.apiVersion = 'v1'; v1NamespaceList.kind = 'NamespaceList'; @@ -134,10 +129,9 @@ async function paginatedNamespaceList(): Promise<{ * The workloads collected are additionally trimmed to contain only the relevant data for vulnerability analysis. * The combination of both listing and trimming ensures we reduce our memory footprint and prevent overloading the API server. */ -async function listPaginatedNamespaces(list: V1NamespaceList): Promise<{ - response: IncomingMessage; - body: V1NamespaceList; -}> { +async function listPaginatedNamespaces( + list: V1NamespaceList, +): Promise { let continueToken: string | undefined = undefined; const pretty = undefined; @@ -145,27 +139,24 @@ async function listPaginatedNamespaces(list: V1NamespaceList): Promise<{ const fieldSelector = undefined; const labelSelector = undefined; - let incomingMessage: IncomingMessage | undefined = undefined; - loop: while (true) { try { - const listCall = await k8sApi.coreClient.listNamespace( - pretty, - allowWatchBookmarks, - continueToken, - fieldSelector, - labelSelector, - PAGE_SIZE, - ); - incomingMessage = listCall.response; - list.metadata = listCall.body.metadata; + const listCall = await k8sApi.coreClient.listNamespace({ + pretty: pretty, + allowWatchBookmarks: allowWatchBookmarks, + _continue: continueToken, + fieldSelector: fieldSelector, + labelSelector: labelSelector, + limit: PAGE_SIZE, + }); + list.metadata = listCall.metadata; - if (Array.isArray(listCall.body.items)) { - const trimmedItems = trimWorkloads(listCall.body.items); + if (Array.isArray(listCall.items)) { + const trimmedItems = trimWorkloads(listCall.items); list.items.push(...trimmedItems); } - continueToken = listCall.body.metadata?._continue; + continueToken = listCall.metadata?._continue; if (!continueToken) { break; } @@ -197,12 +188,5 @@ async function listPaginatedNamespaces(list: V1NamespaceList): Promise<{ } } - if (!incomingMessage) { - throw new Error('could not list workload'); - } - - return { - response: incomingMessage, - body: list, - }; + return list; } diff --git a/src/supervisor/watchers/handlers/pagination.ts b/src/supervisor/watchers/handlers/pagination.ts index 9dddd3b59..1db8d8e2a 100644 --- a/src/supervisor/watchers/handlers/pagination.ts +++ b/src/supervisor/watchers/handlers/pagination.ts @@ -1,4 +1,3 @@ -import { IncomingMessage } from 'http'; import sleep from 'sleep-promise'; import type { KubernetesListObject, @@ -27,10 +26,7 @@ export async function paginatedNamespacedList< namespace: string, list: KubernetesListObject, listPromise: V1NamespacedList>, -): Promise<{ - response: IncomingMessage; - body: KubernetesListObject; -}> { +): Promise> { let continueToken: string | undefined = undefined; const pretty = undefined; @@ -38,31 +34,26 @@ export async function paginatedNamespacedList< const fieldSelector = undefined; const labelSelector = undefined; - let incomingMessage: IncomingMessage | undefined = undefined; - loop: while (true) { try { - const listCall: { - response: IncomingMessage; - body: KubernetesListObject; - } = await listPromise( + const listCall: KubernetesListObject = await listPromise({ namespace, pretty, allowWatchBookmarks, - continueToken, + _continue: continueToken, fieldSelector, labelSelector, - PAGE_SIZE, - ); - incomingMessage = listCall.response; - list.metadata = listCall.body.metadata; + limit: PAGE_SIZE, + }); + // incomingMessage = listCall.response; + list.metadata = listCall.metadata; - if (Array.isArray(listCall.body.items)) { - const trimmedItems = trimWorkloads(listCall.body.items); + if (Array.isArray(listCall.items)) { + const trimmedItems = trimWorkloads(listCall.items); list.items.push(...trimmedItems); } - continueToken = listCall.body.metadata?._continue; + continueToken = listCall.metadata?._continue; if (!continueToken) { break; } @@ -94,14 +85,11 @@ export async function paginatedNamespacedList< } } - if (!incomingMessage) { - throw new Error('could not list workload'); - } + // if (!incomingMessage) { + // throw new Error('could not list workload'); + // } - return { - response: incomingMessage, - body: list, - }; + return list; } /** @@ -114,39 +102,30 @@ export async function paginatedClusterList< >( list: KubernetesListObject, listPromise: V1ClusterList>, -): Promise<{ - response: IncomingMessage; - body: KubernetesListObject; -}> { +): Promise> { let continueToken: string | undefined = undefined; const allowWatchBookmarks = undefined; const fieldSelector = undefined; const labelSelector = undefined; - let incomingMessage: IncomingMessage | undefined = undefined; - loop: while (true) { try { - const listCall: { - response: IncomingMessage; - body: KubernetesListObject; - } = await listPromise( + const listCall: KubernetesListObject = await listPromise({ allowWatchBookmarks, - continueToken, + _continue: continueToken, fieldSelector, labelSelector, - PAGE_SIZE, - ); - incomingMessage = listCall.response; - list.metadata = listCall.body.metadata; + limit: PAGE_SIZE, + }); + list.metadata = listCall.metadata; - if (Array.isArray(listCall.body.items)) { - const trimmedItems = trimWorkloads(listCall.body.items); + if (Array.isArray(listCall.items)) { + const trimmedItems = trimWorkloads(listCall.items); list.items.push(...trimmedItems); } - continueToken = listCall.body.metadata?._continue; + continueToken = listCall.metadata?._continue; if (!continueToken) { break; } @@ -178,12 +157,5 @@ export async function paginatedClusterList< } } - if (!incomingMessage) { - throw new Error('could not list workload'); - } - - return { - response: incomingMessage, - body: list, - }; + return list; } diff --git a/src/supervisor/watchers/handlers/pod.ts b/src/supervisor/watchers/handlers/pod.ts index 95667541a..4d688bb8c 100644 --- a/src/supervisor/watchers/handlers/pod.ts +++ b/src/supervisor/watchers/handlers/pod.ts @@ -1,5 +1,4 @@ import { V1Pod, V1PodList } from '@kubernetes/client-node'; -import { IncomingMessage } from 'http'; import { logger } from '../../../common/logger'; import { sendWorkloadMetadata } from '../../../transmitter'; @@ -85,10 +84,9 @@ export function isPodReady(pod: V1Pod): boolean { return !isTerminating && podStatusPhase && containerReadyStatuses; } -export async function paginatedNamespacedPodList(namespace: string): Promise<{ - response: IncomingMessage; - body: V1PodList; -}> { +export async function paginatedNamespacedPodList( + namespace: string, +): Promise { const v1PodList = new V1PodList(); v1PodList.apiVersion = 'v1'; v1PodList.kind = 'PodList'; @@ -101,10 +99,7 @@ export async function paginatedNamespacedPodList(namespace: string): Promise<{ ); } -export async function paginatedClusterPodList(): Promise<{ - response: IncomingMessage; - body: V1PodList; -}> { +export async function paginatedClusterPodList(): Promise { const v1PodList = new V1PodList(); v1PodList.apiVersion = 'v1'; v1PodList.kind = 'PodList'; diff --git a/src/supervisor/watchers/handlers/replica-set.ts b/src/supervisor/watchers/handlers/replica-set.ts index 9ebb91815..56ae5c7d0 100644 --- a/src/supervisor/watchers/handlers/replica-set.ts +++ b/src/supervisor/watchers/handlers/replica-set.ts @@ -2,7 +2,6 @@ import { V1ReplicaSet, V1ReplicaSetList } from '@kubernetes/client-node'; import { deleteWorkload } from './workload'; import { WorkloadKind } from '../../types'; import { FALSY_WORKLOAD_NAME_MARKER } from './types'; -import { IncomingMessage } from 'http'; import { k8sApi } from '../../cluster'; import { paginatedClusterList, paginatedNamespacedList } from './pagination'; import { @@ -15,10 +14,7 @@ import { deleteWorkloadFromScanQueue } from './queue'; export async function paginatedNamespacedReplicaSetList( namespace: string, -): Promise<{ - response: IncomingMessage; - body: V1ReplicaSetList; -}> { +): Promise { const v1ReplicaSetList = new V1ReplicaSetList(); v1ReplicaSetList.apiVersion = 'apps/v1'; v1ReplicaSetList.kind = 'ReplicaSetList'; @@ -31,10 +27,7 @@ export async function paginatedNamespacedReplicaSetList( ); } -export async function paginatedClusterReplicaSetList(): Promise<{ - response: IncomingMessage; - body: V1ReplicaSetList; -}> { +export async function paginatedClusterReplicaSetList(): Promise { const v1ReplicaSetList = new V1ReplicaSetList(); v1ReplicaSetList.apiVersion = 'apps/v1'; v1ReplicaSetList.kind = 'ReplicaSetList'; diff --git a/src/supervisor/watchers/handlers/replication-controller.ts b/src/supervisor/watchers/handlers/replication-controller.ts index 9152860b5..1369874ec 100644 --- a/src/supervisor/watchers/handlers/replication-controller.ts +++ b/src/supervisor/watchers/handlers/replication-controller.ts @@ -5,7 +5,6 @@ import { import { deleteWorkload } from './workload'; import { WorkloadKind } from '../../types'; import { FALSY_WORKLOAD_NAME_MARKER } from './types'; -import { IncomingMessage } from 'http'; import { k8sApi } from '../../cluster'; import { paginatedClusterList, paginatedNamespacedList } from './pagination'; import { @@ -18,10 +17,7 @@ import { deleteWorkloadFromScanQueue } from './queue'; export async function paginatedNamespacedReplicationControllerList( namespace: string, -): Promise<{ - response: IncomingMessage; - body: V1ReplicationControllerList; -}> { +): Promise { const v1ReplicationControllerList = new V1ReplicationControllerList(); v1ReplicationControllerList.apiVersion = 'v1'; v1ReplicationControllerList.kind = 'ReplicationControllerList'; @@ -36,10 +32,7 @@ export async function paginatedNamespacedReplicationControllerList( ); } -export async function paginatedClusterReplicationControllerList(): Promise<{ - response: IncomingMessage; - body: V1ReplicationControllerList; -}> { +export async function paginatedClusterReplicationControllerList(): Promise { const v1ReplicationControllerList = new V1ReplicationControllerList(); v1ReplicationControllerList.apiVersion = 'v1'; v1ReplicationControllerList.kind = 'ReplicationControllerList'; diff --git a/src/supervisor/watchers/handlers/stateful-set.ts b/src/supervisor/watchers/handlers/stateful-set.ts index 9034f620e..6b759a850 100644 --- a/src/supervisor/watchers/handlers/stateful-set.ts +++ b/src/supervisor/watchers/handlers/stateful-set.ts @@ -2,7 +2,6 @@ import { V1StatefulSet, V1StatefulSetList } from '@kubernetes/client-node'; import { deleteWorkload } from './workload'; import { WorkloadKind } from '../../types'; import { FALSY_WORKLOAD_NAME_MARKER } from './types'; -import { IncomingMessage } from 'http'; import { k8sApi } from '../../cluster'; import { paginatedClusterList, paginatedNamespacedList } from './pagination'; import { @@ -15,10 +14,7 @@ import { deleteWorkloadFromScanQueue } from './queue'; export async function paginatedNamespacedStatefulSetList( namespace: string, -): Promise<{ - response: IncomingMessage; - body: V1StatefulSetList; -}> { +): Promise { const v1StatefulSetList = new V1StatefulSetList(); v1StatefulSetList.apiVersion = 'apps/v1'; v1StatefulSetList.kind = 'StatefulSetList'; @@ -31,10 +27,7 @@ export async function paginatedNamespacedStatefulSetList( ); } -export async function paginatedClusterStatefulSetList(): Promise<{ - response: IncomingMessage; - body: V1StatefulSetList; -}> { +export async function paginatedClusterStatefulSetList(): Promise { const v1StatefulSetList = new V1StatefulSetList(); v1StatefulSetList.apiVersion = 'apps/v1'; v1StatefulSetList.kind = 'StatefulSetList'; diff --git a/src/supervisor/watchers/handlers/types.ts b/src/supervisor/watchers/handlers/types.ts index 5ab0cb5b7..272969f82 100644 --- a/src/supervisor/watchers/handlers/types.ts +++ b/src/supervisor/watchers/handlers/types.ts @@ -4,16 +4,11 @@ import { V1ListMeta, V1ObjectMeta, V1PodTemplateSpec, - ADD, - DELETE, - UPDATE, } from '@kubernetes/client-node'; -import { IncomingMessage } from 'http'; export const FALSY_WORKLOAD_NAME_MARKER = 'falsy workload name'; -export type KubernetesInformerVerb = ADD | DELETE | UPDATE; - +export type KubernetesInformerVerb = string; type WorkloadHandlers = Partial< Record >; @@ -22,15 +17,9 @@ type WorkloadHandlerFunc = (workload: any) => Promise; type ListNamespacedWorkloadFunctionFactory = ( namespace: string, -) => () => Promise<{ - response: any; - body: any; -}>; +) => () => Promise; -type ListClusterWorkloadFunctionFactory = () => () => Promise<{ - response: any; - body: any; -}>; +type ListClusterWorkloadFunctionFactory = () => () => Promise; export interface IWorkloadWatchMetadata { [workloadKind: string]: { @@ -99,47 +88,41 @@ export interface V1alpha1RolloutWorkloadRef { name: string; } -export type V1ClusterList = ( - allowWatchBookmarks?: boolean, - _continue?: string, - fieldSelector?: string, - labelSelector?: string, - limit?: number, - pretty?: string, - resourceVersion?: string, - resourceVersionMatch?: string, - sendInitialEvents?: boolean, - timeoutSeconds?: number, - watch?: boolean, +export type V1ClusterList = (clusterRequest: { + allowWatchBookmarks?: boolean; + _continue?: string; + fieldSelector?: string; + labelSelector?: string; + limit?: number; + pretty?: string; + resourceVersion?: string; + resourceVersionMatch?: string; + sendInitialEvents?: boolean; + timeoutSeconds?: number; + watch?: boolean; options?: { headers: { [name: string]: string; }; - }, -) => Promise<{ - response: IncomingMessage; - body: T; -}>; - -export type V1NamespacedList = ( - namespace: string, - pretty?: string, - allowWatchBookmarks?: boolean, - _continue?: string, - fieldSelector?: string, - labelSelector?: string, - limit?: number, - resourceVersion?: string, - resourceVersionMatch?: string, - sendInitialEvents?: boolean, - timeoutSeconds?: number, - watch?: boolean, + }; +}) => Promise; + +export type V1NamespacedList = (batchRequst: { + namespace: string; + pretty?: string; + allowWatchBookmarks?: boolean; + _continue?: string; + fieldSelector?: string; + labelSelector?: string; + limit?: number; + resourceVersion?: string; + resourceVersionMatch?: string; + sendInitialEvents?: boolean; + timeoutSeconds?: number; + watch?: boolean; options?: { headers: { [name: string]: string; }; - }, -) => Promise<{ - response: IncomingMessage; - body: T; -}>; + }; +}) => Promise; diff --git a/src/supervisor/watchers/index.ts b/src/supervisor/watchers/index.ts index 4ae5028e5..cad93bf0c 100644 --- a/src/supervisor/watchers/index.ts +++ b/src/supervisor/watchers/index.ts @@ -2,7 +2,7 @@ import { V1Namespace } from '@kubernetes/client-node'; import { logger } from '../../common/logger'; import { config } from '../../common/config'; -import { NamespaceResponse, WorkloadKind } from '../types'; +import { WorkloadKind } from '../types'; import { setupNamespacedInformer, setupClusterInformer } from './handlers'; import { k8sApi } from '../cluster'; import { extractNamespaceName } from './internal-namespaces'; @@ -60,11 +60,11 @@ export async function beginWatchingWorkloads(): Promise { { namespace: config.WATCH_NAMESPACE }, 'kubernetes-monitor restricted to specific namespace', ); - let namespaceResponse: NamespaceResponse | undefined; + let namespaceResponse: V1Namespace | undefined; try { - namespaceResponse = await k8sApi.coreClient.readNamespace( - config.WATCH_NAMESPACE, - ); + namespaceResponse = await k8sApi.coreClient.readNamespace({ + name: config.WATCH_NAMESPACE, + }); } catch (err) { logger.error( { watchedNamespace: config.WATCH_NAMESPACE, err }, @@ -72,8 +72,7 @@ export async function beginWatchingWorkloads(): Promise { ); return; } - const namespace = namespaceResponse.body; - await setupWatchesForNamespace(namespace); + await setupWatchesForNamespace(namespaceResponse); return; } diff --git a/src/supervisor/workload-reader.ts b/src/supervisor/workload-reader.ts index a4b2d41cc..ffe32a226 100644 --- a/src/supervisor/workload-reader.ts +++ b/src/supervisor/workload-reader.ts @@ -24,9 +24,12 @@ const deploymentReader: IWorkloadReaderFunc = async ( const deploymentResult = await kubernetesApiWrappers.retryKubernetesApiRequest(() => - k8sApi.appsClient.readNamespacedDeployment(workloadName, namespace), + k8sApi.appsClient.readNamespacedDeployment({ + name: workloadName, + namespace: namespace, + }), ); - const deployment = trimWorkload(deploymentResult.body); + const deployment = trimWorkload(deploymentResult); if ( !deployment.metadata || @@ -63,13 +66,13 @@ const deploymentConfigReader: IWorkloadReaderFunc = async ( const deploymentResult = await kubernetesApiWrappers.retryKubernetesApiRequest(() => - k8sApi.customObjectsClient.getNamespacedCustomObject( - 'apps.openshift.io', - 'v1', - namespace, - 'deploymentconfigs', - workloadName, - ), + k8sApi.customObjectsClient.getNamespacedCustomObject({ + group: 'apps.openshift.io', + version: 'v1', + namespace: namespace, + plural: 'deploymentconfigs', + name: workloadName, + }), ); const deployment: V1DeploymentConfig = trimWorkload(deploymentResult.body); @@ -107,9 +110,12 @@ const replicaSetReader: IWorkloadReaderFunc = async ( const replicaSetResult = await kubernetesApiWrappers.retryKubernetesApiRequest(() => - k8sApi.appsClient.readNamespacedReplicaSet(workloadName, namespace), + k8sApi.appsClient.readNamespacedReplicaSet({ + name: workloadName, + namespace: namespace, + }), ); - const replicaSet = trimWorkload(replicaSetResult.body); + const replicaSet = trimWorkload(replicaSetResult); if ( !replicaSet.metadata || @@ -146,9 +152,12 @@ const statefulSetReader: IWorkloadReaderFunc = async ( const statefulSetResult = await kubernetesApiWrappers.retryKubernetesApiRequest(() => - k8sApi.appsClient.readNamespacedStatefulSet(workloadName, namespace), + k8sApi.appsClient.readNamespacedStatefulSet({ + name: workloadName, + namespace: namespace, + }), ); - const statefulSet = trimWorkload(statefulSetResult.body); + const statefulSet = trimWorkload(statefulSetResult); if ( !statefulSet.metadata || @@ -183,9 +192,13 @@ const daemonSetReader: IWorkloadReaderFunc = async ( } const daemonSetResult = await kubernetesApiWrappers.retryKubernetesApiRequest( - () => k8sApi.appsClient.readNamespacedDaemonSet(workloadName, namespace), + () => + k8sApi.appsClient.readNamespacedDaemonSet({ + name: workloadName, + namespace: namespace, + }), ); - const daemonSet = trimWorkload(daemonSetResult.body); + const daemonSet = trimWorkload(daemonSetResult); if ( !daemonSet.metadata || @@ -217,9 +230,12 @@ const jobReader: IWorkloadReaderFunc = async (workloadName, namespace) => { } const jobResult = await kubernetesApiWrappers.retryKubernetesApiRequest(() => - k8sApi.batchClient.readNamespacedJob(workloadName, namespace), + k8sApi.batchClient.readNamespacedJob({ + name: workloadName, + namespace: namespace, + }), ); - const job = trimWorkload(jobResult.body); + const job = trimWorkload(jobResult); if ( !job.metadata || @@ -249,9 +265,13 @@ const cronJobReader: IWorkloadReaderFunc = async (workloadName, namespace) => { } const cronJobResult = await kubernetesApiWrappers.retryKubernetesApiRequest( - () => k8sApi.batchClient.readNamespacedCronJob(workloadName, namespace), + () => + k8sApi.batchClient.readNamespacedCronJob({ + name: workloadName, + namespace: namespace, + }), ); - const cronJob = trimWorkload(cronJobResult.body); + const cronJob = trimWorkload(cronJobResult); if ( !cronJob.metadata || @@ -286,12 +306,12 @@ const replicationControllerReader: IWorkloadReaderFunc = async ( const replicationControllerResult = await kubernetesApiWrappers.retryKubernetesApiRequest(() => - k8sApi.coreClient.readNamespacedReplicationController( - workloadName, - namespace, - ), + k8sApi.coreClient.readNamespacedReplicationController({ + name: workloadName, + namespace: namespace, + }), ); - const replicationController = trimWorkload(replicationControllerResult.body); + const replicationController = trimWorkload(replicationControllerResult); if ( !replicationController.metadata || @@ -328,13 +348,13 @@ const argoRolloutReader: IWorkloadReaderFunc = async ( const rolloutResult = await kubernetesApiWrappers.retryKubernetesApiRequest( () => - k8sApi.customObjectsClient.getNamespacedCustomObject( - 'argoproj.io', - 'v1alpha1', - namespace, - 'rollouts', - workloadName, - ), + k8sApi.customObjectsClient.getNamespacedCustomObject({ + group: 'argoproj.io', + version: 'v1alpha1', + namespace: namespace, + plural: 'rollouts', + name: workloadName, + }), ); const rollout: V1alpha1Rollout = trimWorkload(rolloutResult.body);