Add guards to prevent activation errors slipping through (#5845)

* Add guards to prevent activation errors slipping through

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Make sure all logging has a message, output less errors when prometheus fails

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Improve logging from getPortFromStream

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-07-19 09:05:41 +03:00
1 parent 0d2aea0101
commit 81c18a6cad
8 files changed
+43 -17

No files matched your search

@@ -31,11 +31,11 @@ const loadMetricsFor = (getMetrics: GetMetrics) => async (promQueries: string[],
} catch (error) {
if (isRequestError(error)) {
if (lastAttempt || (error.statusCode && error.statusCode >= 400 && error.statusCode < 500)) {
logger.error("[Metrics]: metrics not available", error?.response ? error.response?.body : error);
throw new Error("Metrics not available");
throw new Error("Metrics not available", { cause: error });
}
} else if (error instanceof Error) {
throw new Error("Metrics not available", { cause: error });
} else {
logger.error("[Metrics]: metrics not available", error);
throw new Error("Metrics not available");
}
@@ -9,7 +9,10 @@ import { spawn } from "child_process";
import * as tcpPortUsed from "tcp-port-used";
import { TypedRegEx } from "typed-regex";
const internalPortRegex = TypedRegEx("^forwarding from (?<address>.+) ->", "i");
const internalPortMatcher = "^forwarding from (?<address>.+) ->";
const internalPortRegex = Object.assign(TypedRegEx(internalPortMatcher, "i"), {
rawMatcher: internalPortMatcher,
});
export interface PortForwardArgs {
clusterId: string;