Skip to content

Commit 0414030

Browse files
committed
K8SPXC-1647: Use extended exit codes for garbd
1 parent 3e65dba commit 0414030

File tree

2 files changed

+32
-54
lines changed

2 files changed

+32
-54
lines changed

build/backup/backup.sh

100644100755
Lines changed: 32 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -62,57 +62,38 @@ function request_streaming() {
6262
set +o errexit
6363
log 'INFO' 'Garbd was started'
6464
garbd \
65-
--address "gcomm://$NODE_NAME.$PXC_SERVICE?gmcast.listen_addr=tcp://0.0.0.0:4567" \
66-
--donor "$NODE_NAME" \
67-
--group "$PXC_SERVICE" \
68-
--options "$GARBD_OPTS" \
69-
--sst "xtrabackup-v2:$LOCAL_IP:4444/xtrabackup_sst//1" \
70-
--recv-script="/opt/percona/backup/run_backup.sh" 2>&1 | tee /tmp/garbd.log
71-
72-
local sst_info_path
73-
if [[ -n $S3_BUCKET || -n $AZURE_CONTAINER_NAME ]]; then
74-
sst_info_path="/tmp/${SST_INFO_NAME}"
75-
else
76-
sst_info_path="${BACKUP_DIR}/${SST_INFO_NAME}"
77-
fi
78-
79-
MYSQL_VERSION=$(parse_ini 'mysql-version' "$sst_info_path")
80-
if ! check_for_version "$MYSQL_VERSION" '8.0.0'; then
81-
if grep 'State transfer request failed' /tmp/garbd.log; then
82-
exit 1
83-
fi
84-
if grep 'WARN: Protocol violation. JOIN message sender ... (garb) is not in state transfer' /tmp/garbd.log; then
85-
exit 1
86-
fi
87-
if grep 'WARN: Rejecting JOIN message from ... (garb): new State Transfer required.' /tmp/garbd.log; then
88-
exit 1
89-
fi
90-
if grep 'INFO: Shifting CLOSED -> DESTROYED (TO: -1)' /tmp/garbd.log; then
91-
exit 1
92-
fi
93-
if ! grep 'INFO: Sending state transfer request' /tmp/garbd.log; then
94-
exit 1
95-
fi
96-
else
97-
if grep 'Will never receive state. Need to abort' /tmp/garbd.log; then
98-
exit 1
99-
fi
100-
101-
if grep 'Donor is no longer in the cluster, interrupting script' /tmp/garbd.log; then
102-
exit 1
103-
elif grep 'failed: Invalid argument' /tmp/garbd.log; then
104-
exit 1
105-
fi
106-
fi
107-
108-
if [ -f '/tmp/backup-is-completed' ]; then
109-
log 'INFO' 'Backup was finished successfully'
110-
exit 0
111-
fi
112-
113-
log 'ERROR' 'Backup was finished unsuccessful'
114-
115-
exit 1
65+
--address "gcomm://$NODE_NAME.$PXC_SERVICE?gmcast.listen_addr=tcp://0.0.0.0:4567" \
66+
--donor "$NODE_NAME" \
67+
--group "$PXC_SERVICE" \
68+
--options "$GARBD_OPTS" \
69+
--sst "xtrabackup-v2:$LOCAL_IP:4444/xtrabackup_sst//1" \
70+
--extended-exit-codes \
71+
--wait-for-recv-script-exit \
72+
--recv-script="/usr/bin/run_backup.sh"
73+
GARBD_EXIT_CODE=$?
74+
75+
case ${GARBD_EXIT_CODE} in
76+
0)
77+
log 'INFO' 'Backup was finished successfully'
78+
exit 0
79+
;;
80+
100)
81+
log 'ERROR' 'Backup was unsuccessful: Generic failure'
82+
exit 1
83+
;;
84+
101)
85+
log 'ERROR' 'Backup was unsuccessful: Donor disappeared'
86+
exit 1
87+
;;
88+
102)
89+
log 'ERROR' 'Backup was unsuccessful: SST request failure'
90+
exit 1
91+
;;
92+
*)
93+
log 'ERROR' "Backup was unsuccessful: garbd exited with ${GARBD_EXIT_CODE}"
94+
exit 1
95+
;;
96+
esac
11697
}
11798

11899
# TODO: should i remove it?

build/backup/run_backup.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ backup_volume() {
9696
log 'INFO' "Socat(2) returned $?"
9797
fi
9898

99-
trap '' 15
10099
stat xtrabackup.stream
101100
if (($(stat -c%s xtrabackup.stream) < 5000000)); then
102101
log 'ERROR' 'Backup is empty'
@@ -138,8 +137,6 @@ backup_s3() {
138137
| (grep -v "error: http request failed: Couldn't resolve host name" || exit 1)
139138
fi
140139

141-
trap '' 15
142-
143140
# shellcheck disable=SC2086
144141
aws $AWS_S3_NO_VERIFY_SSL s3 ls "s3://$S3_BUCKET/$S3_BUCKET_PATH.md5"
145142
# shellcheck disable=SC2086

0 commit comments

Comments
 (0)