From 5508e49ef5876c2c5e9e5ee60a0f2f1dbd217441 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Fri, 3 Jun 2016 10:42:38 -0700 Subject: [PATCH] Use bash ranges "{1..3}" instead of "$(seq 1 3)". --- cluster/aws/util.sh | 2 +- cluster/gce/util.sh | 2 +- cluster/gke/util.sh | 2 +- cluster/photon-controller/util.sh | 2 +- examples/k8petstore/k8petstore-loadbalancer.sh | 4 ++-- examples/k8petstore/k8petstore-nodeport.sh | 2 +- examples/k8petstore/k8petstore.sh | 2 +- hack/jenkins/e2e-runner.sh | 2 +- hack/jenkins/upload-to-gcs.sh | 4 ++-- hack/make-rules/test-cmd.sh | 4 ++-- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cluster/aws/util.sh b/cluster/aws/util.sh index 747121bd9bb..f0a881114b7 100755 --- a/cluster/aws/util.sh +++ b/cluster/aws/util.sh @@ -1547,7 +1547,7 @@ function ssh-to-node { local ip=$(get_ssh_hostname ${node}) - for try in $(seq 1 5); do + for try in {1..5}; do if ssh -oLogLevel=quiet -oConnectTimeout=30 -oStrictHostKeyChecking=no -i "${AWS_SSH_KEY}" ${SSH_USER}@${ip} "echo test > /dev/null"; then break fi diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index 5db3df6d27b..ce15cc9c50b 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -1533,7 +1533,7 @@ function ssh-to-node { local node="$1" local cmd="$2" # Loop until we can successfully ssh into the box - for try in $(seq 1 5); do + for try in {1..5}; do if gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --ssh-flag="-o ConnectTimeout=30" --project "${PROJECT}" --zone="${ZONE}" "${node}" --command "echo test > /dev/null"; then break fi diff --git a/cluster/gke/util.sh b/cluster/gke/util.sh index 80e67740574..2cb3049266e 100755 --- a/cluster/gke/util.sh +++ b/cluster/gke/util.sh @@ -339,7 +339,7 @@ function ssh-to-node() { local node="$1" local cmd="$2" # Loop until we can successfully ssh into the box - for try in $(seq 1 5); do + for try in {1..5}; do if gcloud compute ssh --ssh-flag="-o LogLevel=quiet" --ssh-flag="-o ConnectTimeout=30" --project "${PROJECT}" --zone="${ZONE}" "${node}" --command "echo test > /dev/null"; then break fi diff --git a/cluster/photon-controller/util.sh b/cluster/photon-controller/util.sh index 6473a4e36ef..a6e769f71ff 100755 --- a/cluster/photon-controller/util.sh +++ b/cluster/photon-controller/util.sh @@ -284,7 +284,7 @@ function pc-create-vm { # Wait for the VM to be started and connected to the network have_network=0 - for i in $(seq 120); do + for i in {1..120}; do # photon -n vm networks print several fields: # NETWORK MAC IP GATEWAY CONNECTED? # We wait until CONNECTED is True diff --git a/examples/k8petstore/k8petstore-loadbalancer.sh b/examples/k8petstore/k8petstore-loadbalancer.sh index dccfc8c5838..5e8e4d09c95 100755 --- a/examples/k8petstore/k8petstore-loadbalancer.sh +++ b/examples/k8petstore/k8petstore-loadbalancer.sh @@ -230,7 +230,7 @@ $kubectl create -f bps-load-gen-rc.json --namespace=$NS #This script assumes the cloud provider is able to create a load balancer. If this not the case, you may want to check out other ways to make the frontend service accessible from outside (https://github.com/kubernetes/kubernetes/blob/master/docs/services.md#external-services) function getIP { echo "Waiting up to 1 min for a public IP to be assigned by the cloud provider..." - for i in `seq 1 20`; + for i in {1..20}; do PUBLIC_IP=$($kubectl get services/frontend --namespace=$NS -o template --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}") if [ -n "$PUBLIC_IP" ]; then @@ -249,7 +249,7 @@ function pollfor { pass_http=0 ### Test HTTP Server comes up. - for i in `seq 1 150`; + for i in {1..150}; do ### Just testing that the front end comes up. Not sure how to test total entries etc... (yet) echo "Trying curl ... $PUBLIC_IP:3000 , attempt $i . expect a few failures while pulling images... " diff --git a/examples/k8petstore/k8petstore-nodeport.sh b/examples/k8petstore/k8petstore-nodeport.sh index e7442f9fe65..2a4dd809696 100755 --- a/examples/k8petstore/k8petstore-nodeport.sh +++ b/examples/k8petstore/k8petstore-nodeport.sh @@ -267,7 +267,7 @@ function pollfor { pass_http=0 ### Test HTTP Server comes up. - for i in `seq 1 150`; + for i in {1..150}; do ### Just testing that the front end comes up. Not sure how to test total entries etc... (yet) echo "Trying curl frontend:3000 via $TEST_IP:$NODE_PORT, attempt ${i}. Expect a few failures while pulling images... " diff --git a/examples/k8petstore/k8petstore.sh b/examples/k8petstore/k8petstore.sh index 60eea24d9a3..633cd2a2472 100755 --- a/examples/k8petstore/k8petstore.sh +++ b/examples/k8petstore/k8petstore.sh @@ -233,7 +233,7 @@ function pollfor { pass_http=0 ### Test HTTP Server comes up. - for i in `seq 1 150`; + for i in {1..150}; do ### Just testing that the front end comes up. Not sure how to test total entries etc... (yet) echo "Trying curl ... $PUBLIC_IP:3000 , attempt $i . expect a few failures while pulling images... " diff --git a/hack/jenkins/e2e-runner.sh b/hack/jenkins/e2e-runner.sh index 2d10a71945a..cef0c02f225 100755 --- a/hack/jenkins/e2e-runner.sh +++ b/hack/jenkins/e2e-runner.sh @@ -236,7 +236,7 @@ fi if [[ -n "${CLOUDSDK_BUCKET:-}" ]]; then # Retry the download a few times to mitigate transient server errors and # race conditions where the bucket contents change under us as we download. - for n in $(seq 3); do + for n in {1..3}; do gsutil -mq cp -r "${CLOUDSDK_BUCKET}" ~ && break || sleep 1 # Delete any temporary files from the download so that we start from # scratch when we retry. diff --git a/hack/jenkins/upload-to-gcs.sh b/hack/jenkins/upload-to-gcs.sh index fcae3a6ef73..77f32e565ab 100755 --- a/hack/jenkins/upload-to-gcs.sh +++ b/hack/jenkins/upload-to-gcs.sh @@ -86,7 +86,7 @@ function upload_version() { fi local -r json_file="${gcs_build_path}/started.json" - for upload_attempt in $(seq 3); do + for upload_attempt in {1..3}; do echo "Uploading version to: ${json_file} (attempt ${upload_attempt})" gsutil -q -h "Content-Type:application/json" cp -a "${gcs_acl}" <( echo "{" @@ -103,7 +103,7 @@ function upload_artifacts_and_build_result() { local -r build_result=$1 echo -n 'Run finished at '; date -d "@${timestamp}" - for upload_attempt in $(seq 3); do + for upload_attempt in {1..3}; do echo "Uploading to ${gcs_build_path} (attempt ${upload_attempt})" echo "Uploading build result: ${build_result}" gsutil -q -h "Content-Type:application/json" cp -a "${gcs_acl}" <( diff --git a/hack/make-rules/test-cmd.sh b/hack/make-rules/test-cmd.sh index aa095f3fd4d..c795e5c4c5c 100755 --- a/hack/make-rules/test-cmd.sh +++ b/hack/make-rules/test-cmd.sh @@ -110,7 +110,7 @@ function kubectl-with-retry() { ERROR_FILE="${KUBE_TEMP}/kubectl-error" preserve_err_file=${PRESERVE_ERR_FILE-false} - for count in $(seq 0 3); do + for count in {0..3}; do kubectl "$@" 2> ${ERROR_FILE} || true if grep -q "the object has been modified" "${ERROR_FILE}"; then kube::log::status "retry $1, error: $(cat ${ERROR_FILE})" @@ -694,7 +694,7 @@ runTests() { ## If the resourceVersion is the same as the one stored in the server, the patch will be applied. # Command # Needs to retry because other party may change the resource. - for count in $(seq 0 3); do + for count in {0..3}; do resourceVersion=$(kubectl get "${kube_flags[@]}" pod valid-pod -o go-template='{{ .metadata.resourceVersion }}') kubectl patch "${kube_flags[@]}" pod valid-pod -p='{"spec":{"containers":[{"name": "kubernetes-serve-hostname", "image": "nginx"}]},"metadata":{"resourceVersion":"'$resourceVersion'"}}' 2> "${ERROR_FILE}" || true if grep -q "the object has been modified" "${ERROR_FILE}"; then