Repository navigation
feat(woodpecker-agent): build the agent with retry window fixes - #43
Merged
Merged
Conversation
The v3.20.1 agent counts WOODPECKER_RETRY_TIMEOUT from the moment an RPC began. Wait() stays open for the whole workflow, so the first dropped connection after two minutes gets no retry and the agent cancels every workflow it runs. keploy-ci-woodpecker-agent builds upstream's v3.20.1 with upstream's open fix (woodpecker-ci/woodpecker#7111, author kept) and three tests for the failure as our agents hit it, runs the patched package's tests in the build, and ships upstream's scratch layout. It is published as ghcr.io/keploy/keploy-ci:woodpecker-agent-<version>, amd64 only. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
With upstream's fix alone, the window counted from the first failure of a streak, and a streak ended only after an attempt that stayed up for longer than the whole window. A drop soon after the agent had reconnected still counted against the outage before it: a server down for 60 s whose new connection dropped 90 s later, or drops after connections that each worked for less than the window, made the agent give up and cancel its workflows. Patch 0003 counts the times the connection became Ready, from a goroutine that watches its state and from every failed attempt. gRPC reports Ready only after a new transport's handshake with the server, so a count that moved between two failures proves a reconnection, and that failure starts a new window. The interval keeps growing, so a server that accepts connections and drops them at once is not called every 10 ms. Patch 0002 gains rows on the fake clock: a Wait() open for 30 minutes under the default 2 minute window, past the backoff library's own 15 minute default, survives one drop; a real outage still ends within the window; an attempt that stayed up for 1.5 windows starts a new streak and resets the interval. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
The README advised a window longer than the outages to ride out, but an outage well under the window can still end with the agent giving up. While the connection is down the agent's retries do not reach the server, so gRPC's reconnect backoff decides when the connection comes back, and the agent stops up to one retry interval before the window ends. Say so, quote the measured rows, and advise a window of about twice the longest outage, or 0. Say too that keploy's agents run 0 and that the fixes matter for a finite window. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
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.
Why
On 2026-11-04 Woodpecker agents canceled every workflow they were running, 63 in all, with every step marked killed and no step failing:
too_many_pingsGOAWAY.The cause is in the v3.20.1 agent (
agent/rpc/client_grpc.go,retryRPC). It countsWOODPECKER_RETRY_TIMEOUT(2 minutes by default) from the moment an RPC began.Wait()stays open for the whole workflow, so once a workflow has run for 2 minutes, the first dropped connection gets no retry, and the runner cancels the workflow. Upstream has the issue (woodpecker-ci/woodpecker#7110) and an open fix (#7111), not yet in a release.What
A new image,
ghcr.io/keploy/keploy-ci:woodpecker-agent-<version>, built fromkeploy-ci-woodpecker-agent/:v3.20.1, checks that the tag still names commit3f1bb0bd, and appliespatches/.0001is upstream's #7111 applied to v3.20.1, author kept. The window counts from the first failure of a streak, not from the start of the RPC. An attempt that stayed up for longer than the whole window starts a new streak.0002adds tests for #7111:Wait()that outlived the window and then got the GOAWAY quoted below is retried. A second row does the same on the fake clock at production scale: a 2 minute window and a poll open for 30 minutes, past the backoff library's own 15 minute default limit;WOODPECKER_RETRY_TIMEOUT=0the interval keeps growing;0003starts the window over once the agent has reconnected. With #7111 alone, a drop soon after a reconnection counted against the outage before it. A server that was down for 60 s, came back, and dropped the new connection 90 s later made the agent give up. So did drops after connections that each worked for less than the window, as in a GOAWAY storm.-raceand fails if any fails. The binary reports version3.20.1-keploy.1.scratch, CA certificates, timezone data,/etc/woodpecker, the same entrypoint, environment and healthcheck.standalone-imagesleg indocker-build.ymlandpublish.yml, amd64 only, since every Linux agent host is x86_64.Tests
0002's production-scaleWait()row fails withbackoff: maximum elapsed time exceeded (last error: rpc error: code = Unavailable desc = closing transport due to: ... received prior goaway: code: ENHANCE_YOUR_CALM, debug data: "too_many_pings"). That is the agents' production log line.0003's rows run on the fake clock with a connection whose state the test sets:test-agentcommand passes:go test -race -cover -coverpkg=./... -timeout 60s -tags test ./cmd/agent ./agent/.... The new rows passed 30 runs in a row under-race.0001and0003, each killed by a failing test. 28 fail the whole package suite. The other 4 make the retry loop never give up, so two wall-clock tests never end: v3.20.1'sTestRetryRPCUnauthenticatedHonorsFiniteTimeoutand #7111'sTestRetryRPCGivesUpAfterWindow. With those two left out, each of the 4 is killed by a test on the fake clock.golangci/golangci-lint:v2.15.0,make lint) passes at v3.20.1. On the patched tree it reports 3usetestingfindings, all in tests that0001brings from #7111, none in0002or0003.woodpecker-agent --versionprints3.20.1-keploy.1.docker-build.yml's static checks pass: one Go patch, no MinIO client,s3.shparity, and only the base publishinglatest.Limits
While the connection is down, every RPC returns
errNotConnectedwithout calling the server, so the agent's retries do not bring the connection back. Only gRPC's reconnect backoff does: 1 s, growing 1.6x per attempt to 120 s, with about 20% jitter. Each connect attempt gets 20 s, or the current delay if that is longer. The connection can therefore return well after the server does.The agent stops up to one retry interval (at most 15 s) before the window ends.
Measured on a real gRPC connection, against an in-memory server that refuses connections until it is back, 12 runs each:
gRPC's delays and the agent's interval do not shrink with the window, so a window of seconds does worse than these shares suggest. A finite window should be minutes long and about twice the longest outage to ride out. Otherwise use 0.
stats.HandlercountingConnBeginsees every new transport, so it would catch both. gRPC calls it before the server's handshake, though, so that count alone would also take a failed handshake for a reconnection.WOODPECKER_RETRY_TIMEOUT=0, which every agent runs, this image retries as v3.20.1 does: without end, at an interval that grows to its cap. An agent whose server is gone waits instead of exiting.WOODPECKER_RETRY_TIMEOUT=0.Wait()deadline fires and the workflow is killed. That behaviour is expected and unchanged.Rollout
Not rolled out to keploy's agents. They run
WOODPECKER_RETRY_TIMEOUT=0, which retries forever, and they stay on it, so this image would change no retry behaviour for them. The image is built and published so it is ready if an agent ever needs a finite window, or until upstream ships the fix.