Fix ceph unified CLI exit code

When a ceph command is executed, the exit code is always "0"
regardless of whether the command was successful or not.
This happens because in the CLI, the command that is executed
within the toolbox pod is not the last one, so it always returns
the last command, which is always 0.

So to solve this problem, the exit code of the command sent to
the toolbox pod is checked and stored, and if it is non-zero,
the execution is terminated there.

Test Plan:
- PASS: AIO-SX with rook ceph backend configured
- PASS: Run 'ceph -s' command and check exit code
- PASS: Run 'ceph test-123' command and check exit code

Story: 2011066
Task: 51021

Change-Id: I0b4c08da57c4c54833b7d75615215b7840275ce4
Signed-off-by: Erickson Silva de Oliveira <Erickson.SilvadeOliveira@windriver.com>
This commit is contained in:
Erickson Silva de Oliveira 2024-09-11 16:24:48 -03:00
parent 63894e875a
commit aa7ffb7038

View File

@ -118,11 +118,18 @@ if [ -f "${NODE_ROOK_CONFIGURED_FLAG}" ]; then
kubectl --kubeconfig ${KUBE_CONFIG} exec \
-n ${ROOK_CEPH_NAMESPACE} deploy/${ROOK_CEPH_TOOLS_NAME} -- \
bash -c "cd ${CMD_DIR} && /usr/bin/ceph ${ARGS}"
RETURN_CODE=$?
if [ ${RETURN_CODE} -ne 0 ]; then
exit ${RETURN_CODE}
fi
if [[ $OUTPUT_ARG ]]; then
kubectl --kubeconfig ${KUBE_CONFIG} cp -n ${ROOK_CEPH_NAMESPACE} \
"${ROOK_CEPH_TOOLS_POD}":"${OUTPUT_REMOTE:1}" "${OUTPUT_ARG}"
RETURN_CODE=$?
fi
exit ${RETURN_CODE}
fi
elif [ -f "${NODE_CEPH_CONFIGURED_FLAG}" ]; then
if [ "${COMPLETION}" = true ]; then