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

feat: add pre-stop hook to unregister a compute node before its pod's termination #71

Merged
merged 2 commits into from
May 7, 2024
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
11 changes: 11 additions & 0 deletions charts/risingwave/templates/compute-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ spec:
command:
- /risingwave/bin/risingwave
- compute-node
{{- if .Values.computeComponent.autoDeregistration.enabled }}
lifecycle:
preStop:
exec:
command:
- bash
- -c
- >-
/risingwave/bin/risingwave ctl meta unregister-workers --yes \
--workers ${POD_NAME}.{{ include "risingwave.computeHeadlessServiceName" . }}.{{.Release.Namespace}}.svc:{{ .Values.ports.compute.svc }}
{{- end }}
{{- end }}
ports:
- containerPort: {{ .Values.ports.compute.svc }}
Expand Down
31 changes: 31 additions & 0 deletions charts/risingwave/tests/compute_auto_deregistration_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
suite: Test compute auto deregistration
templates:
- compute-sts.yaml
chart:
appVersion: 1.0.0
version: 0.0.1
tests:
- it: lifecycle doesn't exist when disabled
set:
computeComponent:
autoDeregistration:
enabled: false
asserts:
- notExists:
path: spec.template.spec.containers[0].lifecycle
- it: lifecycle exists when enabled
set:
computeComponent:
autoDeregistration:
enabled: true
asserts:
- exists:
path: spec.template.spec.containers[0].lifecycle
- equal:
path: spec.template.spec.containers[0].lifecycle.preStop.exec.command
value:
- bash
- -c
- >-
/risingwave/bin/risingwave ctl meta unregister-workers --yes \
--workers ${POD_NAME}.RELEASE-NAME-risingwave-compute-headless.NAMESPACE.svc:5688
7 changes: 7 additions & 0 deletions charts/risingwave/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,13 @@ computeComponent:
whenDeleted: Delete
whenScaled: Delete

## @param autoDeregistration Auto-deregistration of compute pods. If enabled, compute pods will be
## automatically deregistered from the meta store when they are deleted.
##
autoDeregistration:
## @param autoDeregistration.enabled Enable auto-deregistration.
enabled: false

compactorComponent:
## @param compactorComponent.podLabels Labels to add to the component pods.
##
Expand Down