From ba7e05a73d66a9d9af461e158a6cae0e6dc84e9d 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): add git-clone initContainer to git-sync CronJob The git-sync CronJob only ran `git pull`/`git push` against /data/myorg but never ensured the repo existed. The clone was solely the Deployment's git-clone initContainer's job, and when that didn't populate the volume the cron pod failed with 'Not a git repository: /data/myorg' on every run (and swallowed the error, exiting 0). Add an idempotent git-clone initContainer (guarded by [ ! -d /data/myorg/.git ]) so the cron job self-heals and actually syncs. Refs: myorg-git-sync-* 'Pull: Error: Not a git repository' (last 24h+) --- myorg-assistant/cronjobs/git-sync.yaml | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/myorg-assistant/cronjobs/git-sync.yaml b/myorg-assistant/cronjobs/git-sync.yaml index c4d4dba..1078e57 100644 --- a/myorg-assistant/cronjobs/git-sync.yaml +++ b/myorg-assistant/cronjobs/git-sync.yaml @@ -24,6 +24,43 @@ spec: restartPolicy: OnFailure imagePullSecrets: - name: gitea-registry + initContainers: + - name: git-clone + image: alpine/git:latest + command: + - sh + - -c + - | + if [ ! -d /data/myorg/.git ]; then + echo "Cloning repository..." + 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 -- 2.49.1