Skip to content

Commit

Permalink
Check exit code of zk format
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer committed May 31, 2023
1 parent 701d97f commit 3b6d52d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion rust/operator/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,19 @@ impl ContainerConfig {
r###"
echo "Attempt to format ZooKeeper..."
if [[ "0" -eq "$(echo $POD_NAME | sed -e 's/.*-//')" ]] ; then
{hadoop_home}/bin/hdfs zkfc -formatZK -nonInteractive || true
set +e
{hadoop_home}/bin/hdfs zkfc -formatZK -nonInteractive
EXITCODE=$?
set -e
if [[ $EXITCODE -eq 0 ]]; then
echo "Successfully formatted"
elif [[ $EXITCODE -eq 2 ]]; then
echo "ZNode already existed, did nothing"
else
echo "Zookeeper format failed with exit code $EXITCODE"
exit $EXITCODE
fi
else
echo "ZooKeeper already formatted!"
fi
Expand Down

0 comments on commit 3b6d52d

Please sign in to comment.