jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/395041 )

Change subject: Swap Maintenance::error() for fatalError()
......................................................................


Swap Maintenance::error() for fatalError()

The former is deprecated when wanting to exit, replace all such
uses. Remaining calls to error() aren't meant to fail entirely

Change-Id: I24ef0021a99d58b72845f6031bc48648c8acdcb7
(cherry picked from commit 46115c78aa888c715196b6992d9f6600cf7f3b9c)
---
M maintenance/cirrusNeedsToBeBuilt.php
M maintenance/copySearchIndex.php
M maintenance/dumpIndex.php
M maintenance/forceSearchIndex.php
M maintenance/metastore.php
M maintenance/runSearch.php
M maintenance/saneitize.php
M maintenance/saneitizeJobs.php
M maintenance/updateOneSearchIndexConfig.php
M maintenance/updateSuggesterIndex.php
10 files changed, 52 insertions(+), 53 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/maintenance/cirrusNeedsToBeBuilt.php 
b/maintenance/cirrusNeedsToBeBuilt.php
index 4f4f8df..5fea9c3 100644
--- a/maintenance/cirrusNeedsToBeBuilt.php
+++ b/maintenance/cirrusNeedsToBeBuilt.php
@@ -53,11 +53,11 @@
                                        $this->getConnection()->destroyClient();
                                } else {
                                        // The two exit code here makes puppet 
fail with an error.
-                                       $this->error( 'Connection error:  ' . 
$e->getMessage(), 2 );
+                                       $this->fatalError( 'Connection error:  
' . $e->getMessage(), 2 );
                                }
                        }
                        if ( $end < microtime( true ) ) {
-                               $this->error( 'Elasticsearch was not ready in 
time.', 1 );
+                               $this->fatalError( 'Elasticsearch was not ready 
in time.' );
                        }
                        sleep( 1 );
                }
diff --git a/maintenance/copySearchIndex.php b/maintenance/copySearchIndex.php
index d643fd3..863ced8 100644
--- a/maintenance/copySearchIndex.php
+++ b/maintenance/copySearchIndex.php
@@ -76,7 +76,7 @@
                $targetConnection = $this->getConnection( $targetCluster );
 
                if ( $sourceConnection->getClusterName() == 
$targetConnection->getClusterName() ) {
-                       $this->error( "Target cluster should be different from 
current cluster.", 1 );
+                       $this->fatalError( "Target cluster should be different 
from current cluster." );
                }
                $clusterSettings = new ClusterSettings( 
$this->getSearchConfig(), $targetConnection->getClusterName() );
 
diff --git a/maintenance/dumpIndex.php b/maintenance/dumpIndex.php
index d66aa86..d5c0491 100644
--- a/maintenance/dumpIndex.php
+++ b/maintenance/dumpIndex.php
@@ -106,8 +106,8 @@
 
                $indexTypes = $this->getConnection()->getAllIndexTypes();
                if ( !in_array( $this->indexType, $indexTypes ) ) {
-                       $this->error( 'indexType option must be one of ' .
-                               implode( ', ', $indexTypes ), 1 );
+                       $this->fatalError( 'indexType option must be one of ' .
+                               implode( ', ', $indexTypes ) );
                }
 
                $this->indexIdentifier = $this->getOption( 'indexIdentifier' );
diff --git a/maintenance/forceSearchIndex.php b/maintenance/forceSearchIndex.php
index a290c2e..da3f1a2 100644
--- a/maintenance/forceSearchIndex.php
+++ b/maintenance/forceSearchIndex.php
@@ -133,8 +133,8 @@
 
                // Make sure we've actually got indices to populate
                if ( !$this->simpleCheckIndexes() ) {
-                       $this->error(
-                               "$wiki index(es) do not exist. Did you forget 
to run updateSearchIndexConfig?", 1
+                       $this->fatalError(
+                               "$wiki index(es) do not exist. Did you forget 
to run updateSearchIndexConfig?"
                        );
                }
 
@@ -245,8 +245,8 @@
                        || $this->hasOption( 'from' ) || $this->hasOption( 'to' 
)
                        || $this->hasOption( 'fromId' ) || $this->hasOption( 
'toId' )
                ) {
-                       $this->error(
-                               '--ids cannot be used with 
deletes/archive/from/to/fromId/toId/limit', 1
+                       $this->fatalError(
+                               '--ids cannot be used with 
deletes/archive/from/to/fromId/toId/limit'
                        );
                }
 
@@ -254,8 +254,8 @@
                        function ( $pageId ) {
                                $pageId = trim( $pageId );
                                if ( !ctype_digit( $pageId ) ) {
-                                       $this->error( "Invalid page id provided 
in --ids, got '$pageId', " .
-                                               "expected a positive integer", 
1 );
+                                       $this->fatalError( "Invalid page id 
provided in --ids, got '$pageId', " .
+                                               "expected a positive integer" );
                                }
                                return intval( $pageId );
                        },
@@ -636,19 +636,19 @@
                if ( $this->toId === null ) {
                        $this->toId = $dbr->selectField( 'page', 'MAX(page_id)' 
);
                        if ( $this->toId === false ) {
-                               $this->error( "Couldn't find any pages to 
index.  toId = $this->toId.", 1 );
+                               $this->fatalError( "Couldn't find any pages to 
index.  toId = $this->toId." );
                        }
                }
                $fromId = $this->getOption( 'fromId' );
                if ( $fromId === null ) {
                        $fromId = $dbr->selectField( 'page', 'MIN(page_id) - 1' 
);
                        if ( $fromId === false ) {
-                               $this->error( "Couldn't find any pages to 
index.  fromId = $fromId.", 1 );
+                               $this->fatalError( "Couldn't find any pages to 
index.  fromId = $fromId." );
                        }
                }
                if ( $fromId === $this->toId ) {
-                       $this->error(
-                               "Couldn't find any pages to index.  fromId = 
$fromId = $this->toId = toId.", 1
+                       $this->fatalError(
+                               "Couldn't find any pages to index.  fromId = 
$fromId = $this->toId = toId."
                        );
                }
                $builder = new \CirrusSearch\Maintenance\ChunkBuilder();
diff --git a/maintenance/metastore.php b/maintenance/metastore.php
index cf8f1ac..9f81ab6 100644
--- a/maintenance/metastore.php
+++ b/maintenance/metastore.php
@@ -138,7 +138,7 @@
        private function dump() {
                $index = $this->getConnection()->getIndex( 
MetaStoreIndex::INDEX_NAME );
                if ( !$index->exists() ) {
-                       $this->error( "Cannot dump metastore: index does not 
exists. Please run --upgrade first", 1 );
+                       $this->fatalError( "Cannot dump metastore: index does 
not exists. Please run --upgrade first" );
                }
                $scrollOptions = [
                        'search_type' => 'scan',
diff --git a/maintenance/runSearch.php b/maintenance/runSearch.php
index 24b03e7..e5d01dc 100644
--- a/maintenance/runSearch.php
+++ b/maintenance/runSearch.php
@@ -258,8 +258,7 @@
                        }
 
                default:
-                       $this->error( "\nERROR: Unknown search type 
$searchType\n" );
-                       exit( 1 );
+                       $this->fatalError( "\nERROR: Unknown search type 
$searchType\n" );
                }
        }
 }
diff --git a/maintenance/saneitize.php b/maintenance/saneitize.php
index 90b2f95..bb756dd 100644
--- a/maintenance/saneitize.php
+++ b/maintenance/saneitize.php
@@ -78,9 +78,9 @@
                if ( $this->hasOption( 'batch-size' ) ) {
                        $this->setBatchSize( $this->getOption( 'batch-size' ) );
                        if ( $this->getBatchSize() > 5000 ) {
-                               $this->error( "--batch-size too high!", 1 );
+                               $this->fatalError( "--batch-size too high!" );
                        } elseif ( $this->getBatchSize() <= 0 ) {
-                               $this->error( "--batch-size must be > 0!", 1 );
+                               $this->fatalError( "--batch-size must be > 0!" 
);
                        }
                }
 
diff --git a/maintenance/saneitizeJobs.php b/maintenance/saneitizeJobs.php
index 4459f00..de911e4 100644
--- a/maintenance/saneitizeJobs.php
+++ b/maintenance/saneitizeJobs.php
@@ -108,7 +108,7 @@
                        }
                }
                if ( !$this->profileName ) {
-                       $this->error( "No profile found for $wikiSize ids, 
please check sanitization profiles", 1 );
+                       $this->fatalError( "No profile found for $wikiSize ids, 
please check sanitization profiles" );
                }
        }
 
@@ -117,7 +117,7 @@
                $this->initMetaStores();
                $jobInfo = $this->getJobInfo( $jobName );
                if ( $jobInfo === null ) {
-                       $this->error( "Unknown job $jobName\n", 1 );
+                       $this->fatalError( "Unknown job $jobName\n" );
                }
                foreach ( $this->metaStores as $cluster => $store ) {
                        $store->sanitizeType()->deleteDocument( $jobInfo );
@@ -139,8 +139,8 @@
                if ( $jobCluster != $scriptCluster ) {
                        $jobCluster = $jobCluster != null ? $jobCluster : "all 
writable clusters";
                        $scriptCluster = $scriptCluster != null ? 
$scriptCluster : "all writable clusters";
-                       $this->error( "Job cluster mismatch, stored job is 
configured to work on $jobCluster " .
-                               "but the script is configured to run on 
$scriptCluster.\n", 1 );
+                       $this->fatalError( "Job cluster mismatch, stored job is 
configured to work on $jobCluster " .
+                               "but the script is configured to run on 
$scriptCluster.\n" );
                }
        }
 
@@ -154,7 +154,7 @@
                $jobName = $this->getOption( 'job-name', 'default' );
                $jobInfo = $this->getJobInfo( $jobName );
                if ( $jobInfo === null ) {
-                       $this->error( "Unknown job $jobName, push some jobs 
first.\n", 1 );
+                       $this->fatalError( "Unknown job $jobName, push some 
jobs first.\n" );
                }
                $fmt = 'Y-m-d H:i:s';
                $cluster = $jobInfo->get( 'sanitize_job_cluster' ) ?: 'All 
writable clusters';
@@ -226,19 +226,19 @@
        private function pushJobs() {
                $pushJobFreq = $this->getOption( 'refresh-freq', 2 * 3600 );
                if ( !$this->getSearchConfig()->get( 'CirrusSearchSanityCheck' 
) ) {
-                       $this->error( "Sanity check disabled, 
abandonning...\n", 1 );
+                       $this->fatalError( "Sanity check disabled, 
abandonning...\n" );
                }
                $profile = $this->getSearchConfig()->getElement( 
'CirrusSearchSanitizationProfiles', $this->profileName );
                $chunkSize = $profile['jobs_chunk_size'];
                $maxJobs = $profile['max_checker_jobs'];
                if ( !$maxJobs || $maxJobs <= 0 ) {
-                       $this->error( "max_checker_jobs invalid 
abandonning.\n", 1 );
+                       $this->fatalError( "max_checker_jobs invalid 
abandonning.\n" );
                }
                $minLoopDuration = $profile['min_loop_duration'];
 
                $pressure = $this->getPressure();
                if ( $pressure >= $maxJobs ) {
-                       $this->error( "Too many CheckerJob: $pressure in the 
queue, $maxJobs allowed.\n", 1 );
+                       $this->fatalError( "Too many CheckerJob: $pressure in 
the queue, $maxJobs allowed.\n" );
                }
                $this->log( "$pressure checker job(s) in the queue.\n" );
 
@@ -326,10 +326,10 @@
                if ( $this->hasOption( 'cluster' ) ) {
                        $cluster = $this->getOption( 'cluster' );
                        if ( !$this->getSearchConfig()->clusterExists( $cluster 
) ) {
-                               $this->error( "Unknown cluster $cluster\n", 1 );
+                               $this->fatalError( "Unknown cluster $cluster\n" 
);
                        }
                        if ( $this->getSearchConfig()->canWriteToCluster( 
$cluster ) ) {
-                               $this->error( "$cluster is not writable\n", 1 );
+                               $this->fatalError( "$cluster is not writable\n" 
);
                        }
                        $connections[$cluster] = Connection::getPool( 
$this->getSearchConfig(), $cluster );
                } else {
@@ -337,17 +337,17 @@
                }
 
                if ( empty( $connections ) ) {
-                       $this->error( "No writable cluster found.", 1 );
+                       $this->fatalError( "No writable cluster found." );
                }
 
                $this->metaStores = [];
                foreach ( $connections as $cluster => $connection ) {
                        if ( !MetaStoreIndex::cirrusReady( $connection ) ) {
-                               $this->error( "No metastore found in cluster 
$cluster", 1 );
+                               $this->fatalError( "No metastore found in 
cluster $cluster" );
                        }
                        $store = new MetaStoreIndex( $connection, $this );
                        if ( !$store->versionIsAtLeast( [ 0, 2 ] ) ) {
-                               $this->error( 'Metastore version is too old, 
expected at least 0.2', 1 );
+                               $this->fatalError( 'Metastore version is too 
old, expected at least 0.2' );
                        }
                        $this->metaStores[$cluster] = $store;
                }
diff --git a/maintenance/updateOneSearchIndexConfig.php 
b/maintenance/updateOneSearchIndexConfig.php
index 153864f..297252a 100644
--- a/maintenance/updateOneSearchIndexConfig.php
+++ b/maintenance/updateOneSearchIndexConfig.php
@@ -220,8 +220,8 @@
                try{
                        $indexTypes = 
$this->getConnection()->getAllIndexTypes();
                        if ( !in_array( $this->indexType, $indexTypes ) ) {
-                               $this->error( 'indexType option must be one of 
' .
-                                       implode( ', ', $indexTypes ), 1 );
+                               $this->fatalError( 'indexType option must be 
one of ' .
+                                       implode( ', ', $indexTypes ) );
                        }
 
                        $utils->checkElasticsearchVersion();
@@ -248,17 +248,17 @@
                } catch ( \Elastica\Exception\Connection\HttpException $e ) {
                        $message = $e->getMessage();
                        $this->output( "\nUnexpected Elasticsearch failure.\n" 
);
-                       $this->error( "Http error communicating with 
Elasticsearch:  $message.\n", 1 );
+                       $this->fatalError( "Http error communicating with 
Elasticsearch:  $message.\n" );
                } catch ( \Elastica\Exception\ExceptionInterface $e ) {
                        $type = get_class( $e );
                        $message = ElasticaErrorHandler::extractMessage( $e );
                        /** @suppress PhanUndeclaredMethod ExceptionInterface 
has no methods */
                        $trace = $e->getTraceAsString();
                        $this->output( "\nUnexpected Elasticsearch failure.\n" 
);
-                       $this->error( "Elasticsearch failed in an unexpected 
way.  This is always a bug in CirrusSearch.\n" .
+                       $this->fatalError( "Elasticsearch failed in an 
unexpected way.  This is always a bug in CirrusSearch.\n" .
                                "Error type: $type\n" .
                                "Message: $message\n" .
-                               "Trace:\n" . $trace, 1 );
+                               "Trace:\n" . $trace );
                }
        }
 
@@ -334,7 +334,7 @@
                );
 
                if ( !$status->isOK() ) {
-                       $this->error( $status->getMessage()->text(), 1 );
+                       $this->fatalError( $status->getMessage()->text() );
                } else {
                        $this->output( "ok\n" );
                }
@@ -357,7 +357,7 @@
                foreach ( $validators as $validator ) {
                        $status = $validator->validate();
                        if ( !$status->isOK() ) {
-                               $this->error( $status->getMessage()->text(), 1 
);
+                               $this->fatalError( 
$status->getMessage()->text() );
                        }
                }
        }
@@ -367,7 +367,7 @@
                $validator->printDebugCheckConfig( $this->printDebugCheckConfig 
);
                $status = $validator->validate();
                if ( !$status->isOK() ) {
-                       $this->error( $status->getMessage()->text(), 1 );
+                       $this->fatalError( $status->getMessage()->text() );
                }
        }
 
@@ -388,7 +388,7 @@
                $validator->printDebugCheckConfig( $this->printDebugCheckConfig 
);
                $status = $validator->validate();
                if ( !$status->isOK() ) {
-                       $this->error( $status->getMessage()->text(), 1 );
+                       $this->fatalError( $status->getMessage()->text() );
                }
        }
 
@@ -433,7 +433,7 @@
                );
                $status = $validator->validate();
                if ( !$status->isOK() ) {
-                       $this->error( $status->getMessage()->text(), 1 );
+                       $this->fatalError( $status->getMessage()->text() );
                }
        }
 
@@ -442,7 +442,7 @@
                        $this->getIndexName(), $this->getSpecificIndexName(), 
$this->startOver, $this->getIndexTypeName(), $this );
                $status = $validator->validate();
                if ( !$status->isOK() ) {
-                       $this->error( $status->getMessage()->text(), 1 );
+                       $this->fatalError( $status->getMessage()->text() );
                }
 
                if ( $this->tooFewReplicas ) {
@@ -462,7 +462,7 @@
                $validator = $this->getShardAllocationValidator();
                $status = $validator->validate();
                if ( !$status->isOK() ) {
-                       $this->error( $status->getMessage()->text(), 1 );
+                       $this->fatalError( $status->getMessage()->text() );
                }
        }
 
diff --git a/maintenance/updateSuggesterIndex.php 
b/maintenance/updateSuggesterIndex.php
index 272132d..c330d5b 100644
--- a/maintenance/updateSuggesterIndex.php
+++ b/maintenance/updateSuggesterIndex.php
@@ -194,8 +194,8 @@
                        $this->getShardCount();
                        $this->getReplicaCount();
                } catch ( \Exception $e ) {
-                       $this->error(
-                               "Failed to get shard count and replica count 
information: {$e->getMessage()}", 1
+                       $this->fatalError(
+                               "Failed to get shard count and replica count 
information: {$e->getMessage()}"
                        );
                }
 
@@ -248,7 +248,7 @@
                        }
 
                        if ( !$this->canWrite() ) {
-                               $this->error( 'Index/Cluster is frozen. Giving 
up.', 1 );
+                               $this->fatalError( 'Index/Cluster is frozen. 
Giving up.' );
                        }
 
                        # check for broken indices and delete them
@@ -262,18 +262,18 @@
                } catch ( \Elastica\Exception\Connection\HttpException $e ) {
                        $message = $e->getMessage();
                        $this->log( "\nUnexpected Elasticsearch failure.\n" );
-                       $this->error( "Http error communicating with 
Elasticsearch:  $message.\n", 1 );
+                       $this->fatalError( "Http error communicating with 
Elasticsearch:  $message.\n" );
                } catch ( \Elastica\Exception\ExceptionInterface $e ) {
                        $type = get_class( $e );
                        $message = ElasticaErrorHandler::extractMessage( $e );
                        /** @suppress PhanUndeclaredMethod ExceptionInterface 
has no methods */
                        $trace = $e->getTraceAsString();
                        $this->log( "\nUnexpected Elasticsearch failure.\n" );
-                       $this->error( "Elasticsearch failed in an unexpected 
way.  " .
+                       $this->fatalError( "Elasticsearch failed in an 
unexpected way.  " .
                                "This is always a bug in CirrusSearch.\n" .
                                "Error type: $type\n" .
                                "Message: $message\n" .
-                               "Trace:\n" . $trace, 1 );
+                               "Trace:\n" . $trace );
                }
        }
 
@@ -773,8 +773,8 @@
                $this->log( "Waiting for the index to go green...\n" );
                // Wait for the index to go green ( default 10 min)
                if ( !$this->utils->waitForGreen( $this->getIndex()->getName(), 
$timeout ) ) {
-                       $this->error( "Failed to wait for green... please check 
config and " .
-                               "delete the {$this->getIndex()->getName()} 
index if it was created.", 1 );
+                       $this->fatalError( "Failed to wait for green... please 
check config and " .
+                               "delete the {$this->getIndex()->getName()} 
index if it was created." );
                }
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/395041
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I24ef0021a99d58b72845f6031bc48648c8acdcb7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: wmf/1.31.0-wmf.10
Gerrit-Owner: Chad <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: DCausse <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Gehel <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: Tjones <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to