-
Notifications
You must be signed in to change notification settings - Fork 366
[BugFix][Feat]: fix serviceEngineSpec probe field and improve probe management in helm template #809
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
Conversation
Signed-off-by: emanuelecassese <emanuele.cassese@gmail.com>
Signed-off-by: emanuelecassese <emanuele.cassese@gmail.com>
Summary of ChangesHello @emanuelecassese, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the Helm chart's handling of Kubernetes probes for Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
These are some of the test values i've use to test my changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses an issue with probe configuration by moving default values into the Helm template for more granular control and expanding probe support. The changes in values.yaml are appropriate. The new implementation in _helpers.tpl is a significant improvement, but there are opportunities to enhance maintainability, consistency, and robustness, as detailed in the review comments.
helm/templates/_helpers.tpl
Outdated
| {{- define "chart.probes" -}} | ||
| {{- if .Values.servingEngineSpec.startupProbe }} | ||
| {{- if .Values.servingEngineSpec.startupProbe }} | ||
| startupProbe: | ||
| {{- with .Values.servingEngineSpec.startupProbe }} | ||
| {{- toYaml . | nindent 2 }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if .Values.servingEngineSpec.livenessProbe }} | ||
| {{- with .Values.servingEngineSpec.startupProbe }} | ||
| initialDelaySeconds: {{ .initialDelaySeconds | default 15 }} | ||
| periodSeconds: {{ .periodSeconds | default 10 }} | ||
| failureThreshold: {{ .failureThreshold | default 3 }} | ||
| {{- if .timeoutSeconds }} | ||
| timeoutSeconds: {{ .timeoutSeconds }} | ||
| {{- end }} | ||
| {{- if .successThreshold }} | ||
| successThreshold: {{ .successThreshold }} | ||
| {{- end }} | ||
| {{- if .exec }} | ||
| exec: | ||
| command: {{- range .exec.command }} | ||
| - {{.}} {{- end}} | ||
| {{- else if .tcpSocket }} | ||
| tcpSocket: | ||
| {{- if .tcpSocket.host }} | ||
| host: {{ .tcpSocket.host }} | ||
| {{- end }} | ||
| port: {{ .tcpSocket.port }} | ||
| {{- else if .grpc }} | ||
| grpc: | ||
| {{- if .grpc.service }} | ||
| service: {{ .grpc.service }} | ||
| {{- end }} | ||
| port: {{ .grpc.port }} | ||
| {{- else }} | ||
| httpGet: | ||
| path: {{ .httpGet.path | default "/health" }} | ||
| port: {{ .httpGet.port | default 8000 }} | ||
| {{- if .httpGet.httpHeaders }} | ||
| httpHeaders: {{- range .httpGet.httpHeaders }} | ||
| - name: {{ .name }} | ||
| value: {{ .value }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if .httpGet.host }} | ||
| host: {{ .httpGet.host }} | ||
| {{- end }} | ||
| {{- if .httpGet.scheme }} | ||
| scheme: {{ .httpGet.scheme }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if .Values.servingEngineSpec.livenessProbe }} | ||
| livenessProbe: | ||
| {{- with .Values.servingEngineSpec.livenessProbe }} | ||
| {{- toYaml . | nindent 2 }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if .Values.servingEngineSpec.readinessProbe }} | ||
| {{- with .Values.servingEngineSpec.livenessProbe }} | ||
| initialDelaySeconds: {{ .initialDelaySeconds | default 15 }} | ||
| periodSeconds: {{ .periodSeconds | default 10 }} | ||
| failureThreshold: {{ .failureThreshold | default 3 }} | ||
| {{- if .timeoutSeconds }} | ||
| timeoutSeconds: {{ .timeoutSeconds }} | ||
| {{- end }} | ||
| {{- if .successThreshold }} | ||
| successThreshold: {{ .successThreshold }} | ||
| {{- end }} | ||
| {{- if .exec }} | ||
| exec: | ||
| command: {{- range .exec.command }} | ||
| - {{.}} {{- end}} | ||
| {{- else if .grpc }} | ||
| grpc: | ||
| {{- if .grpc.service }} | ||
| service: {{ .grpc.service }} | ||
| {{- end }} | ||
| port: {{ .grpc.port }} | ||
| {{- else if .tcpSocket }} | ||
| tcpSocket: | ||
| {{- if .tcpSocket.host }} | ||
| host: {{ .tcpSocket.host }} | ||
| {{- end }} | ||
| port: {{ .tcpSocket.port }} | ||
| {{- else }} | ||
| httpGet: | ||
| path: {{ .httpGet.path | default "/health" }} | ||
| port: {{ .httpGet.port | default 8000 }} | ||
| {{- if .httpGet.httpHeaders }} | ||
| httpHeaders: {{- range .httpGet.httpHeaders }} | ||
| - name: {{ .name }} | ||
| value: {{ .value }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if .httpGet.host }} | ||
| host: {{ .httpGet.host }} | ||
| {{- end }} | ||
| {{- if .httpGet.scheme }} | ||
| scheme: {{ .httpGet.scheme }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if .Values.servingEngineSpec.readinessProbe }} | ||
| readinessProbe: | ||
| {{- with .Values.servingEngineSpec.readinessProbe }} | ||
| {{- toYaml . | nindent 2 }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- with .Values.servingEngineSpec.readinessProbe }} | ||
| initialDelaySeconds: {{ .initialDelaySeconds | default 15 }} | ||
| periodSeconds: {{ .periodSeconds | default 10 }} | ||
| failureThreshold: {{ .failureThreshold | default 3 }} | ||
| {{- if .timeoutSeconds }} | ||
| timeoutSeconds: {{ .timeoutSeconds }} | ||
| {{- end }} | ||
| {{- if .successThreshold }} | ||
| successThreshold: {{ .successThreshold }} | ||
| {{- end }} | ||
| {{- if .exec }} | ||
| exec: | ||
| command: {{- range .exec.command }} | ||
| - {{.}} {{- end}} | ||
| {{- else if .tcpSocket }} | ||
| tcpSocket: | ||
| {{- if .tcpSocket.host }} | ||
| host: {{ .tcpSocket.host }} | ||
| {{- end }} | ||
| port: {{ .tcpSocket.port }} | ||
| {{- else if .grpc }} | ||
| grpc: | ||
| {{- if .grpc.service }} | ||
| service: {{ .grpc.service }} | ||
| {{- end }} | ||
| port: {{ .grpc.port }} | ||
| {{- else }} | ||
| httpGet: | ||
| path: {{ .httpGet.path | default "/health" }} | ||
| port: {{ .httpGet.port | default 8000 }} | ||
| {{- if .httpGet.httpHeaders }} | ||
| httpHeaders: {{- range .httpGet.httpHeaders }} | ||
| - name: {{ .name }} | ||
| value: {{ .value }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if .httpGet.host }} | ||
| host: {{ .httpGet.host }} | ||
| {{- end }} | ||
| {{- if .httpGet.scheme }} | ||
| scheme: {{ .httpGet.scheme }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for startupProbe, livenessProbe, and readinessProbe is nearly identical. This significant code duplication makes the template harder to maintain, as any change needs to be applied in three separate places. To improve maintainability, consider refactoring this logic into a new, single helper template that can be called for each probe type. This would centralize the probe logic, making it easier to read and update in the future.
helm/templates/_helpers.tpl
Outdated
| {{- else if .grpc }} | ||
| grpc: | ||
| {{- if .grpc.service }} | ||
| service: {{ .grpc.service }} | ||
| {{- end }} | ||
| port: {{ .grpc.port }} | ||
| {{- else if .tcpSocket }} | ||
| tcpSocket: | ||
| {{- if .tcpSocket.host }} | ||
| host: {{ .tcpSocket.host }} | ||
| {{- end }} | ||
| port: {{ .tcpSocket.port }} | ||
| {{- else }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order of checking for probe handlers in livenessProbe (exec, grpc, tcpSocket) is different from startupProbe and readinessProbe (exec, tcpSocket, grpc). While Kubernetes only allows one handler per probe, this inconsistency can be confusing and lead to unexpected behavior if a user accidentally specifies multiple handlers. For consistency, the order should be the same across all probes.
{{- else if .tcpSocket }}
tcpSocket:
{{- if .tcpSocket.host }}
host: {{ .tcpSocket.host }}
{{- end }}
port: {{ .tcpSocket.port }}
{{- else if .grpc }}
grpc:
{{- if .grpc.service }}
service: {{ .grpc.service }}
{{- end }}
port: {{ .grpc.port }}
{{- else }}
Signed-off-by: emanuelecassese <emanuele.cassese@gmail.com>
ruizhang0101
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thanks for bringing this up.
For each specific type, could you use toyaml since there are way too many duplication?
Signed-off-by: emanuelecassese <emanuele.cassese@gmail.com>
|
Hi @ruizhang0101, |
ruizhang0101
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the modification! I like the idea of using the probe template. :) Meanwhile, can you remove some unnecessary modifications?
helm/values.yaml
Outdated
| # -- Configuration of the Kubelet http request on the server | ||
| httpGet: | ||
| # -- Path to access on the HTTP server | ||
| # # -- Path to access on the HTTP server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove these unnecessary modifications? Same with line R270, R283, R285
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, sorry about that
Done
Signed-off-by: emanuelecassese <emanuele.cassese@gmail.com>
Signed-off-by: Rui Zhang <51696593+ruizhang0101@users.noreply.github.com>
ruizhang0101
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)) Thanks for the contribution!
FIX #807
Changes Made
Values File Modification:
The serviceEngineSpec.probe.httpGet section in the values file has been commented
Added equivalent values to the template defaults to prevent the httpGet field from being automatically included in the deployment template.
Helper File Update:
Enhanced the define.probes in the helpers file.
Attempted to accommodate all possible fields to closely align with the Kubernetes probe definitions.