Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ jobs:
tag-prefix: 'ebpf-objects-'
arch: amd64
go: true
- context: ./keploy-ci-woodpecker-agent
tag-prefix: 'woodpecker-agent-'
arch: amd64

steps:
- name: Checkout repository
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ jobs:
- context: ./keploy-ci-ebpf-objects
tag-prefix: 'ebpf-objects-'
platforms: linux/amd64
# Built from upstream's source too, and nothing builds FROM it.
# amd64-only: every Linux Woodpecker agent host is x86_64.
- context: ./keploy-ci-woodpecker-agent
tag-prefix: 'woodpecker-agent-'
platforms: linux/amd64

steps:
- name: Checkout repository
Expand Down
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,59 @@ by digest, and it cannot be rebuilt after that window.

Tag: `ghcr.io/keploy/keploy-ci:ebpf-objects-<version>`.

### keploy-ci-woodpecker-agent

The Woodpecker CI agent, built from upstream's source at a pinned tag and
commit with the patches in `keploy-ci-woodpecker-agent/patches/`, for the Linux
agents that run in docker. It takes upstream's `woodpeckerci/woodpecker-agent`
image's place at the same version, with the same settings.

**Why:** the v3.20.1 agent counts `WOODPECKER_RETRY_TIMEOUT` (2 minutes by
default) from the moment an RPC began, not from its first failure. `Wait()`
stays open for the whole workflow, so when the connection to the server drops
once after that, the agent does not retry: it cancels every workflow it is
running, and every step shows as killed. Patch 0001 is upstream's open fix,
woodpecker-ci/woodpecker#7111 (issue #7110), applied to v3.20.1: the window
counts from the first failure. Patch 0002 adds tests for the failure as it
happened on our agents: a `Wait()` that outlived the window and then got the
server's `too_many_pings` GOAWAY, at production scale too (a 2 minute window
and a poll open for 30 minutes), and the window's edges. Patch 0003 starts the
window over once the agent has reconnected, so a drop soon after a
reconnection (a server restart followed by another drop, or a storm of
GOAWAYs) is retried instead of being counted against the outage before it.
The build runs the patched package's tests and fails if one fails.

keploy's agents run `WOODPECKER_RETRY_TIMEOUT=0`, which retries forever, and
at 0 this image retries as v3.20.1 does. The fixes matter for a finite window:
upstream's users, and anyone who sets one.

A finite window rides out only outages well shorter than itself. When the agent
gives up, the runner cancels every workflow on the agent. While the connection
is down, every RPC returns `errNotConnected` without 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, and a
connect attempt can take 20 s or more. The agent also stops up to one retry
interval (at most 15 s) before the window ends. With a 6 s window, an outage of
60% of it gave up in 5 of 6 runs. With a 2 minute window, 1 of 12 runs gave up
at 60%, and none at 50%. So choose a window of minutes, about twice the longest
outage to ride out, or 0.

**Contents:** the `woodpecker-agent` binary (reporting version
`<tag>-keploy.<n>`), CA certificates, timezone data, and upstream's
`/etc/woodpecker` layout, on `scratch`, as upstream's image. amd64 only: every
Linux agent host is x86_64. The macOS and Windows agents run the binary
natively and do not use this image.

```yaml
# The agent's compose service
image: ghcr.io/keploy/keploy-ci:woodpecker-agent-<version>
```

When an upstream release carries these fixes, move the agents back to
upstream's image at that release and delete this directory.

Tag: `ghcr.io/keploy/keploy-ci:woodpecker-agent-<version>`.

## The CI object store: s3.sh, not `mc`

None of these images ships MinIO's `mc` any more. The CI store behind
Expand Down
72 changes: 72 additions & 0 deletions keploy-ci-woodpecker-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# keploy-ci-woodpecker-agent: the Woodpecker CI agent, built from upstream's
# source at WOODPECKER_TAG with the patches in patches/ applied.
# Used by: the Linux Woodpecker agents (docker), in place of
# woodpeckerci/woodpecker-agent at the same version.
#
# Why: the v3.20.1 agent counts WOODPECKER_RETRY_TIMEOUT (2 minutes by default)
# 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 is running, with every step marked killed.
# 0001 is woodpecker-ci/woodpecker#7111 (for issue #7110), still open
# upstream, applied to v3.20.1; 0002 adds the tests for the failure as it
# happened here; 0003 starts the window over once the agent has reconnected,
# so a drop soon after a reconnection is retried too. When an upstream release
# carries these fixes, go back to upstream's image and delete this one.
#
# Follows upstream's docker/Dockerfile.agent.multiarch: the agent is built on
# the build platform for the target, and the final image is scratch.
FROM --platform=$BUILDPLATFORM golang:1.27.3-bookworm@sha256:972b4110ba0f47539a975c31e52c64765e1ff19f2d74469ae4a595c6676e80a5 AS build

ARG WOODPECKER_TAG=v3.20.1
ARG WOODPECKER_COMMIT=3f1bb0bd0db28e410ad797034d75780116122c91
# Bump with every change to patches/: the agent reports it as its version.
ARG KEPLOY_BUILD=keploy.1

RUN groupadd -g 1000 woodpecker && \
useradd -u 1000 -g 1000 woodpecker && \
mkdir -p /etc/woodpecker

# Upstream's image carries the backward compatible timezone names too
# (US/Eastern, Asia/Calcutta...). Bookworm's tzdata still ships them; trixie,
# which upstream builds on, moved them to tzdata-legacy.
RUN apt-get update && \
apt-get install -y --no-install-recommends tzdata && \
test -e /usr/share/zoneinfo/US/Eastern && \
rm -rf /usr/share/zoneinfo/right /var/lib/apt/lists/*

# The tag must still name the commit the patches were made against.
RUN git clone --quiet --depth 1 --branch "$WOODPECKER_TAG" \
https://github.com/woodpecker-ci/woodpecker.git /src && \
got="$(git -C /src rev-parse HEAD)" && \
{ [ "$got" = "$WOODPECKER_COMMIT" ] || { echo "$WOODPECKER_TAG is $got, not $WOODPECKER_COMMIT" >&2; exit 1; }; }

WORKDIR /src
COPY patches/ /patches/
RUN git apply --index /patches/*.patch

# The patched package's tests, on the build platform, so a patch that no
# longer does what it says fails the build here.
RUN go test -race -count=1 -timeout 120s -tags test ./agent/rpc/

ARG TARGETOS TARGETARCH
RUN make build-agent CI_COMMIT_TAG="${WOODPECKER_TAG}-${KEPLOY_BUILD}" CI_COMMIT_SHA="$WOODPECKER_COMMIT"

FROM scratch AS stage

COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build /etc/group /etc/group
COPY --from=build --chown=woodpecker:woodpecker /etc/woodpecker /etc

FROM scratch
ENV GODEBUG=netdns=go
# Upstream's internal setting: tells the agent it runs inside a container.
ENV WOODPECKER_IN_CONTAINER=true
EXPOSE 3000

COPY --from=stage / /
COPY --from=build /src/dist/woodpecker-agent /bin/

HEALTHCHECK CMD ["/bin/woodpecker-agent", "ping"]
ENTRYPOINT ["/bin/woodpecker-agent"]
Loading
Loading