Closed abhinavgautam-07 closed 4 weeks ago
Exechook takes a single argument - the command to execute. It does not take arguments. The command you gave it was "/bin/sh /git/current/exec_hook.sh" - there is no file in PATH named "/bin/sh /git/current/exec_hook.sh".
If the file is a shell script, why are you calling /bin/sh to run it?
i get the same error even i pass only this /git/current/exec_hook.sh
Run with -v 5
and post full logs?
INFO: detected pid 1, running init handler
{"logger":"","ts":"2024-06-08 11:01:56.585543","caller":{"file":"main.go","line":722},"level":0,"msg":"starting up","pid":12,"uid":65533,"gid":65533,"home":"/tmp","flags":["--add-user=false","--change-permissions=0","--cookie-file=false","--depth=10","--exechook-backoff=3s","--exechook-command=/git/current/exec_hook.sh","--exechook-timeout=30s","--git=git","--git-gc=always","--group-write=false","--help=false","--http-metrics=false","--http-pprof=false","--link=current","--man=false","--max-failures=0","--max-sync-failures=0","--one-time=false","--password=REDACTED","--period=1m0s","--ref=k8s-service-deployment","--repo=parse \"git@gitlab.urbanclap.com:urbanclap/platform-config-service.git\": first path segment in URL cannot contain colon","--root=/git","--ssh=true","--ssh-key-file=/etc/git-secret/ssh","--ssh-known-hosts=true","--ssh-known-hosts-file=/etc/git-secret/known_hosts","--stale-worktree-timeout=0s","--submodules=recursive","--sync-timeout=2m0s","--timeout=0","--v=-1","--verbose=5","--version=false","--wait=0","--webhook-backoff=3s","--webhook-method=POST","--webhook-success-status=200","--webhook-timeout=1s"]}
{"logger":"","ts":"2024-06-08 11:01:56.585888","caller":{"file":"main.go","line":781},"level":2,"msg":"created private gitconfig file","path":"/tmp/git-sync.gitconfig.3671301675"}
{"logger":"","ts":"2024-06-08 11:01:56.585969","caller":{"file":"main.go","line":2062},"level":5,"msg":"running command","cwd":"","cmd":"git config --global gc.autoDetach false"}
{"logger":"","ts":"2024-06-08 11:01:56.588026","caller":{"file":"main.go","line":2062},"level":5,"msg":"running command","cwd":"","cmd":"git config --global gc.pruneExpire now"}
{"logger":"","ts":"2024-06-08 11:01:56.589895","caller":{"file":"main.go","line":2062},"level":5,"msg":"running command","cwd":"","cmd":"git config --global credential.helper \"cache --timeout 3600\""}
{"logger":"","ts":"2024-06-08 11:01:56.591505","caller":{"file":"main.go","line":2062},"level":5,"msg":"running command","cwd":"","cmd":"git config --global safe.directory *"}
{"logger":"","ts":"2024-06-08 11:01:56.593085","caller":{"file":"main.go","line":1931},"level":1,"msg":"setting up git SSH credentials"}
{"logger":"","ts":"2024-06-08 11:01:56.593169","caller":{"file":"main.go","line":1736},"level":3,"msg":"syncing","repo":"git@gitlab.urbanclap.com:urbanclap/platform-config-service.git"}
{"logger":"","ts":"2024-06-08 11:01:56.593197","caller":{"file":"main.go","line":1240},"level":3,"msg":"repo directory exists","path":"/git"}
{"logger":"","ts":"2024-06-08 11:01:56.593221","caller":{"file":"main.go","line":1312},"level":3,"msg":"sanity-checking git repo","repo":"/git"}
{"logger":"","ts":"2024-06-08 11:01:56.593305","caller":{"file":"main.go","line":1323},"level":5,"msg":"running command","cwd":"/git","cmd":"git rev-parse --show-toplevel"}
{"logger":"","ts":"2024-06-08 11:01:56.594882","caller":{"file":"main.go","line":1336},"level":5,"msg":"running command","cwd":"/git","cmd":"git fsck --no-progress --connectivity-only"}
{"logger":"","ts":"2024-06-08 11:01:56.602162","caller":{"file":"main.go","line":1242},"level":4,"msg":"repo directory is valid","path":"/git"}
{"logger":"","ts":"2024-06-08 11:01:56.602208","caller":{"file":"main.go","line":1269},"level":5,"msg":"running command","cwd":"/git","cmd":"git remote get-url origin"}
{"logger":"","ts":"2024-06-08 11:01:56.603851","caller":{"file":"main.go","line":1654},"level":5,"msg":"running command","cwd":"/git","cmd":"git ls-remote -q git@gitlab.urbanclap.com:urbanclap/platform-config-service.git k8s-service-deployment k8s-service-deployment^{}"}
{"logger":"","ts":"2024-06-08 11:01:56.961948","caller":{"file":"main.go","line":1775},"level":3,"msg":"current hash","hash":""}
{"logger":"","ts":"2024-06-08 11:01:56.962001","caller":{"file":"main.go","line":1797},"level":0,"msg":"update required","ref":"k8s-service-deployment","local":"","remote":"8b100e354e3854dc36af1980835e9a260173b70a","syncCount":0}
{"logger":"","ts":"2024-06-08 11:01:56.962023","caller":{"file":"main.go","line":1867},"level":1,"msg":"fetching","ref":"8b100e354e3854dc36af1980835e9a260173b70a","repo":"git@gitlab.urbanclap.com:urbanclap/platform-config-service.git"}
{"logger":"","ts":"2024-06-08 11:01:56.962047","caller":{"file":"main.go","line":1885},"level":5,"msg":"running command","cwd":"/git","cmd":"git fetch git@gitlab.urbanclap.com:urbanclap/platform-config-service.git 8b100e354e3854dc36af1980835e9a260173b70a --verbose --no-progress --prune --no-auto-gc --depth 10"}
{"logger":"","ts":"2024-06-08 11:01:57.316879","caller":{"file":"main.go","line":1808},"level":5,"msg":"running command","cwd":"/git","cmd":"git reset --soft FETCH_HEAD"}
{"logger":"","ts":"2024-06-08 11:01:57.320817","caller":{"file":"main.go","line":1488},"level":1,"msg":"adding worktree","path":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","hash":"8b100e354e3854dc36af1980835e9a260173b70a"}
{"logger":"","ts":"2024-06-08 11:01:57.321362","caller":{"file":"main.go","line":1489},"level":5,"msg":"running command","cwd":"/git","cmd":"git worktree add --force --detach /git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a 8b100e354e3854dc36af1980835e9a260173b70a --no-checkout"}
{"logger":"","ts":"2024-06-08 11:01:57.327587","caller":{"file":"main.go","line":1560},"level":1,"msg":"setting worktree HEAD","hash":"8b100e354e3854dc36af1980835e9a260173b70a"}
{"logger":"","ts":"2024-06-08 11:01:57.327655","caller":{"file":"main.go","line":1561},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"git reset --hard 8b100e354e3854dc36af1980835e9a260173b70a --"}
{"logger":"","ts":"2024-06-08 11:01:57.345528","caller":{"file":"main.go","line":1568},"level":1,"msg":"updating submodules"}
{"logger":"","ts":"2024-06-08 11:01:57.345588","caller":{"file":"main.go","line":1576},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"git submodule update --init --recursive --depth 10"}
{"logger":"","ts":"2024-06-08 11:01:57.377016","caller":{"file":"main.go","line":1441},"level":2,"msg":"creating tmp symlink","dir":"/git","link":"tmp-link","target":".worktrees/8b100e354e3854dc36af1980835e9a260173b70a"}
{"logger":"","ts":"2024-06-08 11:01:57.377359","caller":{"file":"main.go","line":1446},"level":2,"msg":"renaming symlink","root":"/git","oldName":"tmp-link","newName":"current"}
{"logger":"","ts":"2024-06-08 11:01:57.377527","caller":{"file":"main.go","line":1848},"level":0,"msg":"updated successfully","ref":"k8s-service-deployment","remote":"8b100e354e3854dc36af1980835e9a260173b70a","syncCount":1}
{"logger":"","ts":"2024-06-08 11:01:57.377714","caller":{"file":"main.go","line":1293},"level":3,"msg":"cleaning up stale worktrees","currentHash":"8b100e354e3854dc36af1980835e9a260173b70a"}
{"logger":"","ts":"2024-06-08 11:01:57.378109","caller":{"file":"main.go","line":1405},"level":4,"msg":"skipping path","path":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a"}
{"logger":"","ts":"2024-06-08 11:01:57.378267","caller":{"file":"main.go","line":1681},"level":5,"msg":"running command","cwd":"/git","cmd":"git rev-parse k8s-service-deployment^{commit}"}
{"logger":"exechook","ts":"2024-06-08 11:01:57.377956","caller":{"file":"exechook.go","line":71},"level":0,"msg":"running exechook","hash":"8b100e354e3854dc36af1980835e9a260173b70a","command":"/git/current/exec_hook.sh","timeout":"30s"}
{"logger":"exechook","ts":"2024-06-08 11:01:57.378601","caller":{"file":"exechook.go","line":72},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"/git/current/exec_hook.sh "}
{"logger":"exechook","ts":"2024-06-08 11:01:57.379516","caller":{"file":"hook.go","line":143},"msg":"hook failed","error":"Run(/git/current/exec_hook.sh ): fork/exec /git/current/exec_hook.sh: no such file or directory: { stdout: \"\", stderr: \"\" }","hash":"8b100e354e3854dc36af1980835e9a260173b70a","retry":"3s"}
{"logger":"","ts":"2024-06-08 11:01:57.382155","caller":{"file":"main.go","line":1042},"level":3,"msg":"next sync","waitTime":"1m0s"}
{"logger":"exechook","ts":"2024-06-08 11:02:00.381080","caller":{"file":"exechook.go","line":71},"level":0,"msg":"running exechook","hash":"8b100e354e3854dc36af1980835e9a260173b70a","command":"/git/current/exec_hook.sh","timeout":"30s"}
{"logger":"exechook","ts":"2024-06-08 11:02:00.381143","caller":{"file":"exechook.go","line":72},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"/git/current/exec_hook.sh "}
{"logger":"exechook","ts":"2024-06-08 11:02:00.381558","caller":{"file":"hook.go","line":143},"msg":"hook failed","error":"Run(/git/current/exec_hook.sh ): fork/exec /git/current/exec_hook.sh: no such file or directory: { stdout: \"\", stderr: \"\" }","hash":"8b100e354e3854dc36af1980835e9a260173b70a","retry":"3s"}
{"logger":"exechook","ts":"2024-06-08 11:02:03.382148","caller":{"file":"exechook.go","line":71},"level":0,"msg":"running exechook","hash":"8b100e354e3854dc36af1980835e9a260173b70a","command":"/git/current/exec_hook.sh","timeout":"30s"}
{"logger":"exechook","ts":"2024-06-08 11:02:03.382221","caller":{"file":"exechook.go","line":72},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"/git/current/exec_hook.sh "}
{"logger":"exechook","ts":"2024-06-08 11:02:03.382601","caller":{"file":"hook.go","line":143},"msg":"hook failed","error":"Run(/git/current/exec_hook.sh ): fork/exec /git/current/exec_hook.sh: no such file or directory: { stdout: \"\", stderr: \"\" }","hash":"8b100e354e3854dc36af1980835e9a260173b70a","retry":"3s"}
{"logger":"exechook","ts":"2024-06-08 11:02:06.382757","caller":{"file":"exechook.go","line":71},"level":0,"msg":"running exechook","hash":"8b100e354e3854dc36af1980835e9a260173b70a","command":"/git/current/exec_hook.sh","timeout":"30s"}
{"logger":"exechook","ts":"2024-06-08 11:02:06.382824","caller":{"file":"exechook.go","line":72},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"/git/current/exec_hook.sh "}
{"logger":"exechook","ts":"2024-06-08 11:02:06.383290","caller":{"file":"hook.go","line":143},"msg":"hook failed","error":"Run(/git/current/exec_hook.sh ): fork/exec /git/current/exec_hook.sh: no such file or directory: { stdout: \"\", stderr: \"\" }","hash":"8b100e354e3854dc36af1980835e9a260173b70a","retry":"3s"}
{"logger":"exechook","ts":"2024-06-08 11:02:09.385101","caller":{"file":"exechook.go","line":71},"level":0,"msg":"running exechook","hash":"8b100e354e3854dc36af1980835e9a260173b70a","command":"/git/current/exec_hook.sh","timeout":"30s"}
{"logger":"exechook","ts":"2024-06-08 11:02:09.385156","caller":{"file":"exechook.go","line":72},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"/git/current/exec_hook.sh "}
{"logger":"exechook","ts":"2024-06-08 11:02:09.385620","caller":{"file":"hook.go","line":143},"msg":"hook failed","error":"Run(/git/current/exec_hook.sh ): fork/exec /git/current/exec_hook.sh: no such file or directory: { stdout: \"\", stderr: \"\" }","hash":"8b100e354e3854dc36af1980835e9a260173b70a","retry":"3s"}
{"logger":"exechook","ts":"2024-06-08 11:02:12.386344","caller":{"file":"exechook.go","line":71},"level":0,"msg":"running exechook","hash":"8b100e354e3854dc36af1980835e9a260173b70a","command":"/git/current/exec_hook.sh","timeout":"30s"}
{"logger":"exechook","ts":"2024-06-08 11:02:12.386409","caller":{"file":"exechook.go","line":72},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"/git/current/exec_hook.sh "}
{"logger":"exechook","ts":"2024-06-08 11:02:12.387025","caller":{"file":"hook.go","line":143},"msg":"hook failed","error":"Run(/git/current/exec_hook.sh ): fork/exec /git/current/exec_hook.sh: no such file or directory: { stdout: \"\", stderr: \"\" }","hash":"8b100e354e3854dc36af1980835e9a260173b70a","retry":"3s"}
{"logger":"exechook","ts":"2024-06-08 11:02:15.389075","caller":{"file":"exechook.go","line":71},"level":0,"msg":"running exechook","hash":"8b100e354e3854dc36af1980835e9a260173b70a","command":"/git/current/exec_hook.sh","timeout":"30s"}
{"logger":"exechook","ts":"2024-06-08 11:02:15.389143","caller":{"file":"exechook.go","line":72},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"/git/current/exec_hook.sh "}
{"logger":"exechook","ts":"2024-06-08 11:02:15.389522","caller":{"file":"hook.go","line":143},"msg":"hook failed","error":"Run(/git/current/exec_hook.sh ): fork/exec /git/current/exec_hook.sh: no such file or directory: { stdout: \"\", stderr: \"\" }","hash":"8b100e354e3854dc36af1980835e9a260173b70a","retry":"3s"}
{"logger":"exechook","ts":"2024-06-08 11:02:18.390218","caller":{"file":"exechook.go","line":71},"level":0,"msg":"running exechook","hash":"8b100e354e3854dc36af1980835e9a260173b70a","command":"/git/current/exec_hook.sh","timeout":"30s"}
{"logger":"exechook","ts":"2024-06-08 11:02:18.390282","caller":{"file":"exechook.go","line":72},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"/git/current/exec_hook.sh "}
{"logger":"exechook","ts":"2024-06-08 11:02:18.390672","caller":{"file":"hook.go","line":143},"msg":"hook failed","error":"Run(/git/current/exec_hook.sh ): fork/exec /git/current/exec_hook.sh: no such file or directory: { stdout: \"\", stderr: \"\" }","hash":"8b100e354e3854dc36af1980835e9a260173b70a","retry":"3s"}
{"logger":"exechook","ts":"2024-06-08 11:02:21.390941","caller":{"file":"exechook.go","line":71},"level":0,"msg":"running exechook","hash":"8b100e354e3854dc36af1980835e9a260173b70a","command":"/git/current/exec_hook.sh","timeout":"30s"}
{"logger":"exechook","ts":"2024-06-08 11:02:21.391007","caller":{"file":"exechook.go","line":72},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"/git/current/exec_hook.sh "}
{"logger":"exechook","ts":"2024-06-08 11:02:21.391413","caller":{"file":"hook.go","line":143},"msg":"hook failed","error":"Run(/git/current/exec_hook.sh ): fork/exec /git/current/exec_hook.sh: no such file or directory: { stdout: \"\", stderr: \"\" }","hash":"8b100e354e3854dc36af1980835e9a260173b70a","retry":"3s"}
{"logger":"exechook","ts":"2024-06-08 11:02:24.393076","caller":{"file":"exechook.go","line":71},"level":0,"msg":"running exechook","hash":"8b100e354e3854dc36af1980835e9a260173b70a","command":"/git/current/exec_hook.sh","timeout":"30s"}
{"logger":"exechook","ts":"2024-06-08 11:02:24.393130","caller":{"file":"exechook.go","line":72},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"/git/current/exec_hook.sh "}
{"logger":"exechook","ts":"2024-06-08 11:02:24.393607","caller":{"file":"hook.go","line":143},"msg":"hook failed","error":"Run(/git/current/exec_hook.sh ): fork/exec /git/current/exec_hook.sh: no such file or directory: { stdout: \"\", stderr: \"\" }","hash":"8b100e354e3854dc36af1980835e9a260173b70a","retry":"3s"}
{"logger":"exechook","ts":"2024-06-08 11:02:27.394132","caller":{"file":"exechook.go","line":71},"level":0,"msg":"running exechook","hash":"8b100e354e3854dc36af1980835e9a260173b70a","command":"/git/current/exec_hook.sh","timeout":"30s"}
{"logger":"exechook","ts":"2024-06-08 11:02:27.394192","caller":{"file":"exechook.go","line":72},"level":5,"msg":"running command","cwd":"/git/.worktrees/8b100e354e3854dc36af1980835e9a260173b70a","cmd":"/git/current/exec_hook.sh "}
{"logger":"exechook","ts":"2024-06-08 11:02:27.394604","caller":{"file":"hook.go","line":143},"msg":"hook failed","error":"Run(/git/current/exec_hook.sh ): fork/exec /git/current/exec_hook.sh: no such file or directory: { stdout: \"\", stderr: \"\" }","hash":"8b100e354e3854dc36af1980835e9a260173b70a","retry":"3s"}
Are you sure that there is an executable file named exec_hook.sh in the root of that git repo? From what I can see it looks like it is trying to execute that, but it is getting a file not found error. If you exec into that container while it's running, can you ls that file?
when i did exec into the git-sync container in the pod and ran the command. It worked perfectly. I would like to add one more thing here. When i ran
/git/current/exec_hook.sh
. I got this /bin/sh: 1: /git/current/exec_hook.sh: not found
but when i ran /bin/sh /git/current/exec_hook.sh
. It worked
My guess: the #!
at the top of that file references a specific shell (e.g. bash) which is not found in the image.
th-desktop $ docker run -ti --entrypoint sh registry.k8s.io/git-sync/git-sync:v4.0.0
$ bash
sh: 1: bash: not found
$ cat > /tmp/file.sh
#!/bin/bash
echo foo
^D
$ chmod 755 /tmp/file.sh
$ /tmp/file.sh
sh: 16: /tmp/file.sh: not found
Worth noting, the newest git-sync releases (e.g. 4.2.3) DO have bash:
th-desktop: $ docker run -ti --entrypoint sh registry.k8s.io/git-sync/git-sync:v4.2.3
sh-5.2$ cat > /tmp/file.sh
#!/bin/bash
echo foo
^D
sh-5.2$ chmod 755 /tmp/file.sh
sh-5.2$ /tmp/file.sh
foo
Thanks a lot...I upgraded the image to 4.2.3 and it is working.
This my manifest file.
What I want to achieve
My main container is
main-app
. When I start the container. It has some source code (along with some config files which are not present on git) at /usr/src/app. What i want to with git-sync is to update the code at /usr/src/app with the latest code. Also i want to run some commands with exechook-command. but it is giving errorBut when I exec into the git-sync container and run the command
/bin/sh /git/current/exec_hook.sh
. It is working properly.Can I get some suggestions around. What better config I can have and how to solve this exechook error.