Skip to content

Commit 70540c9

Browse files
API changes
1 parent 62555ca commit 70540c9

File tree

5 files changed

+181
-0
lines changed

5 files changed

+181
-0
lines changed

pkg/apis/core/types.go

+83
Original file line numberDiff line numberDiff line change
@@ -2673,6 +2673,78 @@ type GRPCAction struct {
26732673
Service *string
26742674
}
26752675

2676+
// Signal defines the stop signal of containers
2677+
// +enum
2678+
type Signal string
2679+
2680+
const (
2681+
SIGABRT Signal = "SIGABRT"
2682+
SIGALRM Signal = "SIGALRM"
2683+
SIGBUS Signal = "SIGBUS"
2684+
SIGCHLD Signal = "SIGCHLD"
2685+
SIGCLD Signal = "SIGCLD"
2686+
SIGCONT Signal = "SIGCONT"
2687+
SIGFPE Signal = "SIGFPE"
2688+
SIGHUP Signal = "SIGHUP"
2689+
SIGILL Signal = "SIGILL"
2690+
SIGINT Signal = "SIGINT"
2691+
SIGIO Signal = "SIGIO"
2692+
SIGIOT Signal = "SIGIOT"
2693+
SIGKILL Signal = "SIGKILL"
2694+
SIGPIPE Signal = "SIGPIPE"
2695+
SIGPOLL Signal = "SIGPOLL"
2696+
SIGPROF Signal = "SIGPROF"
2697+
SIGPWR Signal = "SIGPWR"
2698+
SIGQUIT Signal = "SIGQUIT"
2699+
SIGSEGV Signal = "SIGSEGV"
2700+
SIGSTKFLT Signal = "SIGSTKFLT"
2701+
SIGSTOP Signal = "SIGSTOP"
2702+
SIGSYS Signal = "SIGSYS"
2703+
SIGTERM Signal = "SIGTERM"
2704+
SIGTRAP Signal = "SIGTRAP"
2705+
SIGTSTP Signal = "SIGTSTP"
2706+
SIGTTIN Signal = "SIGTTIN"
2707+
SIGTTOU Signal = "SIGTTOU"
2708+
SIGURG Signal = "SIGURG"
2709+
SIGUSR1 Signal = "SIGUSR1"
2710+
SIGUSR2 Signal = "SIGUSR2"
2711+
SIGVTALRM Signal = "SIGVTALRM"
2712+
SIGWINCH Signal = "SIGWINCH"
2713+
SIGXCPU Signal = "SIGXCPU"
2714+
SIGXFSZ Signal = "SIGXFSZ"
2715+
SIGRTMIN Signal = "SIGRTMIN"
2716+
SIGRTMINPLUS1 Signal = "SIGRTMIN+1"
2717+
SIGRTMINPLUS2 Signal = "SIGRTMIN+2"
2718+
SIGRTMINPLUS3 Signal = "SIGRTMIN+3"
2719+
SIGRTMINPLUS4 Signal = "SIGRTMIN+4"
2720+
SIGRTMINPLUS5 Signal = "SIGRTMIN+5"
2721+
SIGRTMINPLUS6 Signal = "SIGRTMIN+6"
2722+
SIGRTMINPLUS7 Signal = "SIGRTMIN+7"
2723+
SIGRTMINPLUS8 Signal = "SIGRTMIN+8"
2724+
SIGRTMINPLUS9 Signal = "SIGRTMIN+9"
2725+
SIGRTMINPLUS10 Signal = "SIGRTMIN+10"
2726+
SIGRTMINPLUS11 Signal = "SIGRTMIN+11"
2727+
SIGRTMINPLUS12 Signal = "SIGRTMIN+12"
2728+
SIGRTMINPLUS13 Signal = "SIGRTMIN+13"
2729+
SIGRTMINPLUS14 Signal = "SIGRTMIN+14"
2730+
SIGRTMINPLUS15 Signal = "SIGRTMIN+15"
2731+
SIGRTMAXMINUS14 Signal = "SIGRTMAX-14"
2732+
SIGRTMAXMINUS13 Signal = "SIGRTMAX-13"
2733+
SIGRTMAXMINUS12 Signal = "SIGRTMAX-12"
2734+
SIGRTMAXMINUS11 Signal = "SIGRTMAX-11"
2735+
SIGRTMAXMINUS10 Signal = "SIGRTMAX-10"
2736+
SIGRTMAXMINUS9 Signal = "SIGRTMAX-9"
2737+
SIGRTMAXMINUS8 Signal = "SIGRTMAX-8"
2738+
SIGRTMAXMINUS7 Signal = "SIGRTMAX-7"
2739+
SIGRTMAXMINUS6 Signal = "SIGRTMAX-6"
2740+
SIGRTMAXMINUS5 Signal = "SIGRTMAX-5"
2741+
SIGRTMAXMINUS4 Signal = "SIGRTMAX-4"
2742+
SIGRTMAXMINUS3 Signal = "SIGRTMAX-3"
2743+
SIGRTMAXMINUS2 Signal = "SIGRTMAX-2"
2744+
SIGRTMAXMINUS1 Signal = "SIGRTMAX-1"
2745+
SIGRTMAX Signal = "SIGRTMAX"
2746+
)
2747+
26762748
// Lifecycle describes actions that the management system should take in response to container lifecycle
26772749
// events. For the PostStart and PreStop lifecycle handlers, management of the container blocks
26782750
// until the action is complete, unless the container process fails, in which case the handler is aborted.
@@ -2693,6 +2765,11 @@ type Lifecycle struct {
26932765
// More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks
26942766
// +optional
26952767
PreStop *LifecycleHandler
2768+
// StopSignal defines which signal will be sent to a container when it is being stopped.
2769+
// If not specified, the default is defined by the container runtime in use.
2770+
// StopSignal can only be set for Pods with a non-empty .spec.os.name
2771+
// +optional
2772+
StopSignal *Signal
26962773
}
26972774

26982775
// The below types are used by kube_client and api_server.
@@ -2831,6 +2908,12 @@ type ContainerStatus struct {
28312908
// +featureGate=ResourceHealthStatus
28322909
// +optional
28332910
AllocatedResourcesStatus []ResourceStatus
2911+
// StopSignal is the signal which will be sent to this container when it is stopped. This might be
2912+
// the stop signal specified by the user, the signal specified in the container image, or the default
2913+
// stop signal of the container runtime on this node.
2914+
// +featureGate=ContainerStopSignals
2915+
// +optional
2916+
StopSignal *Signal
28342917
}
28352918

28362919
type ResourceStatus struct {

pkg/features/kube_features.go

+9
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ const (
7979
// Enable ClusterTrustBundle Kubelet projected volumes. Depends on ClusterTrustBundle.
8080
ClusterTrustBundleProjection featuregate.Feature = "ClusterTrustBundleProjection"
8181

82+
// owner: @sreeram-venkitesh
83+
//
84+
// Enables configuring custom stop signals for containers from container lifecycle
85+
ContainerStopSignals featuregate.Feature = "ContainerStopSignals"
86+
8287
// owner: @szuecs
8388
//
8489
// Enable nodes to change CPUCFSQuotaPeriod
@@ -1038,6 +1043,10 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
10381043
{Version: version.MustParse("1.33"), Default: false, PreRelease: featuregate.Beta},
10391044
},
10401045

1046+
ContainerStopSignals: {
1047+
{Version: version.MustParse("1.33"), Default: false, PreRelease: featuregate.Alpha},
1048+
},
1049+
10411050
ContainerCheckpoint: {
10421051
{Version: version.MustParse("1.25"), Default: false, PreRelease: featuregate.Alpha},
10431052
{Version: version.MustParse("1.30"), Default: true, PreRelease: featuregate.Beta},

pkg/kubelet/container/runtime.go

+2
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ type Status struct {
388388
User *ContainerUser
389389
// Mounts are the volume mounts of the container
390390
Mounts []Mount
391+
// StopSignal is used to show the container's effective stop signal in the Status
392+
StopSignal *v1.Signal
391393
}
392394

393395
// ContainerUser represents user identity information

staging/src/k8s.io/api/core/v1/types.go

+81
Original file line numberDiff line numberDiff line change
@@ -2980,6 +2980,78 @@ type LifecycleHandler struct {
29802980
Sleep *SleepAction `json:"sleep,omitempty" protobuf:"bytes,4,opt,name=sleep"`
29812981
}
29822982

2983+
// Signal defines the stop signal of containers
2984+
// +enum
2985+
type Signal string
2986+
2987+
const (
2988+
SIGABRT Signal = "SIGABRT"
2989+
SIGALRM Signal = "SIGALRM"
2990+
SIGBUS Signal = "SIGBUS"
2991+
SIGCHLD Signal = "SIGCHLD"
2992+
SIGCLD Signal = "SIGCLD"
2993+
SIGCONT Signal = "SIGCONT"
2994+
SIGFPE Signal = "SIGFPE"
2995+
SIGHUP Signal = "SIGHUP"
2996+
SIGILL Signal = "SIGILL"
2997+
SIGINT Signal = "SIGINT"
2998+
SIGIO Signal = "SIGIO"
2999+
SIGIOT Signal = "SIGIOT"
3000+
SIGKILL Signal = "SIGKILL"
3001+
SIGPIPE Signal = "SIGPIPE"
3002+
SIGPOLL Signal = "SIGPOLL"
3003+
SIGPROF Signal = "SIGPROF"
3004+
SIGPWR Signal = "SIGPWR"
3005+
SIGQUIT Signal = "SIGQUIT"
3006+
SIGSEGV Signal = "SIGSEGV"
3007+
SIGSTKFLT Signal = "SIGSTKFLT"
3008+
SIGSTOP Signal = "SIGSTOP"
3009+
SIGSYS Signal = "SIGSYS"
3010+
SIGTERM Signal = "SIGTERM"
3011+
SIGTRAP Signal = "SIGTRAP"
3012+
SIGTSTP Signal = "SIGTSTP"
3013+
SIGTTIN Signal = "SIGTTIN"
3014+
SIGTTOU Signal = "SIGTTOU"
3015+
SIGURG Signal = "SIGURG"
3016+
SIGUSR1 Signal = "SIGUSR1"
3017+
SIGUSR2 Signal = "SIGUSR2"
3018+
SIGVTALRM Signal = "SIGVTALRM"
3019+
SIGWINCH Signal = "SIGWINCH"
3020+
SIGXCPU Signal = "SIGXCPU"
3021+
SIGXFSZ Signal = "SIGXFSZ"
3022+
SIGRTMIN Signal = "SIGRTMIN"
3023+
SIGRTMINPLUS1 Signal = "SIGRTMIN+1"
3024+
SIGRTMINPLUS2 Signal = "SIGRTMIN+2"
3025+
SIGRTMINPLUS3 Signal = "SIGRTMIN+3"
3026+
SIGRTMINPLUS4 Signal = "SIGRTMIN+4"
3027+
SIGRTMINPLUS5 Signal = "SIGRTMIN+5"
3028+
SIGRTMINPLUS6 Signal = "SIGRTMIN+6"
3029+
SIGRTMINPLUS7 Signal = "SIGRTMIN+7"
3030+
SIGRTMINPLUS8 Signal = "SIGRTMIN+8"
3031+
SIGRTMINPLUS9 Signal = "SIGRTMIN+9"
3032+
SIGRTMINPLUS10 Signal = "SIGRTMIN+10"
3033+
SIGRTMINPLUS11 Signal = "SIGRTMIN+11"
3034+
SIGRTMINPLUS12 Signal = "SIGRTMIN+12"
3035+
SIGRTMINPLUS13 Signal = "SIGRTMIN+13"
3036+
SIGRTMINPLUS14 Signal = "SIGRTMIN+14"
3037+
SIGRTMINPLUS15 Signal = "SIGRTMIN+15"
3038+
SIGRTMAXMINUS14 Signal = "SIGRTMAX-14"
3039+
SIGRTMAXMINUS13 Signal = "SIGRTMAX-13"
3040+
SIGRTMAXMINUS12 Signal = "SIGRTMAX-12"
3041+
SIGRTMAXMINUS11 Signal = "SIGRTMAX-11"
3042+
SIGRTMAXMINUS10 Signal = "SIGRTMAX-10"
3043+
SIGRTMAXMINUS9 Signal = "SIGRTMAX-9"
3044+
SIGRTMAXMINUS8 Signal = "SIGRTMAX-8"
3045+
SIGRTMAXMINUS7 Signal = "SIGRTMAX-7"
3046+
SIGRTMAXMINUS6 Signal = "SIGRTMAX-6"
3047+
SIGRTMAXMINUS5 Signal = "SIGRTMAX-5"
3048+
SIGRTMAXMINUS4 Signal = "SIGRTMAX-4"
3049+
SIGRTMAXMINUS3 Signal = "SIGRTMAX-3"
3050+
SIGRTMAXMINUS2 Signal = "SIGRTMAX-2"
3051+
SIGRTMAXMINUS1 Signal = "SIGRTMAX-1"
3052+
SIGRTMAX Signal = "SIGRTMAX"
3053+
)
3054+
29833055
// Lifecycle describes actions that the management system should take in response to container lifecycle
29843056
// events. For the PostStart and PreStop lifecycle handlers, management of the container blocks
29853057
// until the action is complete, unless the container process fails, in which case the handler is aborted.
@@ -3001,6 +3073,11 @@ type Lifecycle struct {
30013073
// More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks
30023074
// +optional
30033075
PreStop *LifecycleHandler `json:"preStop,omitempty" protobuf:"bytes,2,opt,name=preStop"`
3076+
// StopSignal defines which signal will be sent to a container when it is being stopped.
3077+
// If not specified, the default is defined by the container runtime in use.
3078+
// StopSignal can only be set for Pods with a non-empty .spec.os.name
3079+
// +optional
3080+
StopSignal *Signal `json:"stopSignal,omitempty" protobuf:"bytes,3,opt,name=stopSignal"`
30043081
}
30053082

30063083
type ConditionStatus string
@@ -3154,6 +3231,10 @@ type ContainerStatus struct {
31543231
// +listType=map
31553232
// +listMapKey=name
31563233
AllocatedResourcesStatus []ResourceStatus `json:"allocatedResourcesStatus,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,14,rep,name=allocatedResourcesStatus"`
3234+
// StopSignal reports the effective stop signal for this container
3235+
// +featureGate=ContainerStopSignals
3236+
// +optional
3237+
StopSignal *Signal `json:"stopSignal,omitempty" protobuf:"bytes,15,opt,name=stopSignal"`
31573238
}
31583239

31593240
// ResourceStatus represents the status of a single resource allocated to a Pod.

test/compatibility_lifecycle/reference/versioned_feature_list.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@
241241
lockToDefault: false
242242
preRelease: Beta
243243
version: "1.30"
244+
- name: ContainerStopSignals
245+
versionedSpecs:
246+
- default: false
247+
lockToDefault: false
248+
preRelease: Alpha
249+
version: "1.33"
244250
- name: ContextualLogging
245251
versionedSpecs:
246252
- default: false

0 commit comments

Comments
 (0)