Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 a78df7c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/host_cleaning/host_cleanup.go
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"os/exec"
"strings"

"github.com/werf/logboek"
"github.com/werf/werf/pkg/git_repo/gitdata"
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit a78df7c

Please sign in to comment.