Tim Starling has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/366983 )
Change subject: Show the hostname in error messages ...................................................................... Show the hostname in error messages It's helpful for the system administrator to know which PC server is giving connection errors and the like. Error messages from the core will not give the hostname, but they are less likely to be specific to a PC server. Bug: T65027 Change-Id: Ic8bfc927b6fa6086b7ae9cc694e848f5808ff58b --- M PoolCounterClient_body.php M PoolCounter_ConnectionManager.php M i18n/en.json M i18n/qqq.json 4 files changed, 24 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PoolCounter refs/changes/83/366983/1 diff --git a/PoolCounterClient_body.php b/PoolCounterClient_body.php index 52066e9..07a51c8 100644 --- a/PoolCounterClient_body.php +++ b/PoolCounterClient_body.php @@ -8,6 +8,11 @@ private $conn; /** + * @var string The server host name + */ + private $hostName; + + /** * @var PoolCounter_ConnectionManager */ static private $manager; @@ -35,7 +40,8 @@ if ( !$status->isOK() ) { return $status; } - $this->conn = $status->value; + $this->conn = $status->value['conn']; + $this->hostName = $status->value['hostName']; // Set the read timeout to be 1.5 times the pool timeout. // This allows the server to time out gracefully before we give up on it. @@ -58,11 +64,11 @@ $conn = $status->value; wfDebug( "Sending pool counter command: $cmd\n" ); if ( fwrite( $conn, "$cmd\n" ) === false ) { - return Status::newFatal( 'poolcounter-write-error' ); + return Status::newFatal( 'poolcounter-write-error', $this->hostName ); } $response = fgets( $conn ); if ( $response === false ) { - return Status::newFatal( 'poolcounter-read-error' ); + return Status::newFatal( 'poolcounter-read-error', $this->hostName ); } $response = rtrim( $response, "\r\n" ); wfDebug( "Got pool counter response: $response\n" ); @@ -85,7 +91,7 @@ default: $parts = explode( ' ', $parts[1], 2 ); $errorMsg = isset( $parts[1] ) ? $parts[1] : '(no message given)'; - return Status::newFatal( 'poolcounter-remote-error', $errorMsg ); + return Status::newFatal( 'poolcounter-remote-error', $errorMsg, $this->hostName ); } return Status::newGood( constant( "PoolCounter::$responseType" ) ); } diff --git a/PoolCounter_ConnectionManager.php b/PoolCounter_ConnectionManager.php index a1f5b62..91df439 100644 --- a/PoolCounter_ConnectionManager.php +++ b/PoolCounter_ConnectionManager.php @@ -29,12 +29,13 @@ $hashes[$hostName] = md5( $hostName . $key ); } asort( $hashes ); - $errno = $errstr = ''; + $errno = $errstr = $hostName = ''; $conn = null; foreach ( $hashes as $hostName => $hash ) { if ( isset( $this->conns[$hostName] ) ) { $this->refCounts[$hostName]++; - return Status::newGood( $this->conns[$hostName] ); + return Status::newGood( + [ 'conn' => $this->conns[$hostName], 'hostName' => $hostName ] ); } $parts = explode( ':', $hostName, 2 ); if ( count( $parts ) < 2 ) { @@ -48,12 +49,12 @@ } } if ( !$conn ) { - return Status::newFatal( 'poolcounter-connection-error', $errstr ); + return Status::newFatal( 'poolcounter-connection-error', $errstr, $hostName ); } wfDebug( "Connected to pool counter server: $hostName\n" ); $this->conns[$hostName] = $conn; $this->refCounts[$hostName] = 1; - return Status::newGood( $conn ); + return Status::newGood( [ 'conn' => $conn, 'hostName' => $hostName ] ); } /** diff --git a/i18n/en.json b/i18n/en.json index 2190e6a..10e180a 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -5,8 +5,8 @@ ] }, "poolcounter-desc": "MediaWiki client for the pool counter daemon", - "poolcounter-connection-error": "Error connecting to pool counter server: $1", - "poolcounter-read-error": "Error reading from pool counter server.", - "poolcounter-write-error": "Error writing to pool counter server.", - "poolcounter-remote-error": "Pool counter server error: $1" -} \ No newline at end of file + "poolcounter-connection-error": "Error connecting to pool counter server $2: $1", + "poolcounter-read-error": "Error reading from pool counter server $1.", + "poolcounter-write-error": "Error writing to pool counter server $1.", + "poolcounter-remote-error": "Pool counter error from server $2: $1" +} diff --git a/i18n/qqq.json b/i18n/qqq.json index c9b344f..ca8f12d 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -10,8 +10,8 @@ ] }, "poolcounter-desc": "{{desc|name=Pool Counter|url=https://www.mediawiki.org/wiki/Extension:PoolCounter}}\nA pool counter keeps track of the running processes on a cluster of processors, and may or may not grant a job access to the processing pool. (Note, the word \"counter\" relates to the counter in a shop, bank, or hotel, not to the verb \"to count\")", - "poolcounter-connection-error": "Used at least in the MediaWiki message {{msg-mw|view-pool-error}}.\n\nUsed as fatal error message.\n\nParameters:\n* $1 - error message which is returned by the server", - "poolcounter-read-error": "Used as error message.\n\nSee also:\n* {{msg-mw|Poolcounter-write-error}}", - "poolcounter-write-error": "Used as error message.\n\nSee also:\n* {{msg-mw|Poolcounter-read-error}}", - "poolcounter-remote-error": "Used as error message. Parameters:\n* $1 - error message which the server returned, or not-localized string \"(no message given)\"." + "poolcounter-connection-error": "Used at least in the MediaWiki message {{msg-mw|view-pool-error}}.\n\nUsed as fatal error message.\n\nParameters:\n* $1 - error message which is returned by the server\n* $2 - the server hostname", + "poolcounter-read-error": "Used as error message.\n\nParameters:\n* $1 - the server hostname\n\nSee also:\n* {{msg-mw|Poolcounter-write-error}}", + "poolcounter-write-error": "Used as error message.\n\nParameters:\n* $1 - the server hostname\n\nSee also:\n* {{msg-mw|Poolcounter-read-error}}", + "poolcounter-remote-error": "Used as error message. Parameters:\n* $1 - error message which the server returned, or not-localized string \"(no message given)\".\n* $2 - the server hostname" } -- To view, visit https://gerrit.wikimedia.org/r/366983 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic8bfc927b6fa6086b7ae9cc694e848f5808ff58b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/PoolCounter Gerrit-Branch: master Gerrit-Owner: Tim Starling <tstarl...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits