Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] allow to config the terminationGracePeriodSeconds #283

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 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 @@ -5575,6 +5601,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
9 changes: 9 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 @@ -2547,6 +2553,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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why there is only 3 occurrence of the terminationGracePeriodSeconds while there are 4 changes in the starrocks_cluster.yaml?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The terminationGracePeriodSeconds was placed in an incorrect location, allowing the FE Proxy to also set the terminationGracePeriodSeconds.

terminationGracePeriodSeconds: 120

# spec for compute node, compute node provide compute function.
starrocksCnSpec:
Expand Down Expand Up @@ -336,6 +338,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 @@ -459,6 +463,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
19 changes: 19 additions & 0 deletions pkg/apis/starrocks/v1/component_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ type StarRocksComponentSpec struct {
// file if specified. This is only valid for non-hostNetwork pods.
// +optional
HostAliases []corev1.HostAlias `json:"hostAliases,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"`
}

// StarRocksComponentStatus represents the status of a starrocks component.
Expand Down Expand Up @@ -106,3 +117,11 @@ func (spec *StarRocksComponentSpec) GetRunAsNonRoot() (*int64, *int64) {
groupId := int64(1000)
return &userId, &groupId
}

func (spec *StarRocksComponentSpec) GetTerminationGracePeriodSeconds() *int64 {
if spec.TerminationGracePeriodSeconds == nil {
v := int64(120)
return &v
}
return spec.TerminationGracePeriodSeconds
}
4 changes: 3 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 Down
8 changes: 8 additions & 0 deletions pkg/apis/starrocks/v1/starrockscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type SpecInterface interface {
loadInterface
GetHostAliases() []corev1.HostAlias
GetRunAsNonRoot() (*int64, *int64)
GetTerminationGracePeriodSeconds() *int64
}

var _ SpecInterface = &StarRocksFeSpec{}
Expand Down Expand Up @@ -181,6 +182,13 @@ func (spec *StarRocksFeProxySpec) GetRunAsNonRoot() (*int64, *int64) {
return nil, nil
}

// GetTerminationGracePeriodSeconds
// fe proxy does not have field TerminationGracePeriodSeconds, the reason why implementing this method is
// that StarRocksFeProxySpec needs to implement SpecInterface interface
func (spec *StarRocksFeProxySpec) GetTerminationGracePeriodSeconds() *int64 {
return nil
}

// ClusterPhase represent the cluster phase. the possible value for cluster phase are: running, failed, pending.
type ClusterPhase string

Expand Down
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
Loading