From 53f3fa17a081acb0d50571799324240c1429fe71 Mon Sep 17 00:00:00 2001 From: Nan Yu Date: Thu, 21 Jan 2021 12:54:00 -0800 Subject: [PATCH] Export the error details to an error file The current git-sync process outputs the error information to standard out, which is inaccessible from outside the container. Users have to dump the logs using kubectl logs in order to check the error details in the git-sync process. This commit exports the error details to a file, which provides users the capability to check the errors directly from other sidecar containers. proposal: https://github.com/kubernetes/git-sync/issues/326 --- README.md | 1 + cmd/git-sync/main.go | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b346b42..806cab4 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ docker run -d \ | GIT_SYNC_SUBMODULES | `--submodules` | git submodule behavior: one of 'recursive', 'shallow', or 'off' | recursive | | GIT_SYNC_ROOT | `--root` | the root directory for git-sync operations, under which --link will be created | "" | | GIT_SYNC_LINK | `--link` | the name of a symlink, under --root, which points to a directory in which --repo is checked out (defaults to the leaf dir of --repo) | "" | +| GIT_SYNC_ERROR_FILE | `--error-file` | the name of a file, under --root, into which errors will be written (defaults to "", disabling error reporting) | "" | | GIT_SYNC_PERIOD | `--period` | how long to wait between syncs, must be >= 10ms | "10s" | | GIT_SYNC_SYNC_TIMEOUT | `--sync-timeout` | the total time allowed for one complete sync, must be >= 10ms | "120s" | | GIT_SYNC_ONE_TIME | `--one-time` | exit after the first sync | false | diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index a8c7db5..26d35b2 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -1517,6 +1517,12 @@ OPTIONS Use a git cookiefile (/etc/git-secret/cookie_file) for authentication. + --error-file, $GIT_SYNC_ERROR_FILE + The name of a file (under --root) into which errors will be + written. This must be a filename, not a path, and may not start + with a period. (default: "", which means error reporting will be + disabled) + --depth , $GIT_SYNC_DEPTH Create a shallow clone with history truncated to the specified number of commits. @@ -1576,7 +1582,7 @@ OPTIONS --period , $GIT_SYNC_PERIOD How long to wait between sync attempts. This must be at least - 10ms. This flag obsoletes --wait, but if --wait is specifed, it + 10ms. This flag obsoletes --wait, but if --wait is specified, it will take precedence. (default: 10s) --repo , $GIT_SYNC_REPO