In Drupal 7, there was an invaluable Features command for Drush "features-revert-all", which would revert all overridden features on the site.

It appears that no equivalent exists in Drupal 8. Was this an intentional omission, or is there a plan to add this functionality?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dane Powell created an issue. See original summary.

mpotter’s picture

That was an intended omission.

In D8, you aren't really "reverting" a feature, you are importing config from a module and overwriting the active config. A Feature is no longer anything special...any module can have config. The concept of "revert all" was always very dangerous in D7.

In D8 when you are working with your entire site config, you are supposed to use the D8 CMI system to sync your config to the file system and perform full imports and exports. That's how you *DEPLOY* config in D8. You no longer use Features to deploy config. You just use features to package your config into normal modules.

CMI already provides drush commands for doing full export and full import of config. You might also check the config_update module that is used by Features since it also has some drush commands. But we removed "feature-revert-all" from Features specifically to encourage people to use CMI for config deployment and stop using Features for that.

mpotter’s picture

To be a bit clearer, here is how the workflow should be in D8:

Creating initial config:

1) Use Features to organize your config into modules.
2) Push feature module code into git repo
3) On Staging server pull the repo, enable all the modules. Initial config will be loaded.
4) On Staging, use CMI to export all config
5) Pull both code and config export to production
6) On Prod, import all config.

Making a change to Feature(s)

1) On your Dev, update the feature code, push to your repo
2) On Staging, pull the code and import/revert the feature
3) Once tested, use CMI to export all config
4) On Prod, pull code and config
5) On Prod, import all config

So you are only using Features on your Dev and Staging server, not on Production. On Staging you are importing/reverting just the features that have been changed. You don't necessarily want to import/revert everything because you are testing specific changes like pull requests etc.

I was going to do a DrupalCon session on all of this, but it didn't get accepted :(

Dane Powell’s picture

I understand the desire to decouple configuration bundling and deployment, and this might work well for small to medium single-site installations, but I think this paradigm breaks down at larger scales.

For instance, let's say you have a multi-site installation with a content type that should be shared across all sites. Easy enough, you put the content type definition in a feature and install it on the sites.

Now let's say you want to make a change to that content type across all sites. So you start by updating the exported feature definition.

In D7, you could simply push this updated feature definition, run drush fra, and you're done--it's updated on every site.

In D8, it sounds like you would need to revert the feature in a lower environment, export the active site config (containing the updated content type) to disk, push this config to the remote environment, run drush config-import, and then repeat this process for every single site. That just seems unnecessarily convoluted, and a strong argument to bring back features-revert-all. Unless I'm misunderstanding the intended workflow?

Dane Powell’s picture

Ack, simulpost... it sounds like your second comment is roughly in line with the workflow that I was expecting. Still seems like quite a large burden for multi-site installations.

mpotter’s picture

Or you can also write an update hook to import that specific config that needs to be changed.

Again, doing a revert-all was very dangerous and led to people losing other changes to other features/config on the site. If you only changed a certain feature then you should only be reverting that specific feature, not doing an "fra"

mpotter’s picture

This is probably a bigger discussion for the CMI people. The whole design of CMI in D8 says that your site owns the config, not the modules. Features is making an exception to that. And while it might be convenient, we'd like to get away from having Features module enabled on Prod servers.

So are we saying that CMI missed the important case of multi-site where doing the recommended CMI export/import deploy is too cumbersome? Are we just using Features because that's what we are used to doing in D7? Or are we missing the "D8 CMI way" of doing this?

nedjo’s picture

Configuration Synchronizer is a small step in the direction of reverting all features (and other extension-provided configuration). I've got ideas of how to expand the start I made but haven't dug into them yet.

Dane Powell’s picture

I guess I would argue that D8 CMI missed this use case, and Features is the best tool to make up for it now :)

If the working basis of CMI is that an individual site owns all config and a module cannot own any config, then you completely lose the ability to do multi-site config management, because it forces every site to be a "special snowflake". You have to be able to share bundles of config between sites somehow, and enforce changes to that config, otherwise it all falls apart at scale.

Dane Powell’s picture

FileSize
1.96 KB

This patch adds features-revert-all. I understand if you don't want to review it, but I suspect others would benefit from it nonetheless. I haven't tested it extensively yet... caveat emptor.

nedjo’s picture

Status: Active » Needs work

I can see how this could be useful.

While the fra alias can be retained for backwards compatibility, this new command should be parallel to the existing features-import, and named features-import-all.

We'd need to clarify what's meant by "all". All features in the current bundle? All installed features in all bundles? Likely we should have a bundle argument. Should also support the 'force' option like features-import.

mpotter’s picture

Dane: I guess I'm still missing something here with your use-case. How is doing a "drush fra" any different than doing a "drush config-import"? You say that with config-import you have to do it for each site, but don't you need to do it for each site with "drush fra" also? A "drush fra" is essentially doing the same thing as config-import. The only difference is that fra is reading config from modules and config-import is reading config from the wherever the config-sync directory is located. If you put the config-sync directory into your repo it seems like that's the same thing as loading config from modules in the repo.

In any case, I can see the connivence of this if bundle support is added. Then you could put features you want to revert into one bundle and put features you don't want reverted into a different bundle. What I'm trying to stay away from here is the mess we got into with D7 where people complained about drush-fra and then added the ability to "lock" certain features so they couldn't be reverted, and then people wanted to export that "lock list" as yet another feature.

Dane Powell’s picture

The difference is that with features-import-all (let's be consistent for D8, per nedjo's comment), you can cut out the "middle-man" that is the config directory for each site.

In the workflow you proposed, you essentially have two "canonical" sources of configuration data that someone has to manually reconcile for every site. To update featurized config, someone would have set up each site in a dev environment, manually revert each feature for each site, commit the new active config for each site, and then push the config for each site to prod. Even in this workflow, having features-import-all would save you a lot of time by automating all of those features reverts. Otherwise, a developer has to write an update hook for every changed feature, or worse yet, revert the feature by hand.

In the workflow I'm proposing, the canonical config lives with the Feature, so all you have to do is push the new feature directly to stage/prod, run features-import-all (automatically), and sleep easily knowing with certainty that the configuration on every site matches what's in VCS. Obviously in this scenario you would not export any featurized config to the config directory. You might not have a config directory at all. And of course there's the risk of blowing away user-generated changes in prod (leading to the need to "lock" config, etc...), but in my mind this is actually a kind of security feature, and probably best worked around in other ways.

Dane Powell’s picture

Status: Needs work » Needs review
FileSize
1.96 KB
1.14 KB

This patch renames features-revert-all to features-import-all.

I don't think bundle / --force functionality needs to be explicitly added, since features-import-all just calls features-import, which already gets these options from Drush. So maybe it just needs to be documented? It's not something we use locally, so I'm just guessing.

mpotter’s picture

I think this is a good start, but I'd still love to see a --bundle option that only loops through packages within a certain bundle instead of all packages. I think that would go a long way to alleviate some of the past issues with features-revert-all losing config changes.

mpotter’s picture

Status: Needs review » Reviewed & tested by the community

OK, I've gotten several other requests for this, so going to RTBC this. Will look at bundle support in the future as a separate enhancement.

mpotter’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 30d793a.

Status: Fixed » Closed (fixed)

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

Dane Powell’s picture

I did finally get around to adding bundle support: #2808303: Add bundle support to features-import-all