Problem/Motivation

I don't see any documentation about best practices for what to do with this module on local/DDEV and non-Acquia (CI) environments, like GitHub actions. Can I config override something to turn off the module? I'd rather also avoid using the Configuration Split module if possible.

Do I need to override a purge module service?

Proposed resolution

Unknown

Remaining tasks

Document in the README (doesn't exist) or INSTALL.md

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dave reid created an issue. See original summary.

dave reid’s picture

Even if the information is "If the module detects it is not hosted on an Acquia environment (by X means), it will not do anything" that would be super helpful!

m4olivei made their first commit to this issue’s fork.

m4olivei’s picture

Assigned: Unassigned » m4olivei

I had occasion to dig into this today. Here's what I found. When you have an acquia_purge Purger plugin enabled, that plugin will immediately start to receive purge module \Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidationInterface object to its \Drupal\acquia_purge\Plugin\Purge\Purger\AcquiaCloudPurger::invalidate* methods (routed via \Drupal\acquia_purge\Plugin\Purge\Purger\AcquiaCloudPurger::routeTypeToMethod). The \Drupal\acquia_purge\Plugin\Purge\Purger\AcquiaCloudPurger::invalidate* methods will group invalidations and send a pool of HTTP BAN requests to a list of static IPs identified via \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface::getBalancerAddresses. This latter part is the key, digging into \Drupal\acquia_purge\AcquiaCloud\PlatformInfo::__construct (the only concrete class of type \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface), these static IPs come from \Drupal::service("settings")->get("reverse_proxies") and this setting is only defined in Acquia Cloud environments. Outside of Acquia Cloud environments, this value is NULL, and thus \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface::getBalancerAddresses returns an empty array, which effectively means \Drupal\acquia_purge\Plugin\Purge\Purger\AcquiaCloudPurger::invalidate* methods have no servers to make their request against, and skip making any BAN requests whatsoever.

All that being said, the tldr is that the Acquia Purge module effectively does nothing on non-Acquia Cloud environments, and is by my evaluation is safe to have enabled everywhere. Although, I would suggest that there is an opportunity in the code to skip a bunch of logic much earlier by checking if we're on an Acquia Cloud environment by making use of \Drupal\acquia_purge\AcquiaCloud\PlatformInfo::isThisAcquiaCloud.

I'll take a crack at a README update here.

m4olivei’s picture

Assigned: m4olivei » Unassigned
Status: Active » Needs review

Opened an MR to update INSTALL.md. Ready for review.

jwilson3’s picture

these static IPs come from \Drupal::service("settings")->get("reverse_proxies")

I haven't dug into the module code yet, but isn't the Drupal $settings[] key either "reverse_proxy" or "reverse_proxy_addresses"?

there is an opportunity in the code to skip a bunch of logic much earlier by checking if we're on an Acquia Cloud environment ...

... or, by adding a feature flag killswitch to explicitly disengage the module on specific environments via settings.local.php, so that both acquia_purge, as well as the purge module, can be enabled but effectively neutralized via $settings, to avoid complex config_split workflows.

The MR seems okay but having it also include a killswitch, in my opinion, is the better way to answer this issue's title, as currently worded. Feature flags are a well known and common paradigm/approach in Drupal contrib modules and programming in general to disable/enable features.

rajeshreeputra made their first commit to this issue’s fork.