Tejaskriya commented on code in PR #20:
URL: https://github.com/apache/ozone-helm-charts/pull/20#discussion_r2453424143


##########
charts/ozone/templates/om/om-statefulset.yaml:
##########
@@ -51,9 +53,66 @@ spec:
           {{- with .Values.om.command }}
           command: {{- tpl (toYaml .) $ | nindent 12 }}
           {{- end }}
-          {{- with .Values.om.args }}
-          args: {{- tpl (toYaml .) $ | nindent 12 }}
-          {{- end }}
+          args:
+            - sh
+            - -c
+            - |
+              set -e
+              HELM_MANAGER_PATH="{{ .Values.om.persistence.path }}{{ 
.Values.helm.persistence.path }}"
+              HELM_MANAGER_BOOTSTRAPPED_FILE="$HELM_MANAGER_PATH/bootstrapped"
+              {{- $flattenedArgs := join " " $.Values.om.args }}
+              {{- if and (.Values.om.persistence.enabled) (gt (len $bnodes) 0) 
}}
+                joinArr() {
+                  local IFS=","
+                  echo "$*"
+                }
+                bootstrap_finalizer() {
+                  echo "Init bootrap finalizer process..."
+                  while true; do
+                    IFS= read -r line;
+                    echo "$line"
+                      if echo "$line" | grep -q "Successfully bootstrapped OM 
$HOSTNAME and joined the Ratis group"; then
+                      echo "$HOSTNAME was successfully bootstrapped!"
+                      mkdir -p "$HELM_MANAGER_PATH"
+                      touch "$HELM_MANAGER_BOOTSTRAPPED_FILE"
+                      break;
+                    fi
+                  done
+                  echo "Bootstrap finalizer process finished!"
+                  exit 0
+                }
+                bootstrapHosts="{{ join "," $bnodes }}"
+                echo "Need to handle bootstrap for nodes $bootstrapHosts"
+                IFS=',' read -r -a hostArray <<< "$bootstrapHosts"
+                doBootstrap=false
+                nodesConfigOverwriteList=()
+                for host in "${hostArray[@]}"; do
+                  if [[ "$host" == "$HOSTNAME" ]]; then
+                    doBootstrap=true
+                    activeNodesConfig="{{ join "," $activeNodes }}"
+                    IFS=',' read -r -a overwriteArray <<< "$activeNodesConfig"
+                    for overwriteHost in "${overwriteArray[@]}"; do
+                      nodesConfigOverwriteList+=("$overwriteHost")
+                      if [[ "$overwriteHost" == "$HOSTNAME" ]]; then
+                        break;
+                      fi
+                    done
+                    break
+                  fi
+                done
+                if [ "$doBootstrap" = true ] && [ ! -f 
"$HELM_MANAGER_BOOTSTRAPPED_FILE" ]; then
+                  echo "$HOSTNAME must be started with bootstrap arg!"
+                  overwriteCmd="$(joinArr "${nodesConfigOverwriteList[@]}")"
+                  echo "Bootstrapping node config for this node: $overwriteCmd"
+                  exec {{ printf "%s --set ozone.om.nodes.cluster1=" 
$flattenedArgs }}"$overwriteCmd" --bootstrap | bootstrap_finalizer

Review Comment:
   It is better parameterized, I have made the change



-- 
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]

Reply via email to