Skip to content

Commit c633cfa

Browse files
authored
Merge pull request #630 from github/hao/fix-paralle-cmd
Update parallel command to adapt to changes in 3.11
2 parents 939854d + 23a1190 commit c633cfa

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

.github/workflows/integration-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
janky-token: '${{ secrets.API_AUTH_TOKEN }}'
3838
job-name: '${{ matrix.jankyJobName }}'
3939
branch-name: '${{ env.SOURCE_BRANCH }}'
40+
force : 'false'
4041
# enterprise2 target branch is same as target branch for PR (either master or enterprise-[0-9]*.[0-9]*-release)
4142
envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }},JANKY_ENV_ENTERPRISE2_BRANCH=${{ env.TARGET_BRANCH }}"
4243

@@ -63,5 +64,6 @@ jobs:
6364
janky-token: '${{ secrets.API_AUTH_TOKEN }}'
6465
job-name: '${{ matrix.jankyJobName }}'
6566
branch-name: '${{ env.SOURCE_BRANCH }}'
67+
force : 'false'
6668
# enterprise2 target branch is same as target branch for PR (either master or enterprise-[0-9]*.[0-9]*-release)
6769
envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }},JANKY_ENV_ENTERPRISE2_BRANCH=${{ env.TARGET_BRANCH }}"

share/github-backup-utils/ghe-backup-config

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,24 @@ ghe_parse_remote_version() {
462462
export GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH
463463
}
464464

465+
# In 3.11 we started to install 2 different version parallel(s)
466+
# moreutils parallel and GNU parallel. When gnu parallel is installed,
467+
# it renames moreutils parallel to parallel.moreutils
468+
# set $PARALLEL_CMD envvar to be used in place of parallel commands
469+
ghe_remote_parallel() {
470+
if [ -z "$GHE_REMOTE_VERSION" ]; then
471+
echo "Error: ghe_remote_version_required needs to be invoked before ghe_remote_parallel" 1>&2
472+
exit 1
473+
fi
474+
475+
if [ "$GHE_VERSION_MINOR" -lt 11 ]; then
476+
PARALLEL_CMD="parallel"
477+
else
478+
PARALLEL_CMD="parallel.moreutils"
479+
fi
480+
export PARALLEL_CMD
481+
}
482+
465483
# Parses the <host> part out of a "<host>:<port>" or just "<host>" string.
466484
# This is used primarily to break hostspecs with non-standard ports down for
467485
# rsync commands.

share/github-backup-utils/ghe-restore-pages

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ fi
3535

3636
# Perform a host-check and establish GHE_REMOTE_XXX variables.
3737
ghe_remote_version_required "$GHE_HOSTNAME"
38+
ghe_remote_parallel
3839

3940
# Split host:port into parts
4041
port=$(ssh_port_part "$GHE_HOSTNAME")
@@ -156,7 +157,7 @@ if $CLUSTER; then
156157
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
157158
split -l 1000 $remote_routes_list $remote_tempdir/chunk
158159
chunks=\$(find $remote_tempdir/ -name chunk\*)
159-
parallel -i /bin/sh -c "cat {} | github-env ./bin/dpages-cluster-restore-finalize" -- \$chunks
160+
$PARALLEL_CMD -i /bin/sh -c "cat {} | github-env ./bin/dpages-cluster-restore-finalize" -- \$chunks
160161
EOF
161162
increment-progress-total-count 1
162163
bm_end "$(basename $0) - Finalizing routes"

share/github-backup-utils/ghe-restore-repositories

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ fi
3636

3737
# Perform a host-check and establish GHE_REMOTE_XXX variables.
3838
ghe_remote_version_required "$GHE_HOSTNAME"
39+
ghe_remote_parallel
3940

4041
# Generate SSH config for forwarding
4142
# Split host:port into parts
@@ -210,7 +211,7 @@ if $CLUSTER; then
210211
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
211212
split -l 1000 $remote_to_restore $remote_tempdir/chunk
212213
chunks=\$(find $remote_tempdir/ -name chunk\*)
213-
parallel -i /bin/sh -c "cat {} | github-env ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
214+
$PARALLEL_CMD -i /bin/sh -c "cat {} | github-env ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
214215
EOF
215216
increment-progress-total-count 1
216217
bm_end "$(basename $0) - Finalizing routes"

share/github-backup-utils/ghe-restore-repositories-gist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ fi
3535

3636
# Perform a host-check and establish GHE_REMOTE_XXX variables.
3737
ghe_remote_version_required "$GHE_HOSTNAME"
38+
ghe_remote_parallel
3839

3940
# Generate SSH config for forwarding
4041
# Split host:port into parts
@@ -159,7 +160,7 @@ if $CLUSTER; then
159160
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
160161
split -l 1000 $remote_to_restore $remote_tempdir/chunk
161162
chunks=\$(find $remote_tempdir/ -name chunk\*)
162-
parallel -i /bin/sh -c "cat {} | github-env ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
163+
$PARALLEL_CMD -i /bin/sh -c "cat {} | github-env ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
163164
EOF
164165
increment-progress-total-count 1
165166
bm_end "$(basename $0) - Finalizing routes"

share/github-backup-utils/ghe-restore-storage

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ fi
3939

4040
# Perform a host-check and establish GHE_REMOTE_XXX variables.
4141
ghe_remote_version_required "$GHE_HOSTNAME"
42+
ghe_remote_parallel
4243

4344
# Split host:port into parts
4445
port=$(ssh_port_part "$GHE_HOSTNAME")
@@ -171,7 +172,7 @@ if $CLUSTER; then
171172
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <<EOF
172173
split -l 1000 $remote_routes_list $remote_tempdir/chunk
173174
chunks=\$(find $remote_tempdir/ -name chunk\*)
174-
parallel -i /bin/sh -c "cat {} | github-env ./bin/storage-cluster-restore-finalize" -- \$chunks
175+
$PARALLEL_CMD -i /bin/sh -c "cat {} | github-env ./bin/storage-cluster-restore-finalize" -- \$chunks
175176
EOF
176177
increment-progress-total-count 1
177178
bm_end "$(basename $0) - Finalizing routes"

0 commit comments

Comments
 (0)