From 23e730ca752364efa87a7ac59d153b9b49905855 Mon Sep 17 00:00:00 2001 From: chenbowen Date: Wed, 29 Jul 2026 19:17:26 +0800 Subject: [PATCH] fix(apisix): use req_headers for active health checks --- apps/cli/src/linter/specs/upstream.spec.ts | 35 ++++++++++++++++++++ libs/backend-apisix-standalone/src/typing.ts | 2 +- libs/sdk/src/core/schema.ts | 2 +- schema.json | 4 +-- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/apps/cli/src/linter/specs/upstream.spec.ts b/apps/cli/src/linter/specs/upstream.spec.ts index b618e255..7f04f722 100644 --- a/apps/cli/src/linter/specs/upstream.spec.ts +++ b/apps/cli/src/linter/specs/upstream.spec.ts @@ -128,6 +128,41 @@ describe('Upstream Linter', () => { } as ADCSDK.Configuration, expect: true, }, + { + name: 'should accept req_headers on active health check', + input: { + services: [ + { + name: 'HealthCheck_RequestHeaders', + upstream: { + nodes: [ + { + host: '1.1.1.1', + port: 443, + weight: 100, + }, + ], + checks: { + active: { + type: 'https', + http_path: '/', + req_headers: ['User-Agent: adc-health-check'], + healthy: { + interval: 2, + successes: 1, + }, + unhealthy: { + interval: 1, + timeouts: 3, + }, + }, + }, + }, + }, + ], + } as ADCSDK.Configuration, + expect: true, + }, { name: 'should only allow upstream mtls in client_cert and client_key', input: { diff --git a/libs/backend-apisix-standalone/src/typing.ts b/libs/backend-apisix-standalone/src/typing.ts index 25f6ef14..3cb3ec04 100644 --- a/libs/backend-apisix-standalone/src/typing.ts +++ b/libs/backend-apisix-standalone/src/typing.ts @@ -147,7 +147,7 @@ const UpstreamSchema = z.strictObject({ port: z.coerce.number().int().min(1).max(65535).optional(), http_path: z.string().default('/').optional(), https_verify_certificate: z.boolean().default(true).optional(), - http_request_headers: z.array(z.string()).min(1).optional(), + req_headers: z.array(z.string()).min(1).optional(), healthy: z .strictObject({ ...upstreamHealthCheckPassiveHealthy.shape, diff --git a/libs/sdk/src/core/schema.ts b/libs/sdk/src/core/schema.ts index 4d6df219..380e0d21 100644 --- a/libs/sdk/src/core/schema.ts +++ b/libs/sdk/src/core/schema.ts @@ -123,7 +123,7 @@ const upstreamSchema = (extend?: ZodRawShape) => port: portSchema.optional(), http_path: z.string().default('/').optional(), https_verify_certificate: z.boolean().default(true).optional(), - http_request_headers: z.array(z.string()).min(1).optional(), + req_headers: z.array(z.string()).min(1).optional(), healthy: z .strictObject({ ...upstreamHealthCheckPassiveHealthy.shape, diff --git a/schema.json b/schema.json index d4e53a22..f2a24f36 100644 --- a/schema.json +++ b/schema.json @@ -128,7 +128,7 @@ "default": true, "type": "boolean" }, - "http_request_headers": { + "req_headers": { "minItems": 1, "type": "array", "items": { @@ -560,7 +560,7 @@ "default": true, "type": "boolean" }, - "http_request_headers": { + "req_headers": { "minItems": 1, "type": "array", "items": {