Skip to content

Commit c9fa1e1

Browse files
committed
fix: trap SIGTERM in pre-init seid container so Job exits cleanly
The sidecar await-condition task sends SIGTERM to seid when the target height is reached. With exec, seid exits 143 which the Job treats as failure (backoffLimit: 0). Run seid as a child process with a TERM trap that exits 0 instead.
1 parent 9833d08 commit c9fa1e1

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • internal/controller/node

internal/controller/node/job.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,15 @@ func preInitSidecarURL(node *seiv1alpha1.SeiNode) string {
7777
}
7878

7979
// preInitWaitCommand returns a shell command that waits for the sidecar
80-
// healthz to return 200 and then runs a standard "seid start --home /sei".
80+
// healthz to return 200 and then runs "seid start --home /sei".
8181
// Unlike sidecarWaitCommand, it does NOT use the node's custom entrypoint
8282
// because the pre-init Job runs the bootstrap image which may not support
8383
// custom flags (e.g. --skip-app-hash-validation).
84+
//
85+
// seid is run as a child process (not exec'd) so the shell can trap
86+
// SIGTERM and exit 0. The sidecar's await-condition task sends SIGTERM
87+
// to seid when the target height is reached; without the trap, seid's
88+
// exit code 143 would cause the Job to fail.
8489
func preInitWaitCommand(port int32) (command []string, args []string) {
8590
script := fmt.Sprintf(
8691
`echo "waiting for sidecar to become ready..."; `+
@@ -91,7 +96,8 @@ func preInitWaitCommand(port int32) (command []string, args []string) {
9196
`exec 3>&-; sleep 5; done; `+
9297
`exec 3>&-; `+
9398
`echo "sidecar ready, starting seid"; `+
94-
`exec seid start --home %s`,
99+
`trap 'exit 0' TERM; `+
100+
`seid start --home %s & wait $!`,
95101
port, dataDir,
96102
)
97103
return []string{"/bin/bash", "-c"}, []string{script}

0 commit comments

Comments
 (0)