From 7759225aaf46aa177372104a25dee7543fb24e98 Mon Sep 17 00:00:00 2001 From: harishspqr Date: Thu, 4 Apr 2019 06:56:50 -0700 Subject: [PATCH] Temporary workaround a data issue in boskos service (#699) --- hack/checkout_account.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/hack/checkout_account.py b/hack/checkout_account.py index cf215b3fd1..d1dbaba741 100755 --- a/hack/checkout_account.py +++ b/hack/checkout_account.py @@ -27,18 +27,26 @@ RESOURCE_TYPE = "aws-account" USER = "cluster-api-provider-aws" -if __name__ == "__main__": - conn = httplib.HTTPConnection(BOSKOS_HOST) - +def post_request(conn, input_state = "free"): conn.request("POST", "/acquire?%s" % urllib.urlencode({ 'type': RESOURCE_TYPE, 'owner': USER, - 'state': 'free', + 'state': input_state, 'dest': 'busy', }) ) - resp = conn.getresponse() + return conn.getresponse() + +if __name__ == "__main__": + conn = httplib.HTTPConnection(BOSKOS_HOST) + + resp = post_request(conn) + # we're working around an issue with the data in boskos. + # We'll remove the code that tries both free and clean once all the data is good. + if resp.status == 404: + resp = post_request(conn, "clean") + if resp.status != 200: sys.exit("Got invalid response %d: %s" % (resp.status, resp.reason)) @@ -47,4 +55,4 @@ print 'export BOSKOS_RESOURCE_NAME="%s";' % body['name'] print 'export AWS_ACCESS_KEY_ID="%s";' % body['userdata']['access-key-id'] print 'export AWS_SECRET_ACCESS_KEY="%s";' % body['userdata']['secret-access-key'] - + \ No newline at end of file