Repository navigation
EPMDEDP-17426: fix: Clone and push with the git binary on Alpine 3.24 - #326
geekhubuser wants to merge 1 commit into
Conversation
c379713 to
3dc1950
Compare
3dc1950 to
4af520d
Compare
4af520d to
3309f00
Compare
- Run Clone and Push with the git binary: go-git does both inside the operator, and onboarding a large repository exceeded the 1Gi memory limit - GIT_CLI_ENABLED (chart value gitCliEnabled, default true) set to false returns to go-git - Keep go-git's behaviour on the git path: host key verification and its messages, the GitServer user, keys go-git reads, the CAs Go trusts, an atomic push, the empty-remote error - Pass the token only through a credential helper that answers for the remote's own host, and no inherited GIT_ variable but the config file locations - Clone checks out after fetching every branch, and removes a partial clone after any failure, for both engines - Checkout fetches branches and tags only, not every pull request ref - Bound git's memory (delta threads, delta window bytes, big-file threshold), keep TLS verification on, and turn git maintenance off: the operator is PID 1 and does not reap it - Log the clone and push engine at startup, and exit when the git binary is missing - Build on alpine:3.24 with git and openssh-client pinned by minor: the Alpine 3.18 index dropped the pinned ca-certificates and broke every build
3309f00 to
5de2a52
Compare
|
/ok-to-test |
Pipeline
|
| Status | Task | Duration |
|---|---|---|
| ✓ Passed | github-set-pending-status | 11s |
| ✓ Passed | fetch-repository | 17s |
| ✓ Passed | init-values | 54s |
| ✓ Passed | get-cache | 2m46s |
| ✓ Passed | commit-validate | 48s |
| ✓ Passed | dockerfile-lint | 48s |
| ✓ Passed | helm-lint | 6s |
| ✓ Passed | helm-docs | 11s |
| ✓ Passed | build | 51s |
| ✓ Passed | sonar | 43s |
| ✓ Passed | save-cache | 2m21s |
| ✓ Passed | buildkit-build | 22s |
| ✓ Passed | github-report-pipeline-status | 6s |
Pushing new commits re-runs this pipeline automatically.
To re-run it without new commits, comment/recheck.
| @@ -1,4 +1,4 @@ | |||
| FROM alpine:3.18.12 | |||
| FROM alpine:3.24 | |||
There was a problem hiding this comment.
Question (non-blocking): this PR contains two changes: the base image fix (Alpine 3.18 -> 3.24, which unblocks every build, including #325) and switching clone/push from go-git to the git binary (~1.6k lines, mostly new code and tests).
Was there a reason to keep them together? Splitting them could let the build fix be reviewed and merged quickly, while the git CLI change gets a more focused review. If they depend on each other (e.g. the image needs git/ssh only because of the new code), that makes sense, I just wanted to ask.
There was a problem hiding this comment.
Thanks! This is intentional: the PO asked to bring the git CLI back in this PR, because go-git runs out of memory on large repositories.
Description
The image no longer builds, on any PR or on master. On 2026-10-20 the Alpine 3.18 x86_64 index replaced the pinned
ca-certificates 20241121-r1with20261020-r0, and Alpine keeps one version per branch:The operator also cannot onboard a large repository. Since 2.29.0 go-git clones and pushes inside the operator process. With strategy
clone, apache/kafka (312 MB) gets the operator OOM-killed at the default 1Gi limit while it pushes the branches and tags, on the current image and on a fixed one alike, and every restart starts the onboarding again, so the Codebase staysin progress.This change:
pkg/git/cli.go,CLIProvider); every other operation stays on go-git.GIT_CLI_ENABLED(chart valuegitCliEnabled, defaulttrue) set tofalsereturns to go-git without a new image.alpine:3.24withgit~=2.54andopenssh-client~=10.3, pinned by minor as in gerrit-operator, and keeps master'sentrypointanduser_setup, which give the random UID OpenShift assigns a passwd entry; ssh needs one.SSH_KNOWN_HOSTS, with the same messages (sshhostkey.OpenSSHOptions,EnrichOutput);-l; Gerrit URLs carry none);SSL_CERT_FILEor the system bundle, plus theSSL_CERT_DIRdirectories), collected intoGIT_SSL_CAINFObecause git reads neither variable, without blocks that do not parse;ErrEmptyRemoteRepository, a remote HEAD that names a missing branch withErrReferenceNotFound, and a push without refspecs pushes every branch;.gitattributesconversion on checkout, since go-git commits on that checkout later.refs/*(apache/kafka advertises about 29,000 pull request refs).pack.threads), so it does not grow with the node's CPU count; a 100 MiB delta window per thread (pack.windowMemory); blobs over 64 MiB streamed without a delta search (core.bigFileThreshold).GIT_variable except the config file locations, soGIT_DIRcannot point it at another repository andGIT_SSL_NO_VERIFYcannot turn TLS verification off; turns git maintenance off, because the operator is PID 1 and does not reap a detached process.GIT_CLI_ENABLEDvalue, exits when the git binary is missing, and logs an error when ssh is missing or the UID has no passwd entry for it.Fixes EPMDEDP-17426 (codebase-operator part; the gerrit-operator part is epam/edp-gerrit-operator#103)
Type of change
How Has This Been Tested?
kind platform with GitLab (try-kuberocketci),
codebase-operatorswitched to an image built from this branch, default 1Gi memory limit, cgroup v2:clonecreatedin 118 s; 0 restarts,oom_kill0; every branch and tag in GitLab. With go-git the same onboarding was OOM-killedclonecreatedin 510 s; 0 restarts,oom_kill0; every branch and tag in GitLabgit pushunder a 1 GiB limit in this imagepack.windowMemoryandcore.bigFileThreshold: anon 87 MiB, all pusheddefaultBranch: 4.0, not the source HEAD, so the go-git checkout fetch runs toocreated; 0 restarts,oom_kill0; every branch and tag in GitLabcreate(template over HTTPS, push over SSH), then a CodebaseBranchcreated, both branches in GitLab; git and git-remote-http seen in the containerrunAsUser: 1000680000,runAsGroup: 0, as OpenShift assigns, strategyclonecreated;whoamiresolves through the entrypoint; ssh ranGIT_CLI_ENABLED=falsecreatedwith go-git; no git or ssh process in the container2.37.0-SNAPSHOT.1The kafka, kubernetes and memory rows ran on this commit, and the binary row ran this image's git with the operator's settings. The other rows ran on an earlier build of the branch, before the review changes (byte caps, cleanup after a failed clone).
Local checks, in
golang:1.26(Go 1.26.9) on a copy of the branch:make build(amd64, arm64),make testmake linthelm lint,helm templateGIT_CLI_ENABLEDrenders"true", and"false"with--set gitCliEnabled=falsemake helm-docsgit~=2.54andopenssh-client~=10.3resolve from the aarch64 index; the image itself was not built here (no arm64 emulation on this host)alpine:3.24(OpenSSH 10.3)-lon a URL without a user; missing and changed host keys give the go-git messages; CRLF and no-newline keys workSSL_CERT_DIR), an ssh stand-in, a branch moved during the clone; each fix's test fails when the fix is removedNot run live: the Gerrit, GitHub and Bitbucket providers and
caCerts.enabled, because the testbed has GitLab only, and theimportstrategy. The sshd run covers the Gerrit URL form, the HTTPS unit test covers the CA path, and the import steps (clone, remote branch checkout, commit, push) were run against sshd outside a Codebase.Checklist:
Additional context
Upgrade notes:
gitCliEnabled: falsereturns to go-git.resources.limits.memorylike the operator's own. On cgroup v2 an OOM kills the whole container (memory.oom.group).runAsUserand a non-zerorunAsGroup, SSH clone and push fail, and the operator logs it at startup: use group 0, orgitCliEnabled: false.https_proxy/HTTPS_PROXYandno_proxy, but forhttp://URLs only the lowercasehttp_proxy, and ssh ignoresALL_PROXY. go-git honoured both; if you rely on them, usegitCliEnabled: false.[host]:22(use the plain host form for port 22, asssh-keyscanprints it).Content-Length.TMPDIR(/tmp) must be writable, also with a read-only root filesystem.Seen during the validation, not changed here: after the first push of a repository with many branches, GitLab's post-receive processing ran after the operator's default-branch call and kept the first pushed branch as the project default (kafka, kubernetes). This happens with go-git too.
Rollback:
gitCliEnabled: false, with no image change. The previous image tag no longer builds, which is the bug.#325 (EPMDEDP-17422) fails
build-and-pushfor this reason and needs this change on master first.