test(kubernetes): stop TEST 3 failing on the expected apiserver connect error#13701
Open
nic-6443 wants to merge 1 commit into
Open
test(kubernetes): stop TEST 3 failing on the expected apiserver connect error#13701nic-6443 wants to merge 1 commit into
nic-6443 wants to merge 1 commit into
Conversation
…ct error
TEST 3 is the only block in the file whose `service.host` is not the
apiserver the CI port-forwards to 127.0.0.1, so its informer can never
connect. The connect failure logs an `[error]`, and whether it lands inside
the block's window depends on how long resolving the host takes, so the
default `no_error_log: [error]` fails the block intermittently:
TEST 3: mixing set custom and default values - pattern "[error]" should
not match any line in error.log but matches line "... informer_factory.lua:302:
connect apiserver failed, apiserver.host: sample.com, apiserver.port: 6443,
message : connection refused, context: ngx.timer"
The block only compares the resolved configuration and never intends to
reach an apiserver, so the connect error is expected noise. Override
`no_error_log` for this block alone.
The neighbouring blocks are unaffected: they point at 127.0.0.1, which the
job actually serves. (Run the file without an apiserver on 127.0.0.1:6443
and the failure moves to them, with the same signature, while TEST 3 passes.)
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.
Description
t/kubernetes/discovery/kubernetes.tTEST 3 fails intermittently on master, for example in this run:TEST 3 is the only block in the file whose
service.hostis not the apiserver the job exposes on127.0.0.1:6443, so its informer can never connect. Configuringdiscovery.kubernetesstarts the informer regardless, it fails to connect in anngx.timer, and it logs an[error]. The block sets neithererror_lognorno_error_log, sot/APISIX.pmgives it the defaultno_error_log: [error]and the block fails — but only when the connect fails early enough to land inside the block's own window. Each block here has its ownyaml_config, so nginx restarts between blocks and a slow-enough resolve means the timer is killed before it ever logs. That is what makes it intermittent rather than a hard failure.The block only compares the resolved configuration through
/compareand never intends to reach an apiserver, so the connect error is expected noise rather than a defect. This overridesno_error_logfor that block alone, using the same idiom already used elsewhere int/.Why not map the host in
/etc/hostsinstead?That was my first instinct too, since
ci/common.sh'sset_coredns()already pinstest.comandadmin.apisix.devthat way. It does work for TEST 3 — the tests resolve through/etc/resolv.conf(t::APISIX::local_dns_resolver), which on the runners is systemd-resolved, and that does serve/etc/hostsentries over DNS. Pointingsample.comat127.0.0.1makes the informer connect to the real apiserver (ssl_verifydefaults to false, so the certificate name does not matter) and the block then passes with its[error]guard intact.I did not take that route because it does not generalise, and the reason is instructive. TEST 5 is the same kind of block — config comparison only, no
no_error_logoverride — but its hosts cannot be mapped:1.cluster.com:6445ishttps, while thekubectl proxyon 6445 speaks plain HTTP;2.cluster.com:6443ishttp, while 6443 is the HTTPS apiserver.Mapping all three hostnames to
127.0.0.1on a local replica of the CI cluster fails TEST 5 deterministically (2 failures on every run), withconnect apiserver failedfor the first andlist failed ... Client sent an HTTP request to an HTTPS serverfor the second. Sosample.comonly works by coincidence — it happens to behttpson the one port that hosts a real apiserver.That asymmetry is the point: these hostnames are deliberately fictitious and the blocks only compare configuration, which is why suppressing the expected error is the fix that matches the file rather than a special case that works for one block out of three and quietly breaks another.
How this was verified
On a local replica of the CI cluster (
kindwitht/kubernetes/configs/kind.yaml, the fixtures from the workflow and the service account token in place), pointingsample.comat an address that refuses6443reproduces the CI failure deterministically:The neighbouring blocks are deliberately left alone: they point at
127.0.0.1, which the job actually serves.Checklist