fix(balancer): remap grpc/grpcs health check types to http/https - #14943
Open
chaitanyapantheor wants to merge 1 commit into
Open
fix(balancer): remap grpc/grpcs health check types to http/https#14943chaitanyapantheor wants to merge 1 commit into
chaitanyapantheor wants to merge 1 commit into
Conversation
lua-resty-healthcheck only accepts "tcp", "http", or "https" as checks.active.type. Kong's upstream schema already allows "grpc" and "grpcs", so translate them to their HTTP/2 equivalents (grpc -> http, grpcs -> https) on a deep copy before passing the checks table to healthcheck.new(). The original upstream entity is never mutated. Also remap passive.type defensively for the same reason. Fixes Kong#13336 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 task
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes the crash that occurs when an upstream is configured with
healthchecks.active.type: grpcorgrpcs.Error (from
error.log):This causes
declarative reconfigure failedon every worker restart whenever a gRPC upstream has active health checks enabled.Root cause
lua-resty-healthcheck(v3.1.0, pinned inkong-latest.rockspec) validateschecks.active.typeand only accepts"tcp","http", or"https". Kong's upstream schema already allows"grpc"and"grpcs"as valid values, buthealthcheckers.luapasses them verbatim tohealthcheck.new()— no translation layer existed.Fix
In
healthcheckers_M.create_healthchecker, after the existing subsystem-gating block, remapgrpc → httpandgrpcs → httpson a deep copy of thecheckstable before passing it tohealthcheck.new(). gRPC runs over HTTP/2, so these are the correct protocol equivalents for health probing. The stored upstream entity is never mutated.passive.typeis remapped defensively for the same reason.To avoid an unnecessary double deep-copy when the subsystem-gating block has already made one, a
checks_copiedflag tracks whether a copy exists.Changes
kong/runloop/balancer/healthcheckers.lua— translate grpc/grpcs to http/https before calling the healthcheck libraryspec/01-unit/09-balancer/07-healthcheckers_spec.lua— 10 unit tests: type remapping (active + passive, grpc + grpcs), pass-through for tcp/http/https, no mutation of the original upstream entity, correct interaction with the stream-subsystem gatingchangelog/unreleased/kong/fix-grpc-healthcheck-active-type.yml— bugfix changelog YAML (CHANGELOG.mdis not modified, per contributing guidelines)Pre-submit checklist
mastermake lint(requires Xcode/Bazel locally; blocked in this environment — please verify in CI)make testorbin/busted -v spec/01-unit/09-balancer/07-healthcheckers_spec.luaCHANGELOG.mdis not modified — a YAML file was added tochangelog/unreleased/kong/insteadHow to test manually
healthchecks.active.type: grpc,healthy.interval: 1, andhealthy.successes: 1error.logdoes not containchecks.active.type can only beGET /upstreams/<name>/healthFixes #13336