Sometimes it is useful to connect to more than one subscription. We should follow the progress of #1190890: Support multiple search environments for the same AN subscription and port the changes to this module as well.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alanmackenzie’s picture

What's missing from this now is the ability to switch the solr path based on environment.

If you rely on the DB & features you can get into a painful mess of having to do manual configuration on each environment and developers accidentally make changes to the wrong index.

The apachsolr module uses the apachesolr_path persistent variable to allow for switching of the path through $conf[].

The attached patch follows the same pattern, only with the variable name search_api_acquia_path.

Example of how to use it:

if ($_ENV["AH_SITE_ENVIRONMENT"] == "prod") {
  $conf['acquia_identifier'] = 'ABCD-1111';
  $conf['acquia_key'] = 'sdfsfsagfsadg7s8gf7asdfasd8f7sa9d';
  $conf['acquia_subscription_name'] = 'MyCompany [Dev - Solr]';
  $conf['search_api_acquia_path'] = '/solr/ABCD-1111';
}
elseif ($_ENV["AH_SITE_ENVIRONMENT"] == "test") {
  $conf['acquia_identifier'] = 'ABCD-2222';
  $conf['acquia_key'] = 'asdaksfd8798s7dafasd9f87sad9f7sa9df';
  $conf['acquia_subscription_name'] = 'MyCompany [Stage - Solr]';
  $conf['search_api_acquia_path'] = '/solr/ABCD-222';
}

There's a fair argument that this should be implemented in search_api_solr instead, however this module is implementing connect() in SearchApiAcquiaSearchService so it's not possible to use the layer below. It's not obbious to me why this is as the code in the method is exactly the same.

If you want me to push this upstream instead and you can confirm that it's ok to remove the implementation of connect() I can provide patches to remove it and reimplement this change against search_api_solr.

nielsvm’s picture

I've pinged various people on your behalf Alan!
(Acquia support reference #73024).

Nick_vh’s picture

Why not use the same variables as apachesolr to make it easier and more consistent?

Nick_vh’s picture

Category: task » feature
Priority: Critical » Normal
Status: Needs work » Active
$conf['acquia_identifier'] = 'ABCD-2222';
$conf['acquia_key'] = 'asdaksfd8798s7dafasd9f87sad9f7sa9df';

// Regular settings
$conf['acquia_search_host'] =  'search.acquia.com';
$conf['acquia_search_path'] = '/solr/' . $identifier;

// Expert mode
$conf['acquia_search_derived_key_salt'] = '123456789123456';

On that note, this module should support the hostname that is pulled in from the subscription array.
Something similar like this.

if (!empty($conf['acquia_subscription_id']) && !empty($conf['acquia_subscription_key'])) {
    $identifier = $conf['acquia_subscription_id'];
    $key = $conf['acquia_subscription_key'];
    $subscription = acquia_agent_get_subscription($params = array(), $identifier, $key);
  }
  else {
    $identifier = acquia_agent_settings('acquia_identifier');
    $subscription = acquia_agent_settings('acquia_subscription_data');
  }
  $search_host = variable_get('acquia_search_host', 'search.acquia.com');
  // Adding the subscription specific colony to the heartbeat data
  if (!empty($subscription['heartbeat_data']['search_service_colony'])) {
    $search_host = $subscription['heartbeat_data']['search_service_colony'];
  }

  $environment = array(
    'url' => 'http://' . $search_host . variable_get('acquia_search_path', '/solr/'. $identifier),
    'service_class' => 'AcquiaSearchService',
  );
Nick_vh’s picture

Status: Active » Needs work
cpliakas’s picture

Category: feature » task
Priority: Normal » Critical

Marking as a critical task for the following reasons:

  • The issue at #1551302: Fix server tasks system will blow your site up if you define a connection per environment and disable the inactive ones
  • We need to get the hostname form the connector otherwise this module is likely to stop working in the upcoming months
cpliakas’s picture

Category: feature » task
Priority: Normal » Critical
Status: Active » Needs work

@alanmackenzie, thanks for your contribution!

cpliakas’s picture

Status: Needs work » Needs review
FileSize
5.12 KB

The attached patch implements Nick's suggestions in #4 to achieve alanmackenzie's goals of using settings.php to change the subscription based on environment. It also implements Nick's suggestion to use the hostname pulled from the subscription. As a bonus, I added the "search_api_acquia_overrides" variable which allows you to override the options on a per-server basis for all servers connected to Acquia Search.

Nick_vh’s picture

Looks good to go

cpliakas’s picture

Status: Needs review » Reviewed & tested by the community

Excellent. Thanks for reviewing!

cpliakas’s picture

Status: Reviewed & tested by the community » Fixed
alanmackenzie’s picture

Thanks for the speedy response guys.

Can you confirm that $subscription['heartbeat_data']['search_service_colony']; isn't some form of high availability failover (as the name heartbeat suggests)?

If it was I would expect it to override search_api_acquia_overrides, I can provide another patch if so.

cpliakas’s picture

Hi @alanmackenzie.

I believe that this setting is not related to the HA heartbeat software but something else that is deprecated. Regardless, I am confident that it has nothing to do with the HA of search as that is managed server-side on Acquia's infrastructure.

Thanks,
Chris

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.