You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/07/17 14:57:10 UTC

[GitHub] marcoabreu commented on a change in pull request #11779: [MXNET-681] Add retry mechanism for the docker build stage

marcoabreu commented on a change in pull request #11779: [MXNET-681] Add retry mechanism for the docker build stage
URL: https://github.com/apache/incubator-mxnet/pull/11779#discussion_r203056320
 
 

 ##########
 File path: ci/build.py
 ##########
 @@ -90,15 +90,33 @@ def build_docker(platform: str, docker_binary: str, registry: str) -> None:
     #
     # This doesn't work with multi head docker files.
     # 
-    cmd = [docker_binary, "build",
-           "-f", get_dockerfile(platform),
-           "--build-arg", "USER_ID={}".format(os.getuid()),
-           "--build-arg", "GROUP_ID={}".format(os.getgid()),
-           "--cache-from", tag,
-           "-t", tag,
-           "docker"]
-    logging.info("Running command: '%s'", ' '.join(cmd))
-    check_call(cmd)
+
+    num_retries = int(os.environ['DOCKER_BUILD_NUM_RETRIES']) if 'DOCKER_BUILD_NUM_RETRIES' in os.environ else 1
+    for i in range(num_retries):
+        logging.info('%d out of %d tries to build the docker image. You can influence this by setting the '
+                     'environment variable "DOCKER_BUILD_NUM_RETRIES"', i + 1, num_retries)
+
+
+        cmd = [docker_binary, "build",
+               "-f", get_dockerfile(platform),
+               "--build-arg", "USER_ID={}".format(os.getuid()),
+               "--build-arg", "GROUP_ID={}".format(os.getgid()),
+               "--cache-from", tag,
+               "-t", tag,
+               "docker"]
+        logging.info("Running command: '%s'", ' '.join(cmd))
+        try:
+            check_call(cmd)
+            # Docker build was successful. Call break to break out of the retry mechanism
+            break
+        except subprocess.CalledProcessError as e:
 
 Review comment:
   Good point, will adjust

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services