Skip to content

Commit 118546d

Browse files
Merge pull request #130556 from sreeram-venkitesh/kep-4960-container-stop-signals
KEP 4960: Container Stop Signals Kubernetes-commit: ff25881bc1fe9da1dda4ec82d294b92078ae2763
2 parents f9401a3 + 9b3e544 commit 118546d

File tree

65 files changed

+1400
-1078
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1400
-1078
lines changed

core/v1/generated.pb.go

Lines changed: 1104 additions & 1012 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/v1/generated.proto

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/v1/types.go

Lines changed: 81 additions & 0 deletions
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.

core/v1/types_swagger_doc_generated.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ var map_ContainerStatus = map[string]string{
474474
"volumeMounts": "Status of volume mounts.",
475475
"user": "User represents user identity information initially attached to the first process of the container",
476476
"allocatedResourcesStatus": "AllocatedResourcesStatus represents the status of various resources allocated for this Pod.",
477+
"stopSignal": "StopSignal reports the effective stop signal for this container",
477478
}
478479

479480
func (ContainerStatus) SwaggerDoc() map[string]string {
@@ -957,9 +958,10 @@ func (KeyToPath) SwaggerDoc() map[string]string {
957958
}
958959

959960
var map_Lifecycle = map[string]string{
960-
"": "Lifecycle describes actions that the management system should take in response to container lifecycle events. For the PostStart and PreStop lifecycle handlers, management of the container blocks until the action is complete, unless the container process fails, in which case the handler is aborted.",
961-
"postStart": "PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks",
962-
"preStop": "PreStop is called immediately before a container is terminated due to an API request or management event such as liveness/startup probe failure, preemption, resource contention, etc. The handler is not called if the container crashes or exits. The Pod's termination grace period countdown begins before the PreStop hook is executed. Regardless of the outcome of the handler, the container will eventually terminate within the Pod's termination grace period (unless delayed by finalizers). Other management of the container blocks until the hook completes or until the termination grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks",
961+
"": "Lifecycle describes actions that the management system should take in response to container lifecycle events. For the PostStart and PreStop lifecycle handlers, management of the container blocks until the action is complete, unless the container process fails, in which case the handler is aborted.",
962+
"postStart": "PostStart is called immediately after a container is created. If the handler fails, the container is terminated and restarted according to its restart policy. Other management of the container blocks until the hook completes. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks",
963+
"preStop": "PreStop is called immediately before a container is terminated due to an API request or management event such as liveness/startup probe failure, preemption, resource contention, etc. The handler is not called if the container crashes or exits. The Pod's termination grace period countdown begins before the PreStop hook is executed. Regardless of the outcome of the handler, the container will eventually terminate within the Pod's termination grace period (unless delayed by finalizers). Other management of the container blocks until the hook completes or until the termination grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks",
964+
"stopSignal": "StopSignal defines which signal will be sent to a container when it is being stopped. If not specified, the default is defined by the container runtime in use. StopSignal can only be set for Pods with a non-empty .spec.os.name",
963965
}
964966

965967
func (Lifecycle) SwaggerDoc() map[string]string {

core/v1/zz_generated.deepcopy.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testdata/HEAD/apps.v1.DaemonSet.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,8 @@
747747
"sleep": {
748748
"seconds": 1
749749
}
750-
}
750+
},
751+
"stopSignal": "stopSignalValue"
751752
},
752753
"terminationMessagePath": "terminationMessagePathValue",
753754
"terminationMessagePolicy": "terminationMessagePolicyValue",
@@ -1043,7 +1044,8 @@
10431044
"sleep": {
10441045
"seconds": 1
10451046
}
1046-
}
1047+
},
1048+
"stopSignal": "stopSignalValue"
10471049
},
10481050
"terminationMessagePath": "terminationMessagePathValue",
10491051
"terminationMessagePolicy": "terminationMessagePolicyValue",
@@ -1339,7 +1341,8 @@
13391341
"sleep": {
13401342
"seconds": 1
13411343
}
1342-
}
1344+
},
1345+
"stopSignal": "stopSignalValue"
13431346
},
13441347
"terminationMessagePath": "terminationMessagePathValue",
13451348
"terminationMessagePolicy": "terminationMessagePolicyValue",

testdata/HEAD/apps.v1.DaemonSet.pb

51 Bytes
Binary file not shown.

testdata/HEAD/apps.v1.DaemonSet.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ spec:
277277
tcpSocket:
278278
host: hostValue
279279
port: portValue
280+
stopSignal: stopSignalValue
280281
livenessProbe:
281282
exec:
282283
command:
@@ -493,6 +494,7 @@ spec:
493494
tcpSocket:
494495
host: hostValue
495496
port: portValue
497+
stopSignal: stopSignalValue
496498
livenessProbe:
497499
exec:
498500
command:
@@ -711,6 +713,7 @@ spec:
711713
tcpSocket:
712714
host: hostValue
713715
port: portValue
716+
stopSignal: stopSignalValue
714717
livenessProbe:
715718
exec:
716719
command:

testdata/HEAD/apps.v1.Deployment.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,8 @@
748748
"sleep": {
749749
"seconds": 1
750750
}
751-
}
751+
},
752+
"stopSignal": "stopSignalValue"
752753
},
753754
"terminationMessagePath": "terminationMessagePathValue",
754755
"terminationMessagePolicy": "terminationMessagePolicyValue",
@@ -1044,7 +1045,8 @@
10441045
"sleep": {
10451046
"seconds": 1
10461047
}
1047-
}
1048+
},
1049+
"stopSignal": "stopSignalValue"
10481050
},
10491051
"terminationMessagePath": "terminationMessagePathValue",
10501052
"terminationMessagePolicy": "terminationMessagePolicyValue",
@@ -1340,7 +1342,8 @@
13401342
"sleep": {
13411343
"seconds": 1
13421344
}
1343-
}
1345+
},
1346+
"stopSignal": "stopSignalValue"
13441347
},
13451348
"terminationMessagePath": "terminationMessagePathValue",
13461349
"terminationMessagePolicy": "terminationMessagePolicyValue",

testdata/HEAD/apps.v1.Deployment.pb

51 Bytes
Binary file not shown.

testdata/HEAD/apps.v1.Deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ spec:
285285
tcpSocket:
286286
host: hostValue
287287
port: portValue
288+
stopSignal: stopSignalValue
288289
livenessProbe:
289290
exec:
290291
command:
@@ -501,6 +502,7 @@ spec:
501502
tcpSocket:
502503
host: hostValue
503504
port: portValue
505+
stopSignal: stopSignalValue
504506
livenessProbe:
505507
exec:
506508
command:
@@ -719,6 +721,7 @@ spec:
719721
tcpSocket:
720722
host: hostValue
721723
port: portValue
724+
stopSignal: stopSignalValue
722725
livenessProbe:
723726
exec:
724727
command:

testdata/HEAD/apps.v1.ReplicaSet.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@
749749
"sleep": {
750750
"seconds": 1
751751
}
752-
}
752+
},
753+
"stopSignal": "stopSignalValue"
753754
},
754755
"terminationMessagePath": "terminationMessagePathValue",
755756
"terminationMessagePolicy": "terminationMessagePolicyValue",
@@ -1045,7 +1046,8 @@
10451046
"sleep": {
10461047
"seconds": 1
10471048
}
1048-
}
1049+
},
1050+
"stopSignal": "stopSignalValue"
10491051
},
10501052
"terminationMessagePath": "terminationMessagePathValue",
10511053
"terminationMessagePolicy": "terminationMessagePolicyValue",
@@ -1341,7 +1343,8 @@
13411343
"sleep": {
13421344
"seconds": 1
13431345
}
1344-
}
1346+
},
1347+
"stopSignal": "stopSignalValue"
13451348
},
13461349
"terminationMessagePath": "terminationMessagePathValue",
13471350
"terminationMessagePolicy": "terminationMessagePolicyValue",

testdata/HEAD/apps.v1.ReplicaSet.pb

51 Bytes
Binary file not shown.

testdata/HEAD/apps.v1.ReplicaSet.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ spec:
277277
tcpSocket:
278278
host: hostValue
279279
port: portValue
280+
stopSignal: stopSignalValue
280281
livenessProbe:
281282
exec:
282283
command:
@@ -493,6 +494,7 @@ spec:
493494
tcpSocket:
494495
host: hostValue
495496
port: portValue
497+
stopSignal: stopSignalValue
496498
livenessProbe:
497499
exec:
498500
command:
@@ -711,6 +713,7 @@ spec:
711713
tcpSocket:
712714
host: hostValue
713715
port: portValue
716+
stopSignal: stopSignalValue
714717
livenessProbe:
715718
exec:
716719
command:

testdata/HEAD/apps.v1.StatefulSet.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,8 @@
748748
"sleep": {
749749
"seconds": 1
750750
}
751-
}
751+
},
752+
"stopSignal": "stopSignalValue"
752753
},
753754
"terminationMessagePath": "terminationMessagePathValue",
754755
"terminationMessagePolicy": "terminationMessagePolicyValue",
@@ -1044,7 +1045,8 @@
10441045
"sleep": {
10451046
"seconds": 1
10461047
}
1047-
}
1048+
},
1049+
"stopSignal": "stopSignalValue"
10481050
},
10491051
"terminationMessagePath": "terminationMessagePathValue",
10501052
"terminationMessagePolicy": "terminationMessagePolicyValue",
@@ -1340,7 +1342,8 @@
13401342
"sleep": {
13411343
"seconds": 1
13421344
}
1343-
}
1345+
},
1346+
"stopSignal": "stopSignalValue"
13441347
},
13451348
"terminationMessagePath": "terminationMessagePathValue",
13461349
"terminationMessagePolicy": "terminationMessagePolicyValue",

testdata/HEAD/apps.v1.StatefulSet.pb

51 Bytes
Binary file not shown.

testdata/HEAD/apps.v1.StatefulSet.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ spec:
285285
tcpSocket:
286286
host: hostValue
287287
port: portValue
288+
stopSignal: stopSignalValue
288289
livenessProbe:
289290
exec:
290291
command:
@@ -501,6 +502,7 @@ spec:
501502
tcpSocket:
502503
host: hostValue
503504
port: portValue
505+
stopSignal: stopSignalValue
504506
livenessProbe:
505507
exec:
506508
command:
@@ -719,6 +721,7 @@ spec:
719721
tcpSocket:
720722
host: hostValue
721723
port: portValue
724+
stopSignal: stopSignalValue
722725
livenessProbe:
723726
exec:
724727
command:

0 commit comments

Comments
 (0)