From a78df7c27d71b3d8be0efd0412fe02a19b0a3068 Mon Sep 17 00:00:00 2001 From: Timofey Kirillov Date: Thu, 17 Feb 2022 20:02:51 +0300 Subject: [PATCH] fix: host-cleanup procedure not running in gitlab-ci Due to enabled werf's "process exterminator", all werf processes started by the GitLab CI/CD system will watch for parent processes pids, and interrupt itself when one of the parents is gone. But this mechanics does not allow background `werf host cleanup` command to finish its job, so it has been disabled for host cleanup background cmd. Signed-off-by: Timofey Kirillov --- pkg/host_cleaning/host_cleanup.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/host_cleaning/host_cleanup.go b/pkg/host_cleaning/host_cleanup.go index 1f3cc79406..cd31eaabcd 100644 --- a/pkg/host_cleaning/host_cleanup.go +++ b/pkg/host_cleaning/host_cleanup.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "os/exec" + "strings" "github.com/werf/logboek" "github.com/werf/werf/pkg/git_repo/gitdata" @@ -57,6 +58,8 @@ func RunAutoHostCleanup(ctx context.Context, options AutoHostCleanupOptions) err } } + logboek.Context(ctx).Debug().LogF("RunAutoHostCleanup forking ...\n") + var args []string args = append(args, @@ -82,8 +85,19 @@ func RunAutoHostCleanup(ctx context.Context, options AutoHostCleanupOptions) err } cmd := exec.Command(os.Args[0], args...) - cmd.Env = append(cmd.Env, os.Environ()...) - cmd.Env = append(cmd.Env, "_WERF_BACKGROUND_MODE_ENABLED=1") + + var env []string + for _, spec := range os.Environ() { + k := strings.SplitN(spec, "=", 2)[0] + if k == "WERF_ENABLE_PROCESS_EXTERMINATOR" { + continue + } + + env = append(env, spec) + } + env = append(env, "_WERF_BACKGROUND_MODE_ENABLED=1") + + cmd.Env = env if err := cmd.Start(); err != nil { logboek.Context(ctx).Warn().LogF("WARNING: unable to start background auto host cleanup process: %s\n", err)