Skip to content

Commit 3b6d52d

Browse files
committed
Check exit code of zk format
1 parent 701d97f commit 3b6d52d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

rust/operator/src/container.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,19 @@ impl ContainerConfig {
546546
r###"
547547
echo "Attempt to format ZooKeeper..."
548548
if [[ "0" -eq "$(echo $POD_NAME | sed -e 's/.*-//')" ]] ; then
549-
{hadoop_home}/bin/hdfs zkfc -formatZK -nonInteractive || true
549+
set +e
550+
{hadoop_home}/bin/hdfs zkfc -formatZK -nonInteractive
551+
EXITCODE=$?
552+
set -e
553+
if [[ $EXITCODE -eq 0 ]]; then
554+
echo "Successfully formatted"
555+
elif [[ $EXITCODE -eq 2 ]]; then
556+
echo "ZNode already existed, did nothing"
557+
else
558+
echo "Zookeeper format failed with exit code $EXITCODE"
559+
exit $EXITCODE
560+
fi
561+
550562
else
551563
echo "ZooKeeper already formatted!"
552564
fi

0 commit comments

Comments
 (0)