Skip to content

Commit

Permalink
use retry modules
Browse files Browse the repository at this point in the history
  • Loading branch information
kunmingg committed Nov 20, 2018
1 parent f670e84 commit 098fea6
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions testing/test_deploy_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import google.auth.iam
import google.oauth2.credentials
import google.oauth2.service_account
from retrying import retry

FILE_PATH = os.path.dirname(os.path.abspath(__file__))
SSL_DIR = os.path.join(FILE_PATH, "sslcert")
Expand Down Expand Up @@ -139,17 +140,18 @@ def insert_ssl_cert(args):
except Exception:
logging.warning("ssl cert for %s doesn't exist in gcs" % args.mode)
return True
for i in range(5):
try:
util_run(("gcloud container clusters get-credentials %s --zone %s --project %s" %
(args.deployment, args.zone, args.project)).split(' '))
util_run(("kubectl create -f %s" % SSL_DIR).split(' '))
except Exception as e:
logging.error(e)
sleep(5)
continue
return True
return False
try:
create_secret(args)
except Exception as e:
logging.error(e)
return False
return True

@retry(wait_fixed=2000, stop_max_delay=15000)
def create_secret(args):
util_run(("gcloud container clusters get-credentials %s --zone %s --project %s" %
(args.deployment, args.zone, args.project)).split(' '))
util_run(("kubectl create -f %s" % SSL_DIR).split(' '))

def check_deploy_status(args):
logging.info("check deployment status")
Expand Down

0 comments on commit 098fea6

Please sign in to comment.