From 42ac9c5f1e845fd72ef15510cf30789b0449244d Mon Sep 17 00:00:00 2001 From: Islam AbdelRahman Date: Mon, 19 Sep 2016 14:50:52 -0700 Subject: [PATCH] Retry getting arcanist token on failure Summary: Many of our diffs dont have sandcastle tests because we failed to load arcanist token file (loaded over the network) this diff try for at least 5 seconds (once every 0.2 second) to load the file instead of failing the first time the file is not found This will make it less probable that diffs are submitted without sandcastle tests Test Plan: arc diff --preview Reviewers: kradhakrishnan, gunnarku, sdong Reviewed By: sdong Subscribers: andrewkr, dhruba Differential Revision: https://reviews.facebook.net/D63951 --- arcanist_util/config/RocksDBCommonHelper.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arcanist_util/config/RocksDBCommonHelper.php b/arcanist_util/config/RocksDBCommonHelper.php index 23575252f..60b9333c3 100644 --- a/arcanist_util/config/RocksDBCommonHelper.php +++ b/arcanist_util/config/RocksDBCommonHelper.php @@ -183,6 +183,14 @@ function getSandcastleConfig() { } else { // This is a typical `[p]arc diff` case. Fetch the values from the specific // configuration files. + for ($i = 0; $i < 50; $i++) { + if (file_exists(PRIMARY_TOKEN_FILE) || + file_exists(SECONDARY_TOKEN_FILE)) { + break; + } + // If we failed to fetch the tokens, sleep for 0.2 second and try again + usleep(200000); + } assert(file_exists(PRIMARY_TOKEN_FILE) || file_exists(SECONDARY_TOKEN_FILE));