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://zdw@gerrit.linuxfoundation.org:29418/releng/global-jjb.git'
@zdw
Copy link
Author

zdw commented Jan 23, 2020

My commit looks like:

/lf/global-jjb/shell $ git log
commit 461d0a22fa883172dc3626fc5677d18991bda862 (HEAD -> jobcosterrorhandling)
Author: Zack Williams <zdw@opennetworking.org>
Date:   Thu Jan 23 11:42:17 2020 -0700

    Error handling for AWS in job-cost.sh
    
    - API being used may return a 404 which doesn't parse properly in jq,
      which fails otherwise working builds.
    - Report correct name when script is run
    
    Change-Id: I375b4a16588b1ab12e4aa7da0e37b351ed52f64c
    Signed-off-by: Zack Williams <zdw@opennetworking.org>

@zdw
Copy link
Author

zdw commented Jan 23, 2020

Same error with bare git commands (not review):

lf/global-jjb/shell $ git branch -v
* jobcosterrorhandling ad24ed5 Error handling for AWS in job-cost.sh
  master               93980c8 DO NOT create a virtualenv in ~/.local
lf/global-jjb/shell $ git push gerrit HEAD:refs/publish/master
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 665 bytes | 665.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3)
remote: error: branch refs/publish/master:
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 (prohibited by Gerrit: not permitted: create)
error: failed to push some refs to 'ssh://zdw@gerrit.linuxfoundation.org: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