Skip to content
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

[WIP] Resolve the PreStartHook failure caused by the slow startup of fuse container #4456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion pkg/application/inject/fuse/poststart/check_fuse_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ func (a *ScriptGeneratorForApp) getConfigmapName() string {
func (a *ScriptGeneratorForApp) GetPostStartCommand(mountPaths string, mountTypes string) (handler *corev1.LifecycleHandler) {
// Return non-null post start command only when PostStartInjeciton is enabled
// https://github.com/kubernetes/kubernetes/issues/25766
cmd := []string{"bash", "-c", fmt.Sprintf("time %s %s %s >> /proc/1/fd/1", appScriptPath, mountPaths, mountTypes)}
// https://github.com/fluid-cloudnative/fluid/issues/4455
cmd := []string{"bash", "-c", fmt.Sprintf("while [ ! -e /proc/1/fd/1 ]; do sleep 1; done; bash -c 'time %s %s %s >> /proc/1/fd/1'", appScriptPath, mountPaths, mountTypes)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding a timeout to avoid potential infinite loops in case of unexpected conditions.

handler = &corev1.LifecycleHandler{
Exec: &corev1.ExecAction{Command: cmd},
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/application/inject/fuse/poststart/check_fuse_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func NewDefaultPostStartScriptGenerator() *defaultPostStartScriptGenerator {

func (g *defaultPostStartScriptGenerator) GetPostStartCommand(mountPath, mountType, subPath string) (handler *corev1.LifecycleHandler) {
// https://github.com/kubernetes/kubernetes/issues/25766
cmd := []string{"bash", "-c", fmt.Sprintf("time %s %s %s %s >> /proc/1/fd/1", g.scriptMountPath, mountPath, mountType, subPath)}
// https://github.com/fluid-cloudnative/fluid/issues/4455
cmd := []string{"bash", "-c", fmt.Sprintf("while [ ! -e /proc/1/fd/1 ]; do sleep 1; done; bash -c 'time %s %s %s %s >> /proc/1/fd/1'", g.scriptMountPath, mountPath, mountType, subPath)}

return &corev1.LifecycleHandler{
Exec: &corev1.ExecAction{Command: cmd},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func NewUnprivilegedPostStartScriptGenerator() *unprivilegedPostStartScriptGener
}

func (g *unprivilegedPostStartScriptGenerator) GetPostStartCommand() (handler *corev1.LifecycleHandler) {
cmd := []string{"bash", "-c", fmt.Sprintf("time %s >> /proc/1/fd/1", g.scriptMountPath)}
// https://github.com/fluid-cloudnative/fluid/issues/4455
cmd := []string{"bash", "-c", fmt.Sprintf("while [ ! -e /proc/1/fd/1 ]; do sleep 1; done; bash -c 'time %s >> /proc/1/fd/1'", g.scriptMountPath)}

return &corev1.LifecycleHandler{
Exec: &corev1.ExecAction{Command: cmd},
Expand Down
Loading