Skip to content

Commit eb05266

Browse files
fix(host-cleanup): fix service host cleanup image cannot be replaced
Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
1 parent 23d553d commit eb05266

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

pkg/container_backend/buildah_backend.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,10 @@ func (backend *BuildahBackend) String() string {
847847
}
848848

849849
func (backend *BuildahBackend) RemoveHostDirs(ctx context.Context, mountDir string, dirs []string) error {
850+
serviceImage := getHostCleanupServiceImage()
850851
var container *containerDesc
851-
if c, err := backend.createContainers(ctx, []string{"alpine"}, CommonOpts{}); err != nil {
852-
return fmt.Errorf("unable to create container based on alpine: %w", err)
852+
if c, err := backend.createContainers(ctx, []string{serviceImage}, CommonOpts{}); err != nil {
853+
return fmt.Errorf("unable to create container based on %q: %w", serviceImage, err)
853854
} else {
854855
container = c[0]
855856
}

pkg/container_backend/docker_server_backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func (backend *DockerServerBackend) RemoveHostDirs(ctx context.Context, mountDir
320320
args := []string{
321321
"--rm",
322322
"--volume", fmt.Sprintf("%s:%s", mountDir, util.ToLinuxContainerPath(mountDir)),
323-
"alpine",
323+
getHostCleanupServiceImage(),
324324
"rm", "-rf",
325325
}
326326

pkg/container_backend/utils.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
const (
1717
SSHHostAuthSockPath = "/run/host-services/ssh-auth.sock"
1818
SSHContainerAuthSockPath = "/.werf/tmp/ssh-auth-sock"
19+
hostCleanupServiceImage = "alpine:3.14"
1920
)
2021

2122
var (
@@ -78,3 +79,12 @@ func setSSHMountPoint(sshAuthSock string) (string, map[string]string) {
7879
}
7980
return vol, env
8081
}
82+
83+
func getHostCleanupServiceImage() string {
84+
image := hostCleanupServiceImage
85+
if v := os.Getenv("WERF_HOST_CLEANUP_SERVICE_IMAGE"); v != "" {
86+
image = v
87+
}
88+
89+
return image
90+
}

0 commit comments

Comments
 (0)