Skip to content

Commit

Permalink
Added optional param replicas (kubeflow#122)
Browse files Browse the repository at this point in the history
* Added optional param replicas

function wait_for_deployment may now check specified number of replicas running

* Fix typo

* Start comment with capital letter
  • Loading branch information
Maerville authored and Ankush Agarwal committed May 10, 2018
1 parent f611e5c commit 314b1f3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions py/kubeflow/testing/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,15 @@ def configure_kubectl(project, zone, cluster_name):
run(["gcloud", "--project=" + project, "container",
"clusters", "--zone=" + zone, "get-credentials", cluster_name])

def wait_for_deployment(api_client, namespace, name, timeout_minutes=2):
def wait_for_deployment(api_client, namespace, name, timeout_minutes=2, replicas=1):
"""Wait for deployment to be ready.
Args:
api_client: K8s api client to use.
namespace: The name space for the deployment.
name: The name of the deployment.
timeout_minutes: Timeout interval in minutes.
replicas: Number of replicas that must be running.
Returns:
deploy: The deploy object describing the deployment.
Expand All @@ -256,7 +257,7 @@ def wait_for_deployment(api_client, namespace, name, timeout_minutes=2):

while datetime.datetime.now() < end_time:
deploy = ext_client.read_namespaced_deployment(name, namespace)
if deploy.status.ready_replicas >= 1:
if deploy.status.ready_replicas >= replicas:
logging.info("Deployment %s in namespace %s is ready", name, namespace)
return deploy
logging.info("Waiting for deployment %s in namespace %s", name, namespace)
Expand Down

0 comments on commit 314b1f3

Please sign in to comment.