Closed anilsati79 closed 1 month ago
I had the same problem with the latest version of git-sync
. After checking the logs and debugging, I found out there's a problem of git client not able to read from the provided ssh-keys from /etc/git-secret
directory. The solution I came up with to add the following environment variable, so guide the git client to read from this directory:
export GIT_SSH_COMMAND="ssh -i /etc/git-secret/ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no"
The complete example based on the provided docs is as follows:
apiVersion: apps/v1
kind: Deployment
metadata:
name: git-sync
spec:
selector:
matchLabels:
demo: git-sync
template:
metadata:
labels:
demo: git-sync
spec:
volumes:
- name: git-secret
secret:
secretName: git-creds
defaultMode: 0400
containers:
- name: git-sync
image: registry.k8s.io/git-sync:v4.0.0
args:
- "--repo=git@github.com:torvalds/linux"
- "--depth=1"
env:
# I don't know why I had to set this env. It took me a long time to but I guess there's a bug here
- name: GIT_SSH_COMMAND
value: "ssh -i /etc/git-secret/ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no"
securityContext:
runAsUser: 65533 # git-sync user
volumeMounts:
- name: git-secret
mountPath: /etc/git-secret
readOnly: true
securityContext:
fsGroup: 65533 # to make SSH key readable
My guess it's a bug that'll hopefully fixed in the near future. But this worked for me.
I am sorry, I don't know what the problem here is. I just tried to repoduce it and, while I found a bug in the docs (https://github.com/kubernetes/git-sync/pull/921), it is not related to this.
I literally just ran this deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: git-sync
spec:
selector:
matchLabels:
demo: git-sync
template:
metadata:
labels:
demo: git-sync
spec:
volumes:
- name: git-secret
secret:
secretName: git-creds
defaultMode: 0400
containers:
- name: git-sync
image: registry.k8s.io/git-sync/git-sync:v4.2.4
args:
- "--repo=git@github.com:kubernetes/git-sync"
- "--depth=1"
- "--ssh-known-hosts=false"
securityContext:
runAsUser: 65533 # git-sync user
volumeMounts:
- name: git-secret
mountPath: /etc/git-secret
readOnly: true
securityContext:
fsGroup: 65533 # to make SSH key readable
Can you please try that and see if it doesn't work? If not, please post the EXACT yaml you used and the full logs with -v6
@e3oroush thanks to mention this. Actually ssh -i /etc/git-secret/ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no. Will force to use mentioned path for ssh keys..And it worked.!! for version v4.0.0 Without above flag --ssh-key-file seems ignored and it try to use some default location and ssh shakehand fails.
@thockin you are also right....with v4.2.4 no need to provide ......ssh -i /etc/git-secret/ssh -o IdentitiesOnly=yes
For me at least ssh shake/hand seems started. But still having some permission issue.
Note : If i do ssh using same key, git commands are successfull from command line but with gitsync on kubernetes(minikube or test environment) it fails.
Couple of line from log file {"logger":"","ts":"2024-09-16 22:21:49.741446","caller":{"file":"main.go","line":855},"msg":"too many failures, aborting","error":"Run(git fetch git@git.xyz.cloud:dds/xyx.xyz.git HEAD --verbose --no-progress --prune --no-auto-gc --depth 1): exit status 128: { stdout: \"\", stderr: \"Warning: Permanently added 'git.xyz.cloud' (ECDSA) to the list of known hosts.\r\nLoad key \\"/etc/git-secret/ssh\\": Is a directory\r\ngit@git.xyz.cloud: Permission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\" }","failCount":1}
I'm sorry I'm a little confused now. Are you saying that the bug does not exist in 4.2.4? That is the latest release, so it's entirely possible that it was fixed along the way. My memory is terrible.
As for the other failure you're seeing, can you please post a complete repro? I need all of the flags that you used. Or better run with -v6, and post the logs. The whole logs
HI @thockin , Thanks for quick response. Yes with latest version(i tried v4.2.4) no need to providde any ssh command to force to look for specific key file location.
Please find log for error i mentioned:
Flag used are as below: --repo, --depth, --root, --verbose=6, --ssh-known-hosts=false
INFO: detected pid 1, running init handler {"logger":"","ts":"2024-09-16 22:21:49.602476","caller":{"file":"main.go","line":568},"level":0,"msg":"starting up","version":"v4.2.4","pid":11,"uid":65533,"gid":65533,"home":"/tmp","flags":["--add-user=false","--askpass-url=","--cookie-file=false","--credential=[]","--depth=1","--error-file=","--exechook-backoff=3s","--exechook-command=","--exechook-timeout=30s","--git=git","--git-config=","--git-gc=always","--group-write=false","--help=false","--http-bind=","--http-metrics=false","--http-pprof=false","--link=my.repo.files.git","--man=false","--max-failures=0","--one-time=false","--password-file=","--period=10s","--ref=HEAD","--repo=git@git.somebody.cloud:dds/my.repo.files.git","--root=/repo/files","--sparse-checkout-file=","--ssh-key-file=[/etc/git-secret/ssh]","--ssh-known-hosts=false","--ssh-known-hosts-file=/etc/git-secret/known_hosts","--stale-worktree-timeout=0s","--submodules=recursive","--sync-on-signal=","--sync-timeout=2m0s","--touch-file=","--username=","--verbose=6","--version=false","--webhook-backoff=3s","--webhook-method=POST","--webhook-success-status=200","--webhook-timeout=1s","--webhook-url="]} {"logger":"","ts":"2024-09-16 22:21:49.602647","caller":{"file":"main.go","line":669},"level":5,"msg":"running command","cwd":"","cmd":"git version"} {"logger":"","ts":"2024-09-16 22:21:49.603799","caller":{"file":"main.go","line":669},"level":6,"msg":"command result","stdout":"git version 2.39.2","stderr":"","time":"1.101552ms"} {"logger":"","ts":"2024-09-16 22:21:49.603837","caller":{"file":"main.go","line":673},"level":0,"msg":"git version","version":"git version 2.39.2"} {"logger":"","ts":"2024-09-16 22:21:49.604131","caller":{"file":"main.go","line":685},"level":2,"msg":"created private gitconfig file","path":"/tmp/git-sync.gitconfig.645497711"} {"logger":"","ts":"2024-09-16 22:21:49.604171","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global gc.autoDetach false"} {"logger":"","ts":"2024-09-16 22:21:49.605333","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"1.13811ms"} {"logger":"","ts":"2024-09-16 22:21:49.605377","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global gc.pruneExpire now"} {"logger":"","ts":"2024-09-16 22:21:49.606322","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"918.885µs"} {"logger":"","ts":"2024-09-16 22:21:49.606356","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global credential.helper \"cache --timeout 3600\""} {"logger":"","ts":"2024-09-16 22:21:49.607334","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"954.981µs"} {"logger":"","ts":"2024-09-16 22:21:49.607359","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global core.askPass true"} {"logger":"","ts":"2024-09-16 22:21:49.608629","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"1.250528ms"} {"logger":"","ts":"2024-09-16 22:21:49.608673","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global safe.directory *"} {"logger":"","ts":"2024-09-16 22:21:49.610000","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"1.29153ms"} {"logger":"","ts":"2024-09-16 22:21:49.610042","caller":{"file":"main.go","line":1814},"level":1,"msg":"setting up git SSH credentials"} {"logger":"","ts":"2024-09-16 22:21:49.610062","caller":{"file":"main.go","line":1625},"level":3,"msg":"syncing","repo":"git@git.somebody.cloud:dds/my.repo.files.git"} {"logger":"","ts":"2024-09-16 22:21:49.610077","caller":{"file":"main.go","line":1160},"level":3,"msg":"repo directory exists","path":"/repo/files"} {"logger":"","ts":"2024-09-16 22:21:49.610125","caller":{"file":"main.go","line":1232},"level":3,"msg":"sanity-checking git repo","repo":"/repo/files"} {"logger":"","ts":"2024-09-16 22:21:49.610182","caller":{"file":"main.go","line":1243},"level":5,"msg":"running command","cwd":"/repo/files","cmd":"git rev-parse --show-toplevel"} {"logger":"","ts":"2024-09-16 22:21:49.611195","caller":{"file":"main.go","line":1243},"level":6,"msg":"command result","stdout":"/repo/files","stderr":"","time":"935.288µs"} {"logger":"","ts":"2024-09-16 22:21:49.611226","caller":{"file":"main.go","line":1256},"level":5,"msg":"running command","cwd":"/repo/files","cmd":"git fsck --no-progress --connectivity-only"} {"logger":"","ts":"2024-09-16 22:21:49.615617","caller":{"file":"main.go","line":1256},"level":6,"msg":"command result","stdout":"","stderr":"notice: HEAD points to an unborn branch (git-sync)\nnotice: No default references","time":"4.358576ms"} {"logger":"","ts":"2024-09-16 22:21:49.615665","caller":{"file":"main.go","line":1162},"level":4,"msg":"repo directory is valid","path":"/repo/files"} {"logger":"","ts":"2024-09-16 22:21:49.615678","caller":{"file":"main.go","line":1189},"level":5,"msg":"running command","cwd":"/repo/files","cmd":"git remote get-url origin"} {"logger":"","ts":"2024-09-16 22:21:49.616604","caller":{"file":"main.go","line":1189},"level":6,"msg":"command result","stdout":"git@git.somebody.cloud:dds/my.repo.files.git","stderr":"","time":"902.212µs"} {"logger":"","ts":"2024-09-16 22:21:49.616668","caller":{"file":"main.go","line":1644},"level":3,"msg":"current state","hash":"","worktree":""} {"logger":"","ts":"2024-09-16 22:21:49.616681","caller":{"file":"main.go","line":1750},"level":2,"msg":"fetching","ref":"HEAD","repo":"git@git.somebody.cloud:dds/my.repo.files.git"} {"logger":"","ts":"2024-09-16 22:21:49.616704","caller":{"file":"main.go","line":1768},"level":5,"msg":"running command","cwd":"/repo/files","cmd":"git fetch git@git.somebody.cloud:dds/my.repo.files.git HEAD --verbose --no-progress --prune --no-auto-gc --depth 1"} {"logger":"","ts":"2024-09-16 22:21:49.741446","caller":{"file":"main.go","line":855},"msg":"too many failures, aborting","error":"Run(git fetch git@git.somebody.cloud:dds/my.repo.files.git HEAD --verbose --no-progress --prune --no-auto-gc --depth 1): exit status 128: { stdout: \"\", stderr: \"Warning: Permanently added 'git.somebody.cloud' (ECDSA) to the list of known hosts.\r\nLoad key \\"/etc/git-secret/ssh\\": Is a directory\r\ngit@git.somebody.cloud: Permission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\" }","failCount":1}
This error is telling us that "/etc/git-secret/ssh" is a directory, but it is expected to be a file. As a result, no key is loaded, and authn fails.
How are you mounting the key?
Hi @thockin ,
You are absolutely right!! I assumed it as key file location. Now it has been fixed .
But i am still getting permission error. Same key is fine when i do ssh from command line(Windows). While in test environment(kubernetes cluster) it fails.
Note: I have copied ssh keys from window machin to vault and then copying ssh from vault to mounted volume.
Error after correction regarding key file.
INFO: detected pid 1, running init handler {"logger":"","ts":"2024-09-17 16:38:01.878354","caller":{"file":"main.go","line":568},"level":0,"msg":"starting up","version":"v4.2.4","pid":12,"uid":65533,"gid":65533,"home":"/tmp","flags":["--add-user=false","--askpass-url=","--cookie-file=false","--credential=[]","--depth=1","--error-file=","--exechook-backoff=3s","--exechook-command=","--exechook-timeout=30s","--git=git","--git-config=","--git-gc=always","--group-write=false","--help=false","--http-bind=","--http-metrics=false","--http-pprof=false","--link=someone-get-config.git","--man=false","--max-failures=0","--one-time=false","--password-file=","--period=10s","--ref=main","--repo=git@git.someone.cloud:dds/someone-get-config.git","--root=/gitsync/repo","--sparse-checkout-file=","--ssh-key-file=[/etc/git-secret/ssh]","--ssh-known-hosts=false","--ssh-known-hosts-file=/etc/git-secret/known_hosts","--stale-worktree-timeout=0s","--submodules=recursive","--sync-on-signal=","--sync-timeout=2m0s","--touch-file=","--username=","--verbose=6","--version=false","--webhook-backoff=3s","--webhook-method=POST","--webhook-success-status=200","--webhook-timeout=1s","--webhook-url="]} {"logger":"","ts":"2024-09-17 16:38:01.878642","caller":{"file":"main.go","line":669},"level":5,"msg":"running command","cwd":"","cmd":"git version"} {"logger":"","ts":"2024-09-17 16:38:01.880994","caller":{"file":"main.go","line":669},"level":6,"msg":"command result","stdout":"git version 2.39.2","stderr":"","time":"2.28417ms"} {"logger":"","ts":"2024-09-17 16:38:01.881035","caller":{"file":"main.go","line":673},"level":0,"msg":"git version","version":"git version 2.39.2"} {"logger":"","ts":"2024-09-17 16:38:01.881245","caller":{"file":"main.go","line":685},"level":2,"msg":"created private gitconfig file","path":"/tmp/git-sync.gitconfig.499604852"} {"logger":"","ts":"2024-09-17 16:38:01.881279","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global gc.autoDetach false"} {"logger":"","ts":"2024-09-17 16:38:01.883349","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"2.01792ms"} {"logger":"","ts":"2024-09-17 16:38:01.883420","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global gc.pruneExpire now"} {"logger":"","ts":"2024-09-17 16:38:01.885247","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"1.752281ms"} {"logger":"","ts":"2024-09-17 16:38:01.885318","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global credential.helper \"cache --timeout 3600\""} {"logger":"","ts":"2024-09-17 16:38:01.887092","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"1.694352ms"} {"logger":"","ts":"2024-09-17 16:38:01.887160","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global core.askPass true"} {"logger":"","ts":"2024-09-17 16:38:01.888934","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"1.67196ms"} {"logger":"","ts":"2024-09-17 16:38:01.889006","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global safe.directory *"} {"logger":"","ts":"2024-09-17 16:38:01.890815","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"1.732604ms"} {"logger":"","ts":"2024-09-17 16:38:01.890882","caller":{"file":"main.go","line":1814},"level":1,"msg":"setting up git SSH credentials"} {"logger":"","ts":"2024-09-17 16:38:01.890932","caller":{"file":"main.go","line":1625},"level":3,"msg":"syncing","repo":"git@git.someone.cloud:dds/someone-get-config.git"} {"logger":"","ts":"2024-09-17 16:38:01.890986","caller":{"file":"main.go","line":1160},"level":3,"msg":"repo directory exists","path":"/gitsync/repo"} {"logger":"","ts":"2024-09-17 16:38:01.891040","caller":{"file":"main.go","line":1232},"level":3,"msg":"sanity-checking git repo","repo":"/gitsync/repo"} {"logger":"","ts":"2024-09-17 16:38:01.891149","caller":{"file":"main.go","line":1243},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git rev-parse --show-toplevel"} {"logger":"","ts":"2024-09-17 16:38:01.893192","caller":{"file":"main.go","line":1243},"level":6,"msg":"command result","stdout":"/gitsync/repo","stderr":"","time":"1.953679ms"} {"logger":"","ts":"2024-09-17 16:38:01.893273","caller":{"file":"main.go","line":1256},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git fsck --no-progress --connectivity-only"} {"logger":"","ts":"2024-09-17 16:38:01.901514","caller":{"file":"main.go","line":1256},"level":6,"msg":"command result","stdout":"","stderr":"notice: HEAD points to an unborn branch (git-sync)\nnotice: No default references","time":"8.155059ms"} {"logger":"","ts":"2024-09-17 16:38:01.901586","caller":{"file":"main.go","line":1162},"level":4,"msg":"repo directory is valid","path":"/gitsync/repo"} {"logger":"","ts":"2024-09-17 16:38:01.901637","caller":{"file":"main.go","line":1189},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git remote get-url origin"} {"logger":"","ts":"2024-09-17 16:38:01.903836","caller":{"file":"main.go","line":1189},"level":6,"msg":"command result","stdout":"git@git.someone.cloud:dds/someone-get-config.git","stderr":"","time":"2.112907ms"} {"logger":"","ts":"2024-09-17 16:38:01.903912","caller":{"file":"main.go","line":1644},"level":3,"msg":"current state","hash":"","worktree":""} {"logger":"","ts":"2024-09-17 16:38:01.903978","caller":{"file":"main.go","line":1750},"level":2,"msg":"fetching","ref":"main","repo":"git@git.someone.cloud:dds/someone-get-config.git"} {"logger":"","ts":"2024-09-17 16:38:01.904039","caller":{"file":"main.go","line":1768},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git fetch git@git.someone.cloud:dds/someone-get-config.git main --verbose --no-progress --prune --no-auto-gc --depth 1"} {"logger":"","ts":"2024-09-17 16:38:02.066260","caller":{"file":"main.go","line":855},"msg":"too many failures, aborting","error":"Run(git fetch git@git.someone.cloud:dds/someone-get-config.git main --verbose --no-progress --prune --no-auto-gc --depth 1): exit status 128: { stdout: \"\", stderr: \"Warning: Permanently added 'git.someone.cloud' (ECDSA) to the list of known hosts.\r\ngit@git.someone.cloud: Permission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\" }","failCount":1}
Did you set permissions properly?
https://github.com/kubernetes/git-sync/blob/master/docs/ssh.md explains how to make sure the key is readable by the git-sync user (which is non-root).
Sure @thockin i will check and update. Thanks a lot for quick response... Though i am not sure how flexible we are with infra(If i refer above link). For now we can create ssh key with terraform and injecting same to vault then from vault to mounted volume.
Hi @thockin, Lot of progress!!Still having issue.
Currently i am running version v4.2.4 as a initContainer(I have a requirement to clone before main container runs, and sync with repo as soon as repo updated) with restartPolicy: Always. Issue : Its status is running but not ready for long time. And repo i am trying to clone is too small. So seems like some issue here or may be its expected as flag one-time=false
Is it meant to be run as main container(sample you provided) or can be used inside initContainer without exit?
Logs..
INFO: detected pid 1, running init handler {"logger":"","ts":"2024-09-18 09:27:43.874575","caller":{"file":"main.go","line":568},"level":0,"msg":"starting up","version":"v4.2.4","pid":12,"uid":65533,"gid":65533,"home":"/tmp","flags":["--add-user=false","--askpass-url=","--cookie-file=false","--credential=[]","--depth=1","--error-file=","--exechook-backoff=3s","--exechook-command=","--exechook-timeout=30s","--git=git","--git-config=","--git-gc=always","--group-write=false","--help=false","--http-bind=","--http-metrics=false","--http-pprof=false","--link=someone-get-config.git","--man=false","--max-failures=0","--one-time=false","--password-file=","--period=1h0m0s","--ref=main","--repo=git@git.someone.cloud:dds/someone-get-config.git","--root=/gitsync/repo","--sparse-checkout-file=","--ssh-key-file=[/etc/git-secret/ssh]","--ssh-known-hosts=false","--ssh-known-hosts-file=/etc/git-secret/known_hosts","--stale-worktree-timeout=0s","--submodules=recursive","--sync-on-signal=","--sync-timeout=2m0s","--touch-file=","--username=","--verbose=6","--version=false","--webhook-backoff=3s","--webhook-method=POST","--webhook-success-status=200","--webhook-timeout=1s","--webhook-url="]} {"logger":"","ts":"2024-09-18 09:27:43.874866","caller":{"file":"main.go","line":669},"level":5,"msg":"running command","cwd":"","cmd":"git version"} {"logger":"","ts":"2024-09-18 09:27:43.877051","caller":{"file":"main.go","line":669},"level":6,"msg":"command result","stdout":"git version 2.39.2","stderr":"","time":"1.97715ms"} {"logger":"","ts":"2024-09-18 09:27:43.877082","caller":{"file":"main.go","line":673},"level":0,"msg":"git version","version":"git version 2.39.2"} {"logger":"","ts":"2024-09-18 09:27:43.877272","caller":{"file":"main.go","line":685},"level":2,"msg":"created private gitconfig file","path":"/tmp/git-sync.gitconfig.3229031793"} {"logger":"","ts":"2024-09-18 09:27:43.877303","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global gc.autoDetach false"} {"logger":"","ts":"2024-09-18 09:27:43.879619","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"2.275052ms"} {"logger":"","ts":"2024-09-18 09:27:43.879648","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global gc.pruneExpire now"} {"logger":"","ts":"2024-09-18 09:27:43.881692","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"1.997885ms"} {"logger":"","ts":"2024-09-18 09:27:43.881734","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global credential.helper \"cache --timeout 3600\""} {"logger":"","ts":"2024-09-18 09:27:43.883733","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"1.949452ms"} {"logger":"","ts":"2024-09-18 09:27:43.883884","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global core.askPass true"} {"logger":"","ts":"2024-09-18 09:27:43.886068","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"2.053376ms"} {"logger":"","ts":"2024-09-18 09:27:43.886095","caller":{"file":"main.go","line":1945},"level":5,"msg":"running command","cwd":"","cmd":"git config --global safe.directory "} {"logger":"","ts":"2024-09-18 09:27:43.887937","caller":{"file":"main.go","line":1945},"level":6,"msg":"command result","stdout":"","stderr":"","time":"1.805412ms"} {"logger":"","ts":"2024-09-18 09:27:43.887965","caller":{"file":"main.go","line":1814},"level":1,"msg":"setting up git SSH credentials"} {"logger":"","ts":"2024-09-18 09:27:43.888004","caller":{"file":"main.go","line":1625},"level":3,"msg":"syncing","repo":"git@git.someone.cloud:dds/someone-get-config.git"} {"logger":"","ts":"2024-09-18 09:27:43.888047","caller":{"file":"main.go","line":1160},"level":3,"msg":"repo directory exists","path":"/gitsync/repo"} {"logger":"","ts":"2024-09-18 09:27:43.888059","caller":{"file":"main.go","line":1232},"level":3,"msg":"sanity-checking git repo","repo":"/gitsync/repo"} {"logger":"","ts":"2024-09-18 09:27:43.888131","caller":{"file":"main.go","line":1238},"level":3,"msg":"repo directory is empty","path":"/gitsync/repo"} {"logger":"","ts":"2024-09-18 09:27:43.888146","caller":{"file":"main.go","line":1168},"level":0,"msg":"repo directory was empty or failed checks","path":"/gitsync/repo"} {"logger":"","ts":"2024-09-18 09:27:43.888183","caller":{"file":"main.go","line":1178},"level":0,"msg":"initializing repo directory","path":"/gitsync/repo"} {"logger":"","ts":"2024-09-18 09:27:43.888215","caller":{"file":"main.go","line":1179},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git init -b git-sync"} {"logger":"","ts":"2024-09-18 09:27:43.892222","caller":{"file":"main.go","line":1179},"level":6,"msg":"command result","stdout":"Initialized empty Git repository in /gitsync/repo/.git/","stderr":"","time":"3.970708ms"} {"logger":"","ts":"2024-09-18 09:27:43.892256","caller":{"file":"main.go","line":1232},"level":3,"msg":"sanity-checking git repo","repo":"/gitsync/repo"} {"logger":"","ts":"2024-09-18 09:27:43.892329","caller":{"file":"main.go","line":1243},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git rev-parse --show-toplevel"} {"logger":"","ts":"2024-09-18 09:27:43.894061","caller":{"file":"main.go","line":1243},"level":6,"msg":"command result","stdout":"/gitsync/repo","stderr":"","time":"1.69177ms"} {"logger":"","ts":"2024-09-18 09:27:43.894093","caller":{"file":"main.go","line":1256},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git fsck --no-progress --connectivity-only"} {"logger":"","ts":"2024-09-18 09:27:43.902332","caller":{"file":"main.go","line":1256},"level":6,"msg":"command result","stdout":"","stderr":"notice: HEAD points to an unborn branch (git-sync)\nnotice: No default references","time":"8.197185ms"} {"logger":"","ts":"2024-09-18 09:27:43.902365","caller":{"file":"main.go","line":1189},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git remote get-url origin"} {"logger":"","ts":"2024-09-18 09:27:43.904172","caller":{"file":"main.go","line":1194},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git remote add origin git@git.someone.cloud:dds/someone-get-config.git"} {"logger":"","ts":"2024-09-18 09:27:43.906503","caller":{"file":"main.go","line":1194},"level":6,"msg":"command result","stdout":"","stderr":"","time":"2.269391ms"} {"logger":"","ts":"2024-09-18 09:27:43.906545","caller":{"file":"main.go","line":1644},"level":3,"msg":"current state","hash":"","worktree":""} {"logger":"","ts":"2024-09-18 09:27:43.906560","caller":{"file":"main.go","line":1750},"level":2,"msg":"fetching","ref":"main","repo":"git@git.someone.cloud:dds/someone-get-config.git"} {"logger":"","ts":"2024-09-18 09:27:43.906575","caller":{"file":"main.go","line":1768},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git fetch git@git.someone.cloud:dds/someone-get-config.git main --verbose --no-progress --prune --no-auto-gc --depth 1"} {"logger":"","ts":"2024-09-18 09:27:44.446828","caller":{"file":"main.go","line":1768},"level":6,"msg":"command result","stdout":"","stderr":"Warning: Permanently added 'git.someone.cloud' (ECDSA) to the list of known hosts.\r\nFrom git.someone.cloud:dds/someone-get-config\n branch main -> FETCH_HEAD","time":"540.199514ms"} {"logger":"","ts":"2024-09-18 09:27:44.446887","caller":{"file":"main.go","line":1656},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git rev-parse FETCH_HEAD^{}"} {"logger":"","ts":"2024-09-18 09:27:44.449064","caller":{"file":"main.go","line":1656},"level":6,"msg":"command result","stdout":"cc9dfdaf0cf12334df7d45e391543c8fc4541114","stderr":"","time":"2.114929ms"} {"logger":"","ts":"2024-09-18 09:27:44.449094","caller":{"file":"main.go","line":1682},"level":0,"msg":"update required","ref":"main","local":"","remote":"cc9dfdaf0cf12334df7d45e391543c8fc4541114","syncCount":0} {"logger":"","ts":"2024-09-18 09:27:44.449108","caller":{"file":"main.go","line":1688},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git reset --soft cc9dfdaf0cf12334df7d45e391543c8fc4541114"} {"logger":"","ts":"2024-09-18 09:27:44.452292","caller":{"file":"main.go","line":1688},"level":6,"msg":"command result","stdout":"","stderr":"","time":"3.133733ms"} {"logger":"","ts":"2024-09-18 09:27:44.452335","caller":{"file":"main.go","line":1419},"level":1,"msg":"adding worktree","path":"/gitsync/repo/.worktrees/cc9dfdaf0cf12334df7d45e391543c8fc4541114","hash":"cc9dfdaf0cf12334df7d45e391543c8fc4541114"} {"logger":"","ts":"2024-09-18 09:27:44.452358","caller":{"file":"main.go","line":1420},"level":5,"msg":"running command","cwd":"/gitsync/repo","cmd":"git worktree add --force --detach /gitsync/repo/.worktrees/cc9dfdaf0cf12334df7d45e391543c8fc4541114 cc9dfdaf0cf12334df7d45e391543c8fc4541114 --no-checkout"} {"logger":"","ts":"2024-09-18 09:27:44.458448","caller":{"file":"main.go","line":1420},"level":6,"msg":"command result","stdout":"","stderr":"Preparing worktree (detached HEAD cc9dfda)","time":"6.044323ms"} {"logger":"","ts":"2024-09-18 09:27:44.458670","caller":{"file":"main.go","line":1491},"level":1,"msg":"setting worktree HEAD","hash":"cc9dfdaf0cf12334df7d45e391543c8fc4541114"} {"logger":"","ts":"2024-09-18 09:27:44.458699","caller":{"file":"main.go","line":1492},"level":5,"msg":"running command","cwd":"/gitsync/repo/.worktrees/cc9dfdaf0cf12334df7d45e391543c8fc4541114","cmd":"git reset --hard cc9dfdaf0cf12334df7d45e391543c8fc4541114 --"} {"logger":"","ts":"2024-09-18 09:27:44.464951","caller":{"file":"main.go","line":1492},"level":6,"msg":"command result","stdout":"HEAD is now at cc9dfda Merge pull request #1 from dds/xyz-File","stderr":"","time":"6.20277ms"} {"logger":"","ts":"2024-09-18 09:27:44.464978","caller":{"file":"main.go","line":1499},"level":1,"msg":"updating submodules"} {"logger":"","ts":"2024-09-18 09:27:44.464991","caller":{"file":"main.go","line":1507},"level":5,"msg":"running command","cwd":"/gitsync/repo/.worktrees/cc9dfdaf0cf12334df7d45e391543c8fc4541114","cmd":"git submodule update --init --recursive --depth 1"} {"logger":"","ts":"2024-09-18 09:27:44.502660","caller":{"file":"main.go","line":1507},"level":6,"msg":"command result","stdout":"","stderr":"","time":"37.61797ms"} {"logger":"","ts":"2024-09-18 09:27:44.502711","caller":{"file":"main.go","line":1372},"level":2,"msg":"creating tmp symlink","dir":"/gitsync/repo","link":"tmp-link","target":".worktrees/cc9dfdaf0cf12334df7d45e391543c8fc4541114"} {"logger":"","ts":"2024-09-18 09:27:44.502777","caller":{"file":"main.go","line":1377},"level":2,"msg":"renaming symlink","root":"/gitsync/repo","oldName":"tmp-link","newName":"someone-get-config.git"} {"logger":"","ts":"2024-09-18 09:27:44.502837","caller":{"file":"main.go","line":1728},"level":0,"msg":"updated successfully","ref":"main","remote":"cc9dfdaf0cf12334df7d45e391543c8fc4541114","syncCount":1} {"logger":"","ts":"2024-09-18 09:27:44.502899","caller":{"file":"main.go","line":1213},"level":3,"msg":"cleaning up stale worktrees","currentHash":"cc9dfdaf0cf12334df7d45e391543c8fc4541114"} {"logger":"","ts":"2024-09-18 09:27:44.502986","caller":{"file":"main.go","line":1336},"level":4,"msg":"skipping path","path":"/gitsync/repo/.worktrees/cc9dfdaf0cf12334df7d45e391543c8fc4541114"} {"logger":"","ts":"2024-09-18 09:27:44.503012","caller":{"file":"main.go","line":923},"level":3,"msg":"next sync","waitTime":"1h0m0s","syncCount":1}
It should run fine as an initContainer - there's nothing special about them, really.
Your log indicates success.
I have tried all settings as provided in documentation, but no luck. Just getting same redundant error.
Host key verification failed.\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\" }"
I0916 00:13:01.273475 13 main.go:535] "level"=0 "msg"="waiting before retrying" "waitTime"=0
It seems while making ssh connection with git, path for key is not taken from ssh_key_file parameter.