Commit Graph

23 Commits

Author SHA1 Message Date
Tommy Hyeonwoo Kim 664fb74867
fix typo 2023-02-21 19:47:26 +09:00
Tim Hockin f5057b7fa8
Log commands we run with original caller 2023-02-10 21:18:28 -08:00
Eng Zer Jun 91113aa314
refactor: move from io/ioutil to io and os packages
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.

[1]: https://golang.org/doc/go1.16#ioutil
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-11-04 20:34:57 +08:00
Tim Hockin f8a532d9df Pass the whole environment to exechooks 2022-05-16 18:14:09 -07:00
Tim Hockin 3ca8099d2d Use logger.WithName() for web/exechook
This makes logs easier to comprehend, since hooks are async.
2022-03-17 12:10:39 -07:00
Tim Hockin 76854fc806 Set $GITSYNC_HASH in exechook 2022-02-06 16:49:34 -08:00
Tim Hockin b752a5eedc Fix tests to set missing arg 2022-02-06 16:29:57 -08:00
Kubernetes Prow Robot 10fd8e662b
Merge pull request #476 from thockin/v4-double-register-hook-metric
Don't double-register the hook metric (v4)
2022-01-23 01:17:56 -08:00
Tim Hockin 2a611a72c0 Don't double-register the hook metric 2022-01-22 14:24:47 -08:00
Tim Hockin c143bfd31a Small cleanup on one-time x hooks 2022-01-19 11:48:50 -08:00
ChrisERo ad6a34abb5 refactor: corrected variable names and logs inside HookRunner.WaitForCompletion 2022-01-15 15:23:06 -05:00
ChrisERo 8827bf7489 refactor: imporved efficiency and code style
* changed sendCompletedOnceMessageIfApplicable so that it kills thread
  after executing
* moved logic for waiting on HookRunner into function defined in
  HookRunner itself
2022-01-14 13:41:59 -05:00
ChrisERo 0df6e005d3 refactor: fixed in-line documentation and added line-wraps where needed 2022-01-10 20:06:23 -05:00
ChrisERo 3b5ed549eb fix: addressed several concers raised by thockin
- Renamed [x]HookChannel to [x]hookChannel for consistency
- Made hookChannels buffered chanels of size 1
- Added clarifying documentation and renamed functions expalining how I was
    - ensuring that hooks execute at least once, assuming that main thread does not crash
    - make sure chanels are not written to more than once
2022-01-10 20:06:06 -05:00
ChrisERo 9e6348c3b5 fix: resolve issue number 463
Resolved original issue by introducing a boolean chanel by which exechook runner can communicate with main thread.
Then introduced and used webhook executed-at-least-once chanel and added documentation explaining sections of of code
only executed when git-sync pulls for first time.
2022-01-10 20:05:53 -05:00
Tim Hockin 4603f559f3 Replace glogr with funcr
No difference in flags.  Log output will now be JSON.

example:

{"logger":"","ts":"2021-11-24 11:19:46.340238","caller":{"file":"main.go","line":1031},"level":0,"msg":"cloning repo","origin":"https://github.com/thockin/git-sync","path":"/tmp/gt"}
2021-11-24 11:18:07 -08:00
Tim Hockin 0ea10cbbc2 Add one call depth to compensate for log pkg 2021-08-16 23:45:10 -07:00
Tim Hockin 0075df238c Make exechooks work like webhooks.
This deprecates the `--sync-hook-command` flag in favor of
`--exechook-command`, `--exechook-timeout`, and `--exechook-backoff`.
2021-08-16 23:21:20 -07:00
Tim Hockin 0222a95f29 Make sure all code files have headers 2021-05-27 08:46:00 -07:00
Tim Hockin 45b28530a7 Fix exit non-zero exit codes when running as pid1
(v4 branch)

Prior to this we would swallow the exit code and always exit(0).
2021-03-15 09:28:26 -07:00
Tim Hockin 95a1690e6f Fix 2 bugs in pid1
1) Was calling Wait() on the child process, but also calling Wait4,
which would race, causing an occasional error or panic.

2) In testing (1), I observed occasional hangs.  Tracing it down to a
SIGWINCH, which masked a SIGCHLD, causing it to hang.  Both seem fixed.

Added a manual test script.
2020-03-20 13:44:27 -07:00
Tim Hockin 2a42fba009 Handle running as pid 1
This detects when it is running as pid 1, and becomes an init process.
Specifically this means handling SIGCHLD and reaping processes
(otherwise they become zombies) and forwarding signals to "real"
process.

We fork and re-exec ourselves so that we only get *this* SIGCHLD for
orphaned processes (re-parented to 1) and not the real events from
running things like git or ssh.
2019-10-27 09:45:27 -07:00
Tim Hockin 70feeb5ae1 Use the go-build-template
Faster builds and versions from tags.  Also use alpine as a base image.  We
need alpine for other architectures...

Also change the --wait flag to take a float for sub-second waits.
2016-10-30 17:09:06 -07:00