Skip to content

Invoke sh from $PATH instead of hard-coded location for postStart and preStop events #1339

Open
@AObuchow

Description

@AObuchow

Description

Currently, postStart and preStop events assume the sh binary is located in /bin/sh/. However, this is not always the case, as discussed here, where sh is actually located in /usr/bin/sh.

I'm opening this issue to investigate whether it's possible to simply invoke sh in the Kubernetes PostStart lifecycle hook and have it expanded to the appropriate location on $PATH rather than hard-coding the location of sh to /bin/sh/.

I'm hopeful this is possible, as the Debugging Hook Handlers section of the Kubernetes docs show an error where a specific command was not found on $PATH:

Events:
  Type     Reason               Age              From               Message
  ----     ------               ----             ----               -------
(...)
  Warning  FailedPostStartHook  4s (x2 over 5s)  kubelet            Exec lifecycle hook ([badcommand]) for Container "lifecycle-demo-container" in Pod "lifecycle-demo_default(30229739-9651-4e5a-9a32-a8f1688862db)" failed - error: command 'badcommand' exited with 126: , message: "OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: \"badcommand\": executable file not found in $PATH: unknown\r\n"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions