Re: [PATCH 3/3] scalar: only warn when background maintenance fails
- From
Victoria Dye <vdye@github.com>
- Date
- Jan 27, 2023, 22:06 UTC
- Message-ID
- <65b1735b-7ea6-5f7c-e1d9-6c986c7beb1d@github.com>
- In-Reply-To
- <d75780e0567b5f765816ab7522afe550ebaa3521.1674849963.git.gitgitgadget@gmail.com>
Derrick Stolee via GitGitGadget wrote:
Show 36 quoted lines
> From: Derrick Stolee <derrickstolee@github.com>
>
> A user reported issues with 'scalar clone' and 'scalar register' when
> working in an environment that had locked down the ability to run
> 'crontab' or 'systemctl' in that those commands registered as _failures_
> instead of opportunistically reporting a success with just a warning
> about background maintenance.
>
> As a workaround, they can use GIT_TEST_MAINT_SCHEDULER to fake a
> successful background maintenance, but this is not a viable strategy for
> long-term.
>
> Update 'scalar register' and 'scalar clone' to no longer fail by
> modifying register_dir() to only warn when toggle_maintenance(1) fails.
>
> Since background maintenance is a "nice to have" and not a requirement
> for a working repository, it is best to move this from hard error to
> gentle warning.
>
> Signed-off-by: Derrick Stolee <derrickstolee@github.com>
> ---
> scalar.c | 2 +-
> t/t9210-scalar.sh | 4 ++--
> t/t9211-scalar-clone.sh | 4 ++--
> 3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/scalar.c b/scalar.c
> index f25d5f1d0ef..ca19b95ce46 100644
> --- a/scalar.c
> +++ b/scalar.c
> @@ -262,7 +262,7 @@ static int register_dir(void)
> return error(_("could not set recommended config"));
>
> if (toggle_maintenance(1))
> - return error(_("could not turn on maintenance"));
> + warning(_("could not turn on maintenance"));Should we do the same thing for 'unregister_dir()'? Unlike 'register_dir()', it doesn't break immediately (and finishes removing the enlistment), but it still returns a nonzero error code from 'scalar unregister'.
Show 35 quoted lines
>
> if (have_fsmonitor_support() && start_fsmonitor_daemon()) {
> return error(_("could not start the FSMonitor daemon"));
> diff --git a/t/t9210-scalar.sh b/t/t9210-scalar.sh
> index 13a4f6dbcf4..4432a30d10b 100755
> --- a/t/t9210-scalar.sh
> +++ b/t/t9210-scalar.sh
> @@ -104,10 +104,10 @@ test_expect_success FSMONITOR_DAEMON 'scalar register starts fsmon daemon' '
> test_cmp_config -C test/src true core.fsmonitor
> '
>
> -test_expect_success 'scalar register fails when background maintenance fails' '
> +test_expect_success 'scalar register warns when background maintenance fails' '
> git init register-repo &&
> GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
> - test_must_fail scalar register register-repo 2>err &&
> + scalar register register-repo 2>err &&
> grep "could not turn on maintenance" err
> '
>
> diff --git a/t/t9211-scalar-clone.sh b/t/t9211-scalar-clone.sh
> index a6156da29ac..872ad1c9c2b 100755
> --- a/t/t9211-scalar-clone.sh
> +++ b/t/t9211-scalar-clone.sh
> @@ -174,9 +174,9 @@ test_expect_success 'progress without tty' '
> cleanup_clone $enlistment
> '
>
> -test_expect_success 'scalar clone fails when background maintenance fails' '
> +test_expect_success 'scalar clone warns when background maintenance fails' '
> GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
> - test_must_fail scalar clone "file://$(pwd)/to-clone" maint-fail 2>err &&
> + scalar clone "file://$(pwd)/to-clone" maint-fail 2>err &&
> grep "could not turn on maintenance" err
> 'Similarly, it might be nice to show how 'scalar unregister' behaves when maintenance fails in the tests.