chore: Add undici package and update health check service to utilize undici's Agent for improved HTTP probing
Build, Test, and Push CFDM Docker Image / test (push) Successful in 4m9s
Build, Test, and Push CFDM Docker Image / build-and-push (push) Successful in 2m58s
Build, Test, and Push CFDM Docker Image / update-wiki (push) Successful in 9s
Build, Test, and Push CFDM Docker Image / create-release (push) Has been skipped
Build, Test, and Push CFDM Docker Image / test (push) Successful in 4m9s
Build, Test, and Push CFDM Docker Image / build-and-push (push) Successful in 2m58s
Build, Test, and Push CFDM Docker Image / update-wiki (push) Successful in 9s
Build, Test, and Push CFDM Docker Image / create-release (push) Has been skipped
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
"p-limit": "^6.2.0",
|
"p-limit": "^6.2.0",
|
||||||
"p-queue": "^8.1.0",
|
"p-queue": "^8.1.0",
|
||||||
"toad-scheduler": "^4.0.1",
|
"toad-scheduler": "^4.0.1",
|
||||||
|
"undici": "^8.5.0",
|
||||||
"zod": "^4.2.0"
|
"zod": "^4.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { connect } from "node:net";
|
import { connect } from "node:net";
|
||||||
|
import { Agent } from "undici";
|
||||||
import type { Db } from "@cfdm/db";
|
import type { Db } from "@cfdm/db";
|
||||||
import { repos } from "@cfdm/db";
|
import { repos } from "@cfdm/db";
|
||||||
import type { HealthCheckTarget, IpHealthState } from "@cfdm/shared";
|
import type { HealthCheckTarget, IpHealthState } from "@cfdm/shared";
|
||||||
@@ -64,14 +65,33 @@ async function httpProbe(
|
|||||||
): Promise<ProbeResult> {
|
): Promise<ProbeResult> {
|
||||||
const started = Date.now();
|
const started = Date.now();
|
||||||
const path = target.path?.trim() || "/";
|
const path = target.path?.trim() || "/";
|
||||||
const url = `http://${ip}${path.startsWith("/") ? path : `/${path}`}`;
|
const pathWithSlash = path.startsWith("/") ? path : `/${path}`;
|
||||||
|
const port = target.port ?? 80;
|
||||||
const hostHeader = target.hostname || ip;
|
const hostHeader = target.hostname || ip;
|
||||||
|
const useTls = port === 443;
|
||||||
|
// For HTTPS probing against a raw IP, set SNI/Host so TLS handshake and vhost routing work.
|
||||||
|
const authorityHost = target.hostname || ip;
|
||||||
|
const url = useTls
|
||||||
|
? `https://${authorityHost}${pathWithSlash}`
|
||||||
|
: `http://${ip}${pathWithSlash}`;
|
||||||
|
// Custom dispatcher for HTTPS-to-IP: connect to the literal IP, but present hostname via SNI.
|
||||||
|
const dispatcher =
|
||||||
|
useTls && target.hostname
|
||||||
|
? new Agent({
|
||||||
|
connect: {
|
||||||
|
servername: target.hostname,
|
||||||
|
rejectUnauthorized: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
: undefined;
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: { Host: hostHeader },
|
headers: { Host: hostHeader },
|
||||||
signal: AbortSignal.timeout(timeoutMs),
|
signal: AbortSignal.timeout(timeoutMs),
|
||||||
redirect: "manual",
|
redirect: "manual",
|
||||||
|
// @ts-expect-error undici dispatcher option is not in fetch types
|
||||||
|
dispatcher,
|
||||||
});
|
});
|
||||||
const latency = Date.now() - started;
|
const latency = Date.now() - started;
|
||||||
if (target.expected_status != null) {
|
if (target.expected_status != null) {
|
||||||
|
|||||||
Generated
+9
@@ -66,6 +66,9 @@ importers:
|
|||||||
toad-scheduler:
|
toad-scheduler:
|
||||||
specifier: ^4.0.1
|
specifier: ^4.0.1
|
||||||
version: 4.0.1
|
version: 4.0.1
|
||||||
|
undici:
|
||||||
|
specifier: ^8.5.0
|
||||||
|
version: 8.5.0
|
||||||
zod:
|
zod:
|
||||||
specifier: ^4.2.0
|
specifier: ^4.2.0
|
||||||
version: 4.4.3
|
version: 4.4.3
|
||||||
@@ -3763,6 +3766,10 @@ packages:
|
|||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==}
|
resolution: {integrity: sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==}
|
||||||
|
|
||||||
|
[email protected]:
|
||||||
|
resolution: {integrity: sha512-xamtWoB1EshgjpmlXd7GGm2VfdDtw1+rD8uhry8pSNW3If6S8E0m2T2+orSKeZXEn/aPJMviCpDBA65WJt8zhg==}
|
||||||
|
engines: {node: '>=22.19.0'}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
resolution: {integrity: sha512-0Mqk3AT2TZCXWKdcoaufeXNukv2mTrEZExeXlHIOZXdqYoHHr4n51pymnwV8x2BOVxwXbK2HLlI7usrqMpycdg==}
|
resolution: {integrity: sha512-0Mqk3AT2TZCXWKdcoaufeXNukv2mTrEZExeXlHIOZXdqYoHHr4n51pymnwV8x2BOVxwXbK2HLlI7usrqMpycdg==}
|
||||||
engines: {node: ^20.19.0 || >=22.12.0}
|
engines: {node: ^20.19.0 || >=22.12.0}
|
||||||
@@ -7095,6 +7102,8 @@ snapshots:
|
|||||||
|
|
||||||
[email protected]: {}
|
[email protected]: {}
|
||||||
|
|
||||||
|
[email protected]: {}
|
||||||
|
|
||||||
[email protected]:
|
[email protected]:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jridgewell/remapping': 2.3.5
|
'@jridgewell/remapping': 2.3.5
|
||||||
|
|||||||
Reference in New Issue
Block a user