Problem/Motivation

With each new version of farmOS, there may be changes to configuration that need to be reverted/applied between updates.

As I see it, there are two potential host/administrator workflows in this regard:

  1. farmOS instances that are "default configurations" which always want to have the most up-to-date config. (Farmier hosting is basically this... but a lot of self-hosted instances will also want this to be automatic.)
  2. farmOS instances that are more customized, where some config may be overridden, and the instance administrator wants to manually review and apply config changes themselves.

Proposed resolution

I propose that we add a core farm_update module, that can be optionally enabled. When enabled, it will automatically maintain configuration so that it is always in sync with the modules that provide it. This will cover the first use case (fully automated configuration updates).

If this is not desired (second use case), then the module can simply be disabled.

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Comments

m.stenta created an issue. See original summary.

m.stenta’s picture

Big questions here are:

1. How do we know what config to maintain?
2. How/when/where do we maintain it?

m.stenta’s picture

> How do we know what config to maintain?

@pcambra pointed to the config_devel module as a possible example to learn from. They use a concept of "third party settings" in module info.yml files to define all the config that is "owned" by a module.

If we implemented something similar, we could essentially make a list of all the config items that each module manages, and the farm_update module could read that and only act on those config items.

Or, maybe that's not even necessary, maybe farm_update can auto-detect the config by looking at the config/install and config/optional directories directly.

m.stenta’s picture

> How/when/where do we maintain it?

The whole point of having this is so that we don't need to add endless hook_update_N() implementations for minor config changes. But hook_update_N() IS the easiest way to ensure this logic runs on updates, I think.

Alternatively, I wonder if hook_cache_flush() would work? Does that run every time that update.php is run? If so, then all we have to do is tell users to run update.php and it will update the config. But... I'm not sure if caches get cleared by update.php if there aren't any actual hook_update_N() implementations to run...

m.stenta’s picture

This related upstream issue in the config_rewrite module might be worth dusting off... IIRC it prevents "rewritten" config from showing as "overridden" in the configuration updates report.

I'm not sure if that would help with this issue at all... but if we need to be able to compare against "rewritten" config then maybe that provides some insight.

m.stenta’s picture

They use a concept of "third party settings" in module info.yml files to define all the config that is "owned" by a module.

I think this would make farm_update a dependency of all modules that include these settings, which would defeat the purpose of being able to disable it.

A hook is a simple approach that would keep this optional, and would allow modules to define config that they don't want to be updated. A similar approach can be taken with a simple config for the update module itself.

Alternatively, I wonder if hook_cache_flush() would work? Does that run every time that update.php is run? If so, then all we have to do is tell users to run update.php and it will update the config. But... I'm not sure if caches get cleared by update.php if there aren't any actual hook_update_N() implementations to run...

hook_rebuild() is another option (runs after caches are flushed): https://api.drupal.org/api/drupal/core!core.api.php/function/hook_rebuil...

Still an open question as to whether or not this runs via update.php even when there are no new update hooks. We could provide a Drush command to manually run the revert logic too.

This related upstream issue in the config_rewrite module might be worth dusting off...

We decided to remove config_rewrite from farmOS, so this is no longer relevant.

m.stenta’s picture

Status: Active » Needs review

Opened a pull request for review: https://github.com/farmOS/farmOS/pull/444

m.stenta’s picture

Status: Needs review » Needs work

This is causing farm_api tests to fail for some reason... commenting out farm_update in the base modules list in farm.profile fixes it. Needs more investigation...

m.stenta’s picture

Status: Needs work » Needs review

Ah the tests are revealing some more config that needs to be excluded:

  • user.role.anonymous
  • user.role.authenticated

These were being overridden during the TokenBearerFunctionalTestBase. And in general we should not be reverting these two roles ever.

I also excluded system.performance.

Tests are passing now.

  • m.stenta committed bc7af7b on 2.x
    Issue #3220627: Optionally apply configuration changes automatically
    
m.stenta’s picture

Status: Needs review » Fixed

Merged.

There was some additional discussion in the pull request regarding triggering this via update.php, but I opted to just add instructions for clearing the cache after updating farmOS for now: https://github.com/farmOS/farmOS/pull/444

Status: Fixed » Closed (fixed)

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