DCausse has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/333275 )

Change subject: Fix alias creation for the metastore index
......................................................................


Fix alias creation for the metastore index

Some endpoints have changed, it causes issues when creating
the metastore.

Depends-On: I208a8dbcc2cb05af69af84a8a534ca8e8e03897c
Change-Id: I3abced22ce24bd4bca9f24d614219630b844ea76
---
M includes/Maintenance/MetaStoreIndex.php
M includes/Maintenance/Validators/IndexAllAliasValidator.php
2 files changed, 10 insertions(+), 3 deletions(-)

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



diff --git a/includes/Maintenance/MetaStoreIndex.php 
b/includes/Maintenance/MetaStoreIndex.php
index 9d9f3a5..5e211ef 100644
--- a/includes/Maintenance/MetaStoreIndex.php
+++ b/includes/Maintenance/MetaStoreIndex.php
@@ -303,7 +303,14 @@
         * alias or null if the alias does not exist
         */
        private function getAliasedIndexName() {
-               $resp = $this->client->request( '_aliases/' . self::INDEX_NAME, 
\Elastica\Request::GET, [] );
+               // FIXME: Elastica seems to have trouble parsing the error 
reason
+               // for this endpoint. Running a simple HEAD first to check if it
+               // exists
+               $resp = $this->client->request( '_alias/' . self::INDEX_NAME, 
\Elastica\Request::HEAD, [] );
+               if ( $resp->getStatus() === 404 ) {
+                       return null;
+               }
+               $resp = $this->client->request( '_alias/' . self::INDEX_NAME, 
\Elastica\Request::GET, [] );
                $indexName = null;
                foreach( $resp->getData() as $index => $aliases ) {
                        if ( isset( $aliases['aliases'][self::INDEX_NAME] ) ) {
diff --git a/includes/Maintenance/Validators/IndexAllAliasValidator.php 
b/includes/Maintenance/Validators/IndexAllAliasValidator.php
index dd59b94..b2c0426 100644
--- a/includes/Maintenance/Validators/IndexAllAliasValidator.php
+++ b/includes/Maintenance/Validators/IndexAllAliasValidator.php
@@ -39,11 +39,11 @@
                // build the request to Elasticsearch ourselves.
 
                foreach ( $add as $indexName ) {
-                       $data['action'][] = [ 'add' => [ 'index' => $indexName, 
'alias' => $this->aliasName ] ];
+                       $data['actions'][] = [ 'add' => [ 'index' => 
$indexName, 'alias' => $this->aliasName ] ];
                }
 
                foreach ( $remove as $indexName ) {
-                       $data['action'][] = [ 'remove' => [ 'index' => 
$indexName, 'alias' => $this->aliasName ] ];
+                       $data['actions'][] = [ 'remove' => [ 'index' => 
$indexName, 'alias' => $this->aliasName ] ];
                }
 
                $this->client->request( '_aliases', \Elastica\Request::POST, 
$data );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3abced22ce24bd4bca9f24d614219630b844ea76
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: es5
Gerrit-Owner: DCausse <dcau...@wikimedia.org>
Gerrit-Reviewer: DCausse <dcau...@wikimedia.org>
Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org>
Gerrit-Reviewer: Gehel <gleder...@wikimedia.org>
Gerrit-Reviewer: Smalyshev <smalys...@wikimedia.org>
Gerrit-Reviewer: Tjones <tjo...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to