You are here

function _acquia_purge_diagnostics_inv_balancers in Acquia Purge 7

Invalidated balancers.

Parameters

string $t: Name of the t() function to call.

AcquiaPurgeService $service: The Acquia Purge service.

Return value

array Associative array with the following elements:

1 string reference to '_acquia_purge_diagnostics_inv_balancers'
acquia_purge_acquia_purge_diagnostics in ./acquia_purge.module
Implements hook_acquia_purge_diagnostics().

File

./acquia_purge.diagnostics.inc, line 585
Diagnostic self-tests and reports that aim to prevent runtime misery.

Code

function _acquia_purge_diagnostics_inv_balancers($t, $service) {
  $test = array(
    'value' => implode(', ', $service
      ->hostingInfo()
      ->getBalancerAddresses()),
    'title' => $t('Invalidated balancers'),
  );

  // When HTTP_X_GEO_COUNTRY is detected, register it as VCL oddity.
  if (isset($_SERVER['HTTP_X_GEO_COUNTRY'])) {
    if (strlen($_SERVER['HTTP_X_GEO_COUNTRY'])) {
      $service
        ->oddities()
        ->add('geoip');
    }
  }

  // Evaluate the sanity of the amount of load balancers.
  $balancers_c = count($service
    ->hostingInfo()
    ->getBalancerAddresses());
  if (!$balancers_c) {
    $test['value'] = $t('No load balancers detected.');
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_ERROR;
    $test['description'] = $t('There are no load balancers detected which makes' . ' it impossible to purge your site. Please contact Acquia Support!');
  }
  elseif ($balancers_c < 2) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_WARNING;
    $test['description'] = $t('You have only one load balancer, this means your' . ' site can not be failed over by us. Please contact Acquia Support.');
  }
  elseif ($balancers_c >= 6) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_WARNING;
    $test['description'] = $t('Your website is running behind @no load' . ' balancers, which will put severe stress on your database. Please pay' . ' attention to the number of items in the queue table.', array(
      '@no' => $balancers_c,
    ));
  }
  elseif ($service
    ->oddities()
    ->has('geoip')) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_WARNING;
    $test['description'] = $t('The HTTP_X_GEO_COUNTRY variable has been detected, which indicates' . ' that you have GeoIP enabled. Acquia Purge automatically switched to' . ' issuing BAN-requests. However, this only works behind a Varnish 4' . ' load balancer. When you are seeing HTTP 501 errors in your logs, then' . ' you require upgraded load balancers. Acquia is in the process to' . ' upgrade its entire platform.');
  }
  elseif ($service
    ->oddities()
    ->has('403')) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_WARNING;
    $test['description'] = $t('Acquia Purge received HTTP 403 (forbidden) responses from one of your' . ' load balancers, this is abnormal behavior! This could suggest that' . ' your site runs behind a customized VCL file which likely hinders the' . ' proper functioning of this module. Please contact Acquia support with' . ' this message to get further guidance on how to resolve the problem.');
  }
  else {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_OK;
  }
  return $test;
}