Skip to content

Commit 26c17da

Browse files
sagor999roboquat
authored andcommitted
call prestophook.sh from ring1 directly
1 parent 59071b4 commit 26c17da

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

components/workspacekit/cmd/rings.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,22 @@ var ring1Cmd = &cobra.Command{
561561
}
562562
}()
563563

564+
// run prestophook when ring1 exits. This is more reliable way of running this script then
565+
// using PreStop Lifecycle Handler of the pod (it would not execute for prebuilds for example)
566+
prestophookFunc := func() {
567+
if _, err := os.Stat("/.supervisor/prestophook.sh"); os.IsNotExist(err) {
568+
return
569+
}
570+
cmd := exec.Command("/.supervisor/prestophook.sh")
571+
cmd.Stdout = os.Stdout
572+
cmd.Stderr = os.Stderr
573+
err := cmd.Run()
574+
if err != nil {
575+
log.WithError(err).Error("error when running prestophook.sh")
576+
}
577+
}
578+
defer prestophookFunc()
579+
564580
err = cmd.Wait()
565581
if err != nil {
566582
if eerr, ok := err.(*exec.ExitError); ok {

components/ws-manager/pkg/manager/create.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -572,15 +572,6 @@ func (m *Manager) createDefiniteWorkspacePod(startContext *startWorkspaceContext
572572
// not needed, since it is using dedicated disk
573573
pod.Spec.Containers[0].VolumeMounts[0].MountPropagation = nil
574574

575-
// add prestop hook to capture git status
576-
pod.Spec.Containers[0].Lifecycle = &corev1.Lifecycle{
577-
PreStop: &corev1.LifecycleHandler{
578-
Exec: &corev1.ExecAction{
579-
Command: []string{"/bin/sh", "-c", "/.supervisor/workspacekit lift /.supervisor/prestophook.sh"},
580-
},
581-
},
582-
}
583-
584575
// pavel: 133332 is the Gitpod UID (33333) shifted by 99999. The shift happens inside the workspace container due to the user namespace use.
585576
// We set this magical ID to make sure that gitpod user inside the workspace can write into /workspace folder mounted by PVC
586577
gitpodGUID := int64(133332)

0 commit comments

Comments
 (0)