Merge pull request #26491 from ArthurWuTW/25389

Pod YAML: Add support for `lifecycle.stopSignal`
This commit is contained in:
openshift-merge-bot[bot]
2025-06-24 19:44:30 +00:00
committed by GitHub
4 changed files with 73 additions and 0 deletions

View File

@ -1331,6 +1331,13 @@ type Lifecycle struct {
// More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks
// +optional
PreStop *Handler `json:"preStop,omitempty"`
// StopSignal defines the signal to be sent to the container when stopping.
// This value is configured via the container's Lifecycle and overrides any
// stop signal defined in the container image. If no StopSignal is specified,
// the default signal (SIGTERM) will be used.
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#defining-custom-stop-signals
// +optional
StopSignal *string `json:"stopSignal,omitempty"`
}
type ConditionStatus string

View File

@ -656,6 +656,14 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
s.StopTimeout = &timeout
}
if lifecycle := opts.Container.Lifecycle; lifecycle != nil && lifecycle.StopSignal != nil {
stopSignal, err := util.ParseSignal(*lifecycle.StopSignal)
if err != nil {
return nil, err
}
s.StopSignal = &stopSignal
}
return s, nil
}