diff --git a/components/workspacekit/cmd/rings.go b/components/workspacekit/cmd/rings.go index dc937260fdb466..f424be4ee74503 100644 --- a/components/workspacekit/cmd/rings.go +++ b/components/workspacekit/cmd/rings.go @@ -561,6 +561,22 @@ var ring1Cmd = &cobra.Command{ } }() + // run prestophook when ring1 exits. This is more reliable way of running this script then + // using PreStop Lifecycle Handler of the pod (it would not execute for prebuilds for example) + prestophookFunc := func() { + if _, err := os.Stat("/.supervisor/prestophook.sh"); os.IsNotExist(err) { + return + } + cmd := exec.Command("/.supervisor/prestophook.sh") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + if err != nil { + log.WithError(err).Error("error when running prestophook.sh") + } + } + defer prestophookFunc() + err = cmd.Wait() if err != nil { if eerr, ok := err.(*exec.ExitError); ok { diff --git a/components/ws-manager/pkg/manager/create.go b/components/ws-manager/pkg/manager/create.go index 8ec972f23b5c49..51c0250c77c0b3 100644 --- a/components/ws-manager/pkg/manager/create.go +++ b/components/ws-manager/pkg/manager/create.go @@ -572,15 +572,6 @@ func (m *Manager) createDefiniteWorkspacePod(startContext *startWorkspaceContext // not needed, since it is using dedicated disk pod.Spec.Containers[0].VolumeMounts[0].MountPropagation = nil - // add prestop hook to capture git status - pod.Spec.Containers[0].Lifecycle = &corev1.Lifecycle{ - PreStop: &corev1.LifecycleHandler{ - Exec: &corev1.ExecAction{ - Command: []string{"/bin/sh", "-c", "/.supervisor/workspacekit lift /.supervisor/prestophook.sh"}, - }, - }, - } - // pavel: 133332 is the Gitpod UID (33333) shifted by 99999. The shift happens inside the workspace container due to the user namespace use. // We set this magical ID to make sure that gitpod user inside the workspace can write into /workspace folder mounted by PVC gitpodGUID := int64(133332)