Skip to content

Commit

Permalink
*: replace expr commond to bc radondb#725
Browse files Browse the repository at this point in the history
  • Loading branch information
acekingke committed Nov 2, 2022
1 parent e7a7c52 commit 6fc2fe6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.sidecar
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN set -ex; \
ARG XTRABACKUP_PKG=percona-xtrabackup-24
RUN set -ex; \
apt-get update; \
apt-get install -y --no-install-recommends gnupg2 wget lsb-release curl; \
apt-get install -y --no-install-recommends gnupg2 wget lsb-release curl bc; \
wget -P /tmp --no-check-certificate https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb; \
dpkg -i /tmp/percona-release_latest.$(lsb_release -sc)_all.deb; \
apt-get update; \
Expand Down
2 changes: 1 addition & 1 deletion backup/syncer/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (s *jobSyncer) ensurePodSpec(in corev1.PodSpec) corev1.PodSpec {
s.backup.Namespace, s.backup.GetNameForJob(), backupToDir, DateTime)
// Add the check DiskUsage
// use expr because shell cannot compare float number
checkUsage := `[ $(expr $(df /backup|awk 'NR>1 {print $4}') \> $(du /backup |awk 'END {if (NR > 1) {print $1 /(NR-1)} else print 0}')) -eq '1' ] || { echo disk available may be too small; exit 1;};`
checkUsage := `[ $(echo "$(df /backup|awk 'NR>1 {print $4}') > $(du /backup |awk 'END {if (NR > 1) {print $1 /(NR-1)} else print 0}')"|bc) -eq '1' ] || { echo disk available may be too small; exit 1;};`
in.Containers[0].Args = []string{
checkUsage + fmt.Sprintf("mkdir -p /backup/%s;"+
"curl --user $BACKUP_USER:$BACKUP_PASSWORD %s/download|xbstream -x -C /backup/%s; err1=${PIPESTATUS[0]};"+
Expand Down

0 comments on commit 6fc2fe6

Please sign in to comment.