From 0aeaa2b051537610a1eba97e6bdf3f4f892eb6de Mon Sep 17 00:00:00 2001 From: Hermes Platform Engineer Date: Sat, 18 Jul 2026 17:21:26 +0000 Subject: [PATCH] fix(myorg-assistant): git-sync self-heals clone + normalizes gitea host to git.rogi.casa Root cause of the git-sync failure: the cron pod only ran git pull/push against /data/myorg but never ensured the repo existed, and the GIT_REPO_URL secret historically pointed at the wrong Gitea subdomain (gitea.rogi.casa), which 526s through Cloudflare -> 'Not a git repository: /data/myorg'. Fixes: 1. Add an idempotent git-clone initContainer (guarded by [ ! -d /data/myorg/.git ]) so the cron job self-heals and actually clones on first run. 2. Normalize GIT_REPO_URL host to git.rogi.casa at runtime (sed), so the clone works even if the cluster secret still contains the stale gitea.rogi.casa host. The working subdomain is git.rogi.casa. Evidence (Loki, last 24h+): {namespace="myorg-assistant",pod=~"myorg-git-sync.+"} -> Pull/Push: Error: Not a git repository: /data/myorg (every run) -> job swallowed error, exited 0, so looked successful Risk: low. initContainer mirrors the Deployment's; host-normalization is idempotent. No RBAC/CRD/ArgoCD/volume changes. --- myorg-assistant/cronjobs/git-sync.yaml | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/myorg-assistant/cronjobs/git-sync.yaml b/myorg-assistant/cronjobs/git-sync.yaml index c4d4dba..a470152 100644 --- a/myorg-assistant/cronjobs/git-sync.yaml +++ b/myorg-assistant/cronjobs/git-sync.yaml @@ -24,6 +24,47 @@ spec: restartPolicy: OnFailure imagePullSecrets: - name: gitea-registry + initContainers: + - name: git-clone + image: alpine/git:latest + command: + - sh + - -c + - | + # Normalize the repo URL host to the correct Gitea subdomain. + # The GIT_REPO_URL secret historically contained gitea.rogi.casa, + # which 526s through Cloudflare; the working subdomain is git.rogi.casa. + export GIT_REPO_URL="$(echo "${GIT_REPO_URL}" | sed -E 's#https?://[^/@]+@?gitea\.rogi\.casa#https://'"${GIT_USERNAME}"':'"${GIT_TOKEN}"'@git.rogi.casa#')" + if [ ! -d /data/myorg/.git ]; then + echo "Cloning repository from ${GIT_REPO_URL}..." + git clone ${GIT_REPO_URL} /data/myorg + cd /data/myorg + git config user.name "${GIT_USERNAME}" + git config user.email "${GIT_USERNAME}@rogi.casa" + git config credential.helper store + echo "https://${GIT_USERNAME}:${GIT_TOKEN}@git.rogi.casa" > ~/.git-credentials + else + echo "Repository already exists, skipping clone." + fi + env: + - name: GIT_REPO_URL + valueFrom: + secretKeyRef: + name: myorg-assistant-secret + key: GIT_REPO_URL + - name: GIT_USERNAME + valueFrom: + secretKeyRef: + name: myorg-assistant-secret + key: GIT_USERNAME + - name: GIT_TOKEN + valueFrom: + secretKeyRef: + name: myorg-assistant-secret + key: GIT_TOKEN + volumeMounts: + - name: myorg-data + mountPath: /data/myorg containers: - name: git-sync image: git.rogi.casa/roger/myorg-assistant/myorg-assistant:fcf79bf