Skip to content

call prestophook.sh from ring1 directly #10776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions components/workspacekit/cmd/rings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 0 additions & 9 deletions components/ws-manager/pkg/manager/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down