Skip to content

Commit 0d94e79

Browse files
authored
fix: handle interruptions during git clone and auto host cleanup gracefully (#6887)
Signed-off-by: Alexandr Zaytsev <alexandr.zaytsev@flant.com>
1 parent 791cb41 commit 0d94e79

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pkg/git_repo/remote.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (repo *Remote) Clone(ctx context.Context) (bool, error) {
186186
// Ensure cleanup on failure
187187
defer os.RemoveAll(tmpPath)
188188

189-
_, err = git.PlainClone(tmpPath, true, &git.CloneOptions{
189+
_, err = git.PlainCloneContext(ctx, tmpPath, true, &git.CloneOptions{
190190
URL: repo.Url,
191191
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
192192
})

pkg/host_cleaning/host_cleanup.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77

8+
"github.com/werf/common-go/pkg/graceful"
89
"github.com/werf/logboek"
910
"github.com/werf/werf/v2/pkg/container_backend"
1011
"github.com/werf/werf/v2/pkg/git_repo/gitdata"
@@ -145,6 +146,9 @@ func RunHostCleanup(ctx context.Context, backend container_backend.ContainerBack
145146
}
146147

147148
func shouldRunAutoHostCleanup(ctx context.Context, backend container_backend.ContainerBackend, options AutoHostCleanupOptions) (bool, error) {
149+
if graceful.IsTerminating(ctx) {
150+
return false, nil
151+
}
148152
// host cleanup is not supported for certain project
149153
if options.ProjectName != nil && *options.ProjectName != "" {
150154
return false, nil

0 commit comments

Comments
 (0)