New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies are not skipped when config-export --skip-modules is used #1820

Closed
gaelg opened this Issue Nov 30, 2015 · 21 comments

Comments

Projects
None yet
@gaelg
Copy link
Contributor

gaelg commented Nov 30, 2015

If one skips some module (let's say Devel) when exporting configuration, the dependent config entities won't be skipped (you'll still get a devel.settings.yml file in the export). And this can break the import in another instance of the same site, because of dependency validation. The error will come from https://api.drupal.org/api/drupal/core!lib!Drupal!Core!EventSubscriber!ConfigImportSubscriber.php/function/ConfigImportSubscriber%3A%3AvalidateDependencies/8

@nevergone

This comment has been minimized.

Copy link

nevergone commented Dec 11, 2015

Confirmed. :(

@nevergone

This comment has been minimized.

Copy link

nevergone commented Dec 15, 2015

drush config-import also affected.

@weitzman weitzman added the pri-high label Dec 19, 2015

@thenetexperts

This comment has been minimized.

Copy link

thenetexperts commented Jan 19, 2016

still a problem in 8.0.2, for now one could add the dependent config files to a .gitignore until solved

@nevergone

This comment has been minimized.

Copy link

nevergone commented Jan 19, 2016

This issue is independent from git.

@thenetexperts

This comment has been minimized.

Copy link

thenetexperts commented Jan 19, 2016

yes of course. I was merely pointing out that, in the meantime, you could add the created dependent configuration .yml files (for example devel.settings.yml) to a .gitignore until this issue is resolved.

@gaelg

This comment has been minimized.

Copy link
Contributor Author

gaelg commented Jan 29, 2016

I tried to work on this, but it's harder than I expected. The storage filters are called with source config objects only, so that there is no way to filter out a destination config object using storage filters. I'll try to find another way.

@gaelg

This comment has been minimized.

Copy link
Contributor Author

gaelg commented Feb 1, 2016

Here's what I did today: gaelg@44887b1
Any help would be very appreciated, specially to improve dependency detection and to make tests.

@gaelg

This comment has been minimized.

Copy link
Contributor Author

gaelg commented Feb 2, 2016

I improved dependency detection and fixed a bug.
system.menu.devel is still not ignored, but this is because Devel should enforce the dependency for this config (https://www.drupal.org/node/2404447).
It seems to work well. Should I make a pull request, or should this still be improved before any pull?

@greg-1-anderson

This comment has been minimized.

Copy link
Member

greg-1-anderson commented Feb 2, 2016

Thanks for working on this. I haven't had a chance to review the referenced branch yet, but it is always okay to make a work-in-progress PR.

@gaelg

This comment has been minimized.

Copy link
Contributor Author

gaelg commented Feb 2, 2016

It would be nice if someone in this issue queue could write up tests for this. I'll do it when I get time otherwise.
The tests could be:
For export :

  • install devel on a website, drush cex --skip-modules=devel, ensure that devel.settings.yml is not created
  • do it a second time, now that sync dir is not empty, ensure the same
  • website without devel, sync dir with devel.settings.yml, drush cex --skip-modules=devel, ensure devel.settings.yml still exists
  • website with devel, sync dir with a different devel.settings.yml, drush cex --skip-modules=devel, ensure devel.settings.yml has not been updated

For import :

  • website without devel, add a dummy devel.settings.yml in the sync directory, drush cim --skip-modules=devel, ensure the devel settings are not imported (how?)
  • website with devel, drush cim --skip-modules=devel from a config which doesn't have devel, ensure devel settings are not lost

I said Devel but it might be better to test with a module which has chained dependencies (which one ?).

NB: It make me think that dependent modules should also be ignored, but that might be another issue for later? (it's easy to just add them in the command)

@gaelg

This comment has been minimized.

Copy link
Contributor Author

gaelg commented Feb 5, 2016

I made an issue about the devel problem: https://www.drupal.org/node/2663558

@nevergone

This comment has been minimized.

Copy link

nevergone commented Feb 17, 2016

gaelg: not work :(

@weitzman

This comment has been minimized.

Copy link
Member

weitzman commented Jul 12, 2016

Is this issue related to #1964

@gaelg

This comment has been minimized.

Copy link
Contributor Author

gaelg commented Jul 13, 2016

Yes, I'm not very used to GitHub. I first made an "issue", and then a related pull request.

@flesheater

This comment has been minimized.

Copy link

flesheater commented Dec 7, 2016

Meanwhile, you may use this tool from here https://github.com/previousnext/drush_cmi_tools
It works like charm for me.

@stevector

This comment has been minimized.

Copy link

stevector commented Dec 7, 2016

While watching this really good presentation on config management from DrupalCon Dublin (https://www.youtube.com/watch?v=57t_CS2wbHI) I learned about Config Split which handles the same use case: https://www.drupal.org/project/config_split

@dsdobrzynski

This comment has been minimized.

Copy link

dsdobrzynski commented Dec 7, 2016

@stevector Config Split does resolve this issue on a broader level. I'm currently using it on several projects successfully. I'm using it to split config based on environment (prod, test/staging, dev) and import based on environment with a script.

Perhaps the larger question then is: Does this need to be part of Drush?

@leymannx

This comment has been minimized.

Copy link

leymannx commented Sep 5, 2017

Sure it does. Drush allows you to skip modules like when you have the following in your drushrc.php for example:

// Ignore development modules when exporting/importing configuration.
$development_modules = ['devel', 'webprofiler'];
$command_specific['config-export']['skip-modules'] = $development_modules;
$command_specific['config-import']['skip-modules'] = $development_modules;

This prevents that these module will get added to core.extensions.yml. So why not skip the other *.yml files related to these modules, too? (Which in this example at least are devel.settings.yml and webprofiler.config.yml.)

@rodrigoaguilera

This comment has been minimized.

Copy link

rodrigoaguilera commented Sep 5, 2017

The "skip-modules" option was removed on drush 8.1.11
https://github.com/drush-ops/drush/releases/tag/8.1.11

This issue should be closed

@colans

This comment has been minimized.

Copy link
Contributor

colans commented Sep 5, 2017

It was removed in favour of Config Split so yes, we can close this.

@leymannx

This comment has been minimized.

Copy link

leymannx commented Sep 5, 2017

Wow, good to know. Thanks for the clarification.

@gaelg gaelg closed this Sep 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment