Skip to content
Permalink
Browse files
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 <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Feb 17, 2022
1 parent e55accd commit a78df7c27d71b3d8be0efd0412fe02a19b0a3068
Showing with 16 additions and 2 deletions.
  1. +16 −2 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)

0 comments on commit a78df7c

Please sign in to comment.