Deleting cluster used for Search API server backend causes fatal error

Created on 6 March 2016, almost 9 years ago
Updated 24 September 2024, 3 months ago

Hi,

Problem/Motivation

Right now it is possible to delete cluster through the Elasticsearch Connector administration while this cluster is used as Search API server backend.
The result of that is fatal error.

TypeError: Argument 1 passed to Drupal\\elasticsearch_connector\\ElasticSearch\\ClientManager::getClientForCluster() must be an instance of Drupal\\elasticsearch_connector\\Entity\\Cluster, null given, called in .../elasticsearch_connector/src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php on line 101 in .../elasticsearch_connector/src/ElasticSearch/ClientManager.php on line 39

Proposed resolution

We should either not allow remove of clusters used in Search API configuration or making sure that this is handled nicely.

Regards,
Lachezar

🐛 Bug report
Status

Active

Version

7.0

Component

Elasticsearch Connector Search API

Created by

🇧🇬Bulgaria lachezar.valchev

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada mparker17 UTC-4

    It appears that it is still possible to delete Elasticsearch clusters that are the backend for a Search API index in elasticsearch_connector-8.x-7.x-dev. However, it is not possible in the 8.0.x branch.

    To reproduce it on 8.x-7.x...

    1. Go to /admin/config/search/elasticsearch-connector/cluster/add and add a cluster. Check "Make this cluster default connection".
    2. Go to /admin/config/search/elasticsearch-connector/cluster/add again, and add a second cluster. Do not check "Make this cluster default connection" this time.
    3. Go to /admin/config/search/search-api/add-server and add a search server which points to the second cluster (the one that isn't the default).
    4. Go to /admin/config/search/elasticsearch-connector and delete the second cluster.
    5. Go to /admin/config/search/search-api: you get an error...
      Drupal\search_api\SearchApiException: Cannot load the Elasticsearch cluster for your index. in Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend->__construct() (line 205 of /var/www/html/src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php).
      
      Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::create() (Line: 21)
      Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 83)
      Drupal\Component\Plugin\PluginManagerBase->createInstance() (Line: 149)
      Drupal\search_api\Entity\Server->getBackend() (Line: 198)
      Drupal\search_api\Entity\Server->isAvailable() (Line: 209)
      Drupal\search_api\IndexListBuilder->buildRow() (Line: 241)
      Drupal\search_api\IndexListBuilder->render() (Line: 23)
      Drupal\Core\Entity\Controller\EntityListController->listing()
      call_user_func_array() (Line: 123)
      Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
      Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
      Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
      Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
      Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
      Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
      Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
      Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
      Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
      Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
      Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
      Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
      Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
      Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
      Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
      Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
      Drupal\Core\DrupalKernel->handle() (Line: 19)
      
Production build 0.71.5 2024