Problem/Motivation
Much of the data that Connector stores in configuration is volatile and managed by the server. This makes it difficult to integrate with common Configuration Management strategies, and makes it prone to accidental breakage.
Proposed resolution
Move the following configuration keys into the state API:
- acquia_connector.settings.subscription_data
- acquia_connector.settings.spi.def_vars
- acquia_connector.settings.spi.def_waived_vars
- acquia_connector.settings.spi.def_timestamp
- acquia_connector.settings.new_optional_data
Remaining tasks
Decide whether to backport to 8.x-1.x: pros, it will fix the issue for more users, and it will solve related issues such as #3105440: Acquia Connector's calling Subscription::update() sometimes invalidates cache tags unnecessarily. Cons, there's a larger scope since Acquia Search would also need to be updated, and it's potentially breaking if anyone has code that relies on subscription configuration being present.
User interface changes
None.
API changes
None.
Data model changes
Update hook must be run to migrate config items to state. Any custom code depending on the configuration being present will break.
Release notes snippet
(Major and critical issues should have a snippet that can be pulled into the release notes when a release is created that includes the fix)
Original report by bkosborne
This module keeps track of a lot of Acquia subscription related data which is currently stored in the config management system. This is troublesome because this data can change at any time during cron runs, but a config import/export will overwrite the changes. All of this data should be stored in the State API and not config.
See #2635138: Don't use config for storing dynamic subscription data or API keys for more info.
Comment | File | Size | Author |
---|---|---|---|
#23 | acquia_connector-2864697-22.patch | 22.38 KB | Dane Powell |
| |||
#15 | acquia_connector-2864697-15.patch | 18.18 KB | Dane Powell |
|
Comments
Comment #2
bkosborneComment #3
bkosborneHi, Just wondering if this is on Acquia's priority list for the module at all? I don't think it's causing any major issues for us, but the config object is still constantly being updated during cron runs so there's always a config difference between what's in active vs what's on the file system.
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedI'm seeing a write in expiration_date, likely due to the start of a new year,
Comment #5
Dane Powell CreditAttribution: Dane Powell at Acquia commentedWhile I think that everything in the subscription_data key should be moved into the state system, I've been advised that this would probably break other Acquia products and internal systems that apparently read directly from Acquia Connector's config to get subscription data.
I'd think that we could at least move the expiration date safely out of the config, but who knows for sure.
Ideally, Acquia Connector would have a set of public 'getter' functions for subscription data so that other products don't have to directly read its config. This would have made this fix a whole lot simpler.
Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentedThanks for the background. Guess someone should create those methods and then perhaps the Acquia teams can have 3 months (or whatever) to convert to new API.
Comment #7
kmoll CreditAttribution: kmoll at Appnovation for Pfizer, Inc. commentedWe are running into this issue on all of our subscriptions. We do a config import after all of our deployments, and the subscriptions data always gets overwritten and the the status shows as inactive. Has there been any progress on this?
Comment #8
larowlanthis is now causing major issues on client sites, after a deploy the subscription data is reset and then searches stop working which ends up with fatal errors
Uncaught PHP Exception Drupal\search_api_solr\SearchApiSolrException: "An error occurred while trying to search with Solr: Solr endpoint http://{host}.acquia-search.com:80/solr/{something}/ unreachable..
Comment #9
timwoodWe have always used config_ignore to not export/store Acquia Connector module configuration in code and let it be generated automatically in the environment when the module is enabled. Would that help anyone with the issue outlined here?
Comment #10
richardbporter CreditAttribution: richardbporter as a volunteer commentedAre there any plans to address this?
@timwood have you found a way to ignore configuration while also allowing modules to be enabled/disabled per environment splits?
Comment #11
timwoodHey @rbp. We haven't had a use case where we needed to ignore config related to modules which are enabled/disabled per environment splits. In the case of the acquia_connector module, we just enable it across the board.
I did find this module, which looks like it does exactly what you are looking for: https://www.drupal.org/project/config_split_ignore
Comment #12
janusman CreditAttribution: janusman at Acquia commentedThis is a related issue that can help relieve the "resaving the config object on all cron runs" issue (which also then triggers unneeded cache tag invalidations) : #3105440: Acquia Connector's calling Subscription::update() sometimes invalidates cache tags unnecessarily
Comment #13
Dane Powell CreditAttribution: Dane Powell at Acquia commentedHere's a first pass at a patch for 8.x-2.x. It seems to work for new installations, but upgrading installations will need an update hook.
I'm not sure if we'll be able to backport this or not. There's a larger scope since Acquia Search would also need to be updated, and it's potentially breaking if anyone has code that relies on subscription configuration being present. The Acquia Connector 8.x-2.x branch seems like the perfect place for this change since it's still in beta.
We should see if there's any other configuration that needs to move to state, since this may be our only shot to make it happen. Please let me know if you can think of anything.
Comment #14
larowlanshould the state service be injected here?
Agree, needs an update path to copy the current values and delete the existing config entry
Looking good though - thanks!
Comment #15
Dane Powell CreditAttribution: Dane Powell at Acquia commentedThanks for the feedback. This patch should be ready to go, I appreciate any additional input. Like I mentioned previously, it's really important that we get this right now because it will be difficult to make similar changes once 8.x-2.x is stable.
Changes from #13:
Comment #16
larowlanChange looks good, not sure if you normally require update path tests for this module or not, other than that - looks good
Comment #17
bkosborneChanges look good to me! I did not test on a live site though, so not setting reviewed yet
Comment #18
moshe weitzman CreditAttribution: moshe weitzman commentedIf you create service or wrapper around
Drupal::state()->get('acquia_subscription_data')
(for example) then you can change implementation later without bothering downstream.Comment #19
Dave ReidI think a service that contains the logic and gets the state service injected behind the scenes does sound like a good idea. It would have been possible to do in 1.x if that had been the case.
Comment #20
Dane Powell CreditAttribution: Dane Powell at Acquia commentedA wrapper service does sound nice to have, but my biggest concern is moving additional settings out of configuration and into state, which a wrapper service won't help with. I also wasn't able to find any examples of custom or contributed code in D8 that access these settings.
Without any evidence that people would actually use such a wrapper, it feels premature. I appreciate the irony that I was the first person to suggest it in this thread two years ago :)
Comment #21
Dane Powell CreditAttribution: Dane Powell at Acquia commentedComment #23
Dane Powell CreditAttribution: Dane Powell at Acquia commentedCommitted to 8.x-2.x, backporting to 8.x-1.x. I also tweaked the update function in the 2.x branch to be idempotent for upgrading users.
Comment #25
Dane Powell CreditAttribution: Dane Powell at Acquia commented