Skip to content

Instantly share code, notes, and snippets.

@zdw
Created January 23, 2020 19:10
Show Gist options
  • Save zdw/e2e6cd42aaf100bf57430ee1bde3a0d5 to your computer and use it in GitHub Desktop.
Save zdw/e2e6cd42aaf100bf57430ee1bde3a0d5 to your computer and use it in GitHub Desktop.
lf/global-jjb/shell $ git review
remote: error: branch refs/publish/master/jobcosterrorhandling:
remote: You need 'Create' rights to create new references.
remote: User: zdw
remote: Contact an administrator to fix the permissions
remote: Processing changes: refs: 1, done
To ssh://gerrit.linuxfoundation.org:29418/releng/global-jjb.git
! [remote rejected] HEAD -> refs/publish/master/jobcosterrorhandling (prohibited by Gerrit: not permitted: create)
error: failed to push some refs to 'ssh://[email protected]:29418/releng/global-jjb.git'
@zdw
Copy link
Author

zdw commented Jan 23, 2020

The actual change is minor:

lf/global-jjb/shell $ git diff gerrit/master
diff --git a/shell/job-cost.sh b/shell/job-cost.sh
index 5bd61be..9cbc716 100644
--- a/shell/job-cost.sh
+++ b/shell/job-cost.sh
@@ -8,7 +8,7 @@
 # which accompanies this distribution, and is available at
 # http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
-echo "---> build-cost.sh"
+echo "---> job-cost.sh"
 
 set -euf -o pipefail
 
@@ -49,8 +49,16 @@ echo "INFO: Retrieving Pricing Info for: $instance_type"
 url="https://pricing.vexxhost.net/v1/pricing/$instance_type/cost?seconds=$uptime"
 json_block=$(curl -s "$url")
 
-cost=$(jq .cost <<< "$json_block")
-resource=$(jq .resource <<< "$json_block" | tr -d '"')
+if jq <<< "$json_block"
+then
+  cost=$(jq .cost <<< "$json_block")
+  resource=$(jq .resource <<< "$json_block" | tr -d '"')
+else
+  echo "ERROR: EC2 pricing returned invalid json"
+  cost=0
+  resource=0
+fi
+
 
 # Archive the cost date
 mkdir -p "$WORKSPACE/archives/cost"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment