From 0db29e624cc2918205e68640f3d25c904c9c0d7e Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 20 Jan 2019 09:27:48 -0800 Subject: [PATCH] Provide a richer error when an intracluster request can not be satisfied by the target node Summary: See PHI1030. When installs hit this error, provide more details about which node we ended up on and what's going on. Test Plan: ``` $ git pull phabricator-ssh-exec: This repository request (for repository "spellbook") has been incorrectly routed to a cluster host (with device name "local.phacility.net", and hostname "orbital-3.local") which can not serve the request. The Almanac device address for the correct device may improperly point at this host, or the "device.id" configuration file on this host may be incorrect. Requests routed within the cluster by Phabricator are always expected to be sent to a node which can serve the request. To prevent loops, this request will not be proxied again. (This is a read request.) fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D20002 --- .../storage/PhabricatorRepository.php | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php index e1febe7ac8..9dfafbcf59 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -2024,10 +2024,35 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO } if ($never_proxy) { + // See PHI1030. This error can arise from various device name/address + // mismatches which are hard to detect, so try to provide as much + // information as we can. + + if ($writable) { + $request_type = pht('(This is a write request.)'); + } else { + $request_type = pht('(This is a read request.)'); + } + throw new Exception( pht( - 'Refusing to proxy a repository request from a cluster host. '. - 'Cluster hosts must correctly route their intracluster requests.')); + 'This repository request (for repository "%s") has been '. + 'incorrectly routed to a cluster host (with device name "%s", '. + 'and hostname "%s") which can not serve the request.'. + "\n\n". + 'The Almanac device address for the correct device may improperly '. + 'point at this host, or the "device.id" configuration file on '. + 'this host may be incorrect.'. + "\n\n". + 'Requests routed within the cluster by Phabricator are always '. + 'expected to be sent to a node which can serve the request. To '. + 'prevent loops, this request will not be proxied again.'. + "\n\n". + "%s", + $this->getDisplayName(), + $local_device, + php_uname('n'), + $request_type)); } if (count($results) > 1) {