Copilot commented on code in PR #17946: URL: https://github.com/apache/pinot/pull/17946#discussion_r2978870650
########## helm/pinot/templates/zookeeper/statefulset.yaml: ########## @@ -0,0 +1,201 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +{{- if .Values.zookeeper.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "pinot.zookeeper.fullname" . }} + namespace: {{ include "pinot.namespace" . }} + labels: + {{- include "pinot.zookeeperLabels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "pinot.zookeeperMatchLabels" . | nindent 6 }} + serviceName: {{ include "pinot.zookeeper.headless" . }} + replicas: {{ .Values.zookeeper.replicaCount }} + updateStrategy: + type: RollingUpdate + podManagementPolicy: Parallel + template: + metadata: + labels: + {{- include "pinot.zookeeperLabels" . | nindent 8 }} + {{- with .Values.zookeeper.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} + serviceAccountName: {{ include "pinot.serviceAccountName" . }} + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.zookeeper.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.zookeeper.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.zookeeper.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.zookeeper.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: zookeeper + image: "{{ .Values.zookeeper.image.repository }}:{{ .Values.zookeeper.image.tag }}" + imagePullPolicy: {{ .Values.zookeeper.image.pullPolicy }} + {{- with .Values.zookeeper.containerSecurityContext }} + securityContext: + {{- toYaml . | nindent 10 }} + {{- end }} + env: + - name: ZOO_SERVERS + value: {{ include "pinot.zookeeper.servers" . | quote }} + - name: ZOO_TICK_TIME + value: {{ .Values.zookeeper.tickTime | quote }} + - name: ZOO_INIT_LIMIT + value: {{ .Values.zookeeper.initLimit | quote }} + - name: ZOO_SYNC_LIMIT + value: {{ .Values.zookeeper.syncLimit | quote }} + - name: ZOO_MAX_CLIENT_CNXNS + value: {{ .Values.zookeeper.maxClientCnxns | quote }} + - name: ZOO_AUTOPURGE_PURGE_INTERVAL + value: {{ .Values.zookeeper.autopurge.purgeInterval | quote }} + - name: ZOO_AUTOPURGE_SNAP_RETAIN_COUNT + value: {{ .Values.zookeeper.autopurge.snapRetainCount | quote }} + - name: JVMFLAGS + value: "-Xmx{{ .Values.zookeeper.heapSize }}m -Xms{{ .Values.zookeeper.heapSize }}m {{ .Values.zookeeper.jvmFlags }}" + - name: ZOO_4LW_COMMANDS_WHITELIST + value: {{ .Values.zookeeper.fourLetterWordsWhitelist | quote }} + - name: ZOO_ADMINSERVER_ENABLED + value: {{ .Values.zookeeper.adminServer.enabled | quote }} + {{- if .Values.zookeeper.adminServer.enabled }} + - name: ZOO_ADMINSERVER_PORT + value: {{ .Values.zookeeper.adminServer.port | quote }} + {{- end }} + {{- with .Values.zookeeper.extraEnv }} + {{- toYaml . | nindent 10 }} + {{- end }} + command: + - bash + - -c + - | + # The official ZooKeeper image uses 1-based IDs, but pod-index is 0-based + HOST=$(hostname -s) + if [[ $HOST =~ (.*)-([0-9]+)$ ]]; then + export ZOO_MY_ID=$(( ${BASH_REMATCH[2]} + 1 )) + else + echo "Failed to extract ordinal from hostname $HOST" + exit 1 + fi + exec /docker-entrypoint.sh zkServer.sh start-foreground + ports: + - name: client + containerPort: {{ .Values.zookeeper.port }} + - name: follower + containerPort: {{ .Values.zookeeper.followerPort }} + - name: election + containerPort: {{ .Values.zookeeper.electionPort }} + {{- if .Values.zookeeper.adminServer.enabled }} + - name: admin + containerPort: {{ .Values.zookeeper.adminServer.port }} + {{- end }} + {{- if .Values.zookeeper.probes.livenessEnabled }} + livenessProbe: + exec: + command: + - bash + - -c + - echo ruok | nc -w {{ .Values.zookeeper.probes.liveness.timeoutSeconds }} localhost {{ .Values.zookeeper.port }} | grep imok + initialDelaySeconds: {{ .Values.zookeeper.probes.liveness.initialDelaySeconds }} + periodSeconds: {{ .Values.zookeeper.probes.liveness.periodSeconds }} + timeoutSeconds: {{ .Values.zookeeper.probes.liveness.timeoutSeconds }} + failureThreshold: {{ .Values.zookeeper.probes.liveness.failureThreshold }} + {{- end }} + {{- if .Values.zookeeper.probes.readinessEnabled }} + readinessProbe: + exec: + command: + - bash + - -c + - echo ruok | nc -w {{ .Values.zookeeper.probes.readiness.timeoutSeconds }} localhost {{ .Values.zookeeper.port }} | grep imok + initialDelaySeconds: {{ .Values.zookeeper.probes.readiness.initialDelaySeconds }} + periodSeconds: {{ .Values.zookeeper.probes.readiness.periodSeconds }} + timeoutSeconds: {{ .Values.zookeeper.probes.readiness.timeoutSeconds }} + failureThreshold: {{ .Values.zookeeper.probes.readiness.failureThreshold }} + {{- end }} Review Comment: Both probes depend on `nc` being present in the ZooKeeper image. The official `zookeeper:3.9.3` image does not guarantee `netcat` availability, so probes may fail continuously and cause restarts/unready pods. Recommended fix: implement the `ruok` check without external utilities (e.g., bash `/dev/tcp` socket) or switch to a probe method that is guaranteed to exist in the image. ########## helm/pinot/templates/zookeeper/statefulset.yaml: ########## @@ -0,0 +1,201 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +{{- if .Values.zookeeper.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "pinot.zookeeper.fullname" . }} + namespace: {{ include "pinot.namespace" . }} + labels: + {{- include "pinot.zookeeperLabels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "pinot.zookeeperMatchLabels" . | nindent 6 }} + serviceName: {{ include "pinot.zookeeper.headless" . }} + replicas: {{ .Values.zookeeper.replicaCount }} + updateStrategy: + type: RollingUpdate + podManagementPolicy: Parallel + template: + metadata: + labels: + {{- include "pinot.zookeeperLabels" . | nindent 8 }} + {{- with .Values.zookeeper.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} + serviceAccountName: {{ include "pinot.serviceAccountName" . }} + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.zookeeper.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.zookeeper.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.zookeeper.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.zookeeper.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: zookeeper + image: "{{ .Values.zookeeper.image.repository }}:{{ .Values.zookeeper.image.tag }}" + imagePullPolicy: {{ .Values.zookeeper.image.pullPolicy }} + {{- with .Values.zookeeper.containerSecurityContext }} + securityContext: + {{- toYaml . | nindent 10 }} + {{- end }} + env: + - name: ZOO_SERVERS + value: {{ include "pinot.zookeeper.servers" . | quote }} + - name: ZOO_TICK_TIME + value: {{ .Values.zookeeper.tickTime | quote }} + - name: ZOO_INIT_LIMIT + value: {{ .Values.zookeeper.initLimit | quote }} + - name: ZOO_SYNC_LIMIT + value: {{ .Values.zookeeper.syncLimit | quote }} + - name: ZOO_MAX_CLIENT_CNXNS + value: {{ .Values.zookeeper.maxClientCnxns | quote }} + - name: ZOO_AUTOPURGE_PURGE_INTERVAL + value: {{ .Values.zookeeper.autopurge.purgeInterval | quote }} + - name: ZOO_AUTOPURGE_SNAP_RETAIN_COUNT + value: {{ .Values.zookeeper.autopurge.snapRetainCount | quote }} + - name: JVMFLAGS + value: "-Xmx{{ .Values.zookeeper.heapSize }}m -Xms{{ .Values.zookeeper.heapSize }}m {{ .Values.zookeeper.jvmFlags }}" Review Comment: This always injects `-Xmx/-Xms` derived from `heapSize` and then appends `jvmFlags`. If users include their own `-Xmx/-Xms` in `zookeeper.jvmFlags`, the resulting JVM options will be duplicated/ambiguous. A more robust pattern is to (a) allow `heapSize` to be empty/null and only add `-Xmx/-Xms` when set, or (b) make `jvmFlags` the single source of truth and document how to set heap there. ```suggestion value: '{{- if .Values.zookeeper.heapSize }}-Xmx{{ .Values.zookeeper.heapSize }}m -Xms{{ .Values.zookeeper.heapSize }}m {{- end }}{{ .Values.zookeeper.jvmFlags }}' ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
