Skip to content

Commit

Permalink
[Feature] allow to config the terminationGracePeriodSeconds
Browse files Browse the repository at this point in the history
Signed-off-by: yandongxiao <[email protected]>
  • Loading branch information
yandongxiao committed Oct 14, 2023
1 parent d36d9c4 commit 1add3ba
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 2 deletions.
52 changes: 52 additions & 0 deletions config/crd/bases/starrocks.com_starrocksclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,19 @@ spec:
- storageSize
type: object
type: array
terminationGracePeriodSeconds:
description: TerminationGracePeriodSeconds defines duration in
seconds the pod needs to terminate gracefully. May be decreased
in delete request. Value must be non-negative integer. The value
zero indicates stop immediately via the kill signal (no opportunity
to shut down). If this value is nil, the default grace period
will be used instead. The grace period is the duration in seconds
after the processes running in the pod are sent a termination
signal and the time when the processes are forcibly halted with
a kill signal. Set this value longer than the expected cleanup
time for your process. Defaults to 120 seconds.
format: int64
type: integer
tolerations:
description: (Optional) Tolerations for scheduling pods onto some
dedicated nodes
Expand Down Expand Up @@ -3218,6 +3231,19 @@ spec:
- storageSize
type: object
type: array
terminationGracePeriodSeconds:
description: TerminationGracePeriodSeconds defines duration in
seconds the pod needs to terminate gracefully. May be decreased
in delete request. Value must be non-negative integer. The value
zero indicates stop immediately via the kill signal (no opportunity
to shut down). If this value is nil, the default grace period
will be used instead. The grace period is the duration in seconds
after the processes running in the pod are sent a termination
signal and the time when the processes are forcibly halted with
a kill signal. Set this value longer than the expected cleanup
time for your process. Defaults to 120 seconds.
format: int64
type: integer
tolerations:
description: (Optional) Tolerations for scheduling pods onto some
dedicated nodes
Expand Down Expand Up @@ -4310,6 +4336,19 @@ spec:
- storageSize
type: object
type: array
terminationGracePeriodSeconds:
description: TerminationGracePeriodSeconds defines duration in
seconds the pod needs to terminate gracefully. May be decreased
in delete request. Value must be non-negative integer. The value
zero indicates stop immediately via the kill signal (no opportunity
to shut down). If this value is nil, the default grace period
will be used instead. The grace period is the duration in seconds
after the processes running in the pod are sent a termination
signal and the time when the processes are forcibly halted with
a kill signal. Set this value longer than the expected cleanup
time for your process. Defaults to 120 seconds.
format: int64
type: integer
tolerations:
description: (Optional) Tolerations for scheduling pods onto some
dedicated nodes
Expand Down Expand Up @@ -5575,6 +5614,19 @@ spec:
- storageSize
type: object
type: array
terminationGracePeriodSeconds:
description: TerminationGracePeriodSeconds defines duration in
seconds the pod needs to terminate gracefully. May be decreased
in delete request. Value must be non-negative integer. The value
zero indicates stop immediately via the kill signal (no opportunity
to shut down). If this value is nil, the default grace period
will be used instead. The grace period is the duration in seconds
after the processes running in the pod are sent a termination
signal and the time when the processes are forcibly halted with
a kill signal. Set this value longer than the expected cleanup
time for your process. Defaults to 120 seconds.
format: int64
type: integer
tolerations:
description: (Optional) Tolerations for scheduling pods onto some
dedicated nodes
Expand Down
12 changes: 12 additions & 0 deletions deploy/starrocks.com_starrocksclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ spec:
- storageSize
type: object
type: array
terminationGracePeriodSeconds:
format: int64
type: integer
tolerations:
items:
properties:
Expand Down Expand Up @@ -1496,6 +1499,9 @@ spec:
- storageSize
type: object
type: array
terminationGracePeriodSeconds:
format: int64
type: integer
tolerations:
items:
properties:
Expand Down Expand Up @@ -1975,6 +1981,9 @@ spec:
- storageSize
type: object
type: array
terminationGracePeriodSeconds:
format: int64
type: integer
tolerations:
items:
properties:
Expand Down Expand Up @@ -2547,6 +2556,9 @@ spec:
- storageSize
type: object
type: array
terminationGracePeriodSeconds:
format: int64
type: integer
tolerations:
items:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ spec:
tolerations:
{{toYaml .Values.starrocksFESpec.tolerations | indent 4 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.starrocksFESpec.terminationGracePeriodSeconds }}
{{- if .Values.starrocksFESpec.secrets }}
secrets:
{{- range .Values.starrocksFESpec.secrets }}
Expand Down Expand Up @@ -241,6 +242,7 @@ spec:
tolerations:
{{toYaml .Values.starrocksBeSpec.tolerations | indent 4 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.starrocksBeSpec.terminationGracePeriodSeconds }}
{{- if .Values.starrocksBeSpec.secrets }}
secrets:
{{- range .Values.starrocksBeSpec.secrets }}
Expand Down Expand Up @@ -333,6 +335,7 @@ spec:
tolerations:
{{toYaml .Values.starrocksCnSpec.tolerations | indent 4 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.starrocksCnSpec.terminationGracePeriodSeconds }}
{{- if and .Values.starrocksCluster.enabledCn .Values.starrocksCnSpec.autoScalingPolicy }}
autoScalingPolicy:
{{ toYaml .Values.starrocksCnSpec.autoScalingPolicy | indent 6 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ starrocksFESpec:
# - name: my-configmap
# mountPath: /etc/my-configmap
# subPath: ""
# terminationGracePeriodSeconds defines duration in seconds the FE pod needs to terminate gracefully.
terminationGracePeriodSeconds: 120

# spec for compute node, compute node provide compute function.
starrocksCnSpec:
Expand Down Expand Up @@ -325,6 +327,8 @@ starrocksCnSpec:
# - name: my-configmap
# mountPath: /etc/my-configmap
# subPath: ""
# terminationGracePeriodSeconds defines duration in seconds the CN pod needs to terminate gracefully.
terminationGracePeriodSeconds: 120

# spec for component be, provide storage and compute function.
starrocksBeSpec:
Expand Down Expand Up @@ -448,6 +452,8 @@ starrocksBeSpec:
# - name: my-configmap
# mountPath: /etc/my-configmap
# subPath: ""
# terminationGracePeriodSeconds defines duration in seconds the BE pod needs to terminate gracefully.
terminationGracePeriodSeconds: 120

# create secrets if necessary.
secrets: []
Expand Down
24 changes: 23 additions & 1 deletion pkg/apis/starrocks/v1/load_type.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package v1

import corev1 "k8s.io/api/core/v1"
import (
corev1 "k8s.io/api/core/v1"
)

type loadInterface interface {
GetAnnotations() map[string]string
Expand All @@ -12,6 +14,7 @@ type loadInterface interface {
GetAffinity() *corev1.Affinity
GetTolerations() []corev1.Toleration
GetStartupProbeFailureSeconds() *int32
GetTerminationGracePeriodSeconds() *int64

GetStorageVolumes() []StorageVolume
GetServiceAccount() string
Expand Down Expand Up @@ -90,6 +93,17 @@ type StarRocksLoadSpec struct {
// will be rounded up
// +optional
StartupProbeFailureSeconds *int32 `json:"startupProbeFailureSeconds,omitempty"`

// TerminationGracePeriodSeconds defines duration in seconds the pod needs to terminate gracefully. May be decreased in delete request.
// Value must be non-negative integer. The value zero indicates stop immediately via
// the kill signal (no opportunity to shut down).
// If this value is nil, the default grace period will be used instead.
// The grace period is the duration in seconds after the processes running in the pod are sent
// a termination signal and the time when the processes are forcibly halted with a kill signal.
// Set this value longer than the expected cleanup time for your process.
// Defaults to 120 seconds.
// +optional
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
}

// StarRocksService defines external service for starrocks component.
Expand Down Expand Up @@ -198,3 +212,11 @@ func (spec *StarRocksLoadSpec) GetSchedulerName() string {
func (spec *StarRocksLoadSpec) GetStartupProbeFailureSeconds() *int32 {
return spec.StartupProbeFailureSeconds
}

func (spec *StarRocksLoadSpec) GetTerminationGracePeriodSeconds() *int64 {
if spec.TerminationGracePeriodSeconds == nil {
v := int64(120)
return &v
}
return spec.TerminationGracePeriodSeconds
}
5 changes: 5 additions & 0 deletions pkg/apis/starrocks/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/k8sutils/templates/pod/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func Spec(spec v1.SpecInterface, defaultServiceAccount string, container corev1.
Containers: []corev1.Container{container},
Volumes: volumes,
ServiceAccountName: spec.GetServiceAccount(),
TerminationGracePeriodSeconds: rutils.GetInt64ptr(int64(120)),
TerminationGracePeriodSeconds: spec.GetTerminationGracePeriodSeconds(),
Affinity: spec.GetAffinity(),
Tolerations: spec.GetTolerations(),
ImagePullSecrets: spec.GetImagePullSecrets(),
Expand Down

0 comments on commit 1add3ba

Please sign in to comment.