Skip to content

fix(builder): replace lifecycle handlers instead of merging them - #245

Open
giuliocalzo wants to merge 1 commit into
SlinkyProject:mainfrom
giuliocalzo:gcalzolari/configurable-slurmd-prestop
Open

fix(builder): replace lifecycle handlers instead of merging them#245
giuliocalzo wants to merge 1 commit into
SlinkyProject:mainfrom
giuliocalzo:gcalzolari/configurable-slurmd-prestop

Conversation

@giuliocalzo

@giuliocalzo giuliocalzo commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

A NodeSet can already override the slurmd preStop command, but only while the handler stays an exec one. BuildContainer merges the handler from spec.slurmd.lifecycle into the operator default with a strategic merge patch, so switching the action to httpGet, tcpSocket, or sleep leaves the default exec in place alongside it. A lifecycle handler may specify only one action, so Kubernetes rejects the result.

A merged lifecycle handler now displaces the base handler rather than being merged into it, the way BuildContainer already treats probe handlers. The default slurmd preStop also moves out of an inline literal into a named function, so what a NodeSet replaces is legible at the call site.

Both new cases fail against main and pass with the fix: TestBuilder_BuildContainer/preStop_httpGet_replaces_exec and TestWorkerBuilder_slurmdContainerPreStop/httpGet_handler_replaces_the_default_exec.

Checklist

  • I have read the
    CONTRIBUTING.md
    and the
    Code of Conduct.
  • New or existing tests cover these changes (where applicable).
  • Documentation is updated if user-visible behavior changes.

Breaking Changes

None. A NodeSet that does not set spec.slurmd.lifecycle renders an identical container.

Testing Notes

Deploy a NodeSet whose preStop uses a different action than the default exec:

spec:
  slurmd:
    lifecycle:
      preStop:
        httpGet:
          path: /drain
          port: slurmd

On main the API server rejects the pod, because the rendered handler carries both httpGet and the operator's exec. With this change the pod is admitted and carries only the httpGet handler:

kubectl get pod <nodeset-pod> -o jsonpath='{.spec.containers[?(@.name=="slurmd")].lifecycle.preStop}'

A NodeSet with no lifecycle should still show the default state=down hook.

Additional Context

Also submitted upstream on GitLab as slurm-operator!724, where the maintainers do their review; I will close whichever of the two you prefer not to keep.

@giuliocalzo giuliocalzo changed the title feat: make the slurmd preStop hook configurable feat(NodeSet): make the slurmd preStop hook configurable Aug 28, 2026
@giuliocalzo
giuliocalzo force-pushed the gcalzolari/configurable-slurmd-prestop branch 4 times, most recently from 210f1be to ed0b9ec Compare September 4, 2026 08:04
A NodeSet can already override the slurmd preStop command, but only while
the handler stays an `exec` one. Strategic merge patch combines the handler
from `spec.slurmd.lifecycle` with the operator default, so switching the
action to `httpGet`, `tcpSocket`, or `sleep` renders a handler holding two
actions, which Kubernetes rejects.

Let a merged lifecycle handler displace the base handler, the way probe
handlers are already treated, and lift the default slurmd preStop out of an
inline literal into a named function so what a NodeSet replaces is legible.

Signed-off-by: Giulio Calzolari <gcalzolari@nvidia.com>
Changelog: Fixed - A non-exec slurmd preStop handler rendered an invalid container.
@giuliocalzo
giuliocalzo force-pushed the gcalzolari/configurable-slurmd-prestop branch from ed0b9ec to f0d94d0 Compare September 4, 2026 15:07
@giuliocalzo giuliocalzo changed the title feat(NodeSet): make the slurmd preStop hook configurable fix(builder): replace lifecycle handlers instead of merging them Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant