-
Notifications
You must be signed in to change notification settings - Fork 40
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
Documentation of Configuration Management #855
Comments
Hi @Drupaldise! We have an article coming out in Drupal Watchdog next month that includes some details, but I think generally speaking we don't have documentation on managing config via the file system. We need to figure out even where this documentation would go between the API docs and the Backdrop handbook, but generally I think I can sum it up. Perhaps once we have a place to put it, we can get something official written up. If you're going to be managing configuration outside the user interface (such as through version control or even FTP), you should move the config directories outside of the Backdrop "files" directory. Backdrop by default will put the configuration files in a randomly generated
Because the "files" directory is generally not in version control, you can make managing your config easier (and more secure) if this directory is moved outside the web directory. Generally that means up one level in the file system:
And you'll need to organize your Git repository or site directory to match this structure, so it would be something like:
I included the
The key to all management of config is the "staging" directory. This directory will be empty all the time unless you're actively moving configuration. We're also introducing our own "versioned" directory that we'll manage in Git. On your localhost or development machine. Configure your site as you would want to deploy to live. Then to deploy your changes simply copy the "active" files into the "versioned" directory, then check it into Git.
Then on your live server, copy the files back out of "versioned" directory into the "staging" (NOT the "active") directory:
You've now "staged" your configuration for deployment, but it's not yet active. You have to let Backdrop import the configuration to allow it to make necessary database changes and validate the configuration is acceptable (e.g. won't accidentally delete in-use fields). So visit In the future, we'll probably have a command-line tool (#47) to do this last step without the UI, but it's a good idea to use the UI to view the file diffs anyway. Note that after you do the import, your "staged" directory will be empty again. Ready for the next time you do a deployment and copy from the "versioned" directory. If you would like to pull down the configuration from live, you can simply do the same process of copying the active directory to versioned, checking it in, pulling down on your local, copying to staging, then importing. There may be other approaches that work as well. We've theorized ideas like managing the "staging" directory all the time, or a combination of symlinks, but so far I think the "just make another directory" for versioned config is the easiest approach we've encountered. |
@quicksketch That's an interesting approach. I'm going to outline this approach below, along with the two others, in more detail for a better compare / contrast for anyone curious. The extra directory approachConfiguration of config directory
Additional set up
Deploying to prod - moving upstream
Sync local from prod - moving downstream
Upsides:
Downsides:
There are two other approaches we've also been considering: The versioned staging directory approachThis an idea from @populist and @davidstrauss based on how the config directory is being managed for Drupal 8 on Pantheon. Configuration of config directory
Additional set up
Deploying to prod - moving upstream
Sync local from prod - moving downstream
Upsides:
Downsides:
And this approach is my personal favorite (and what we'll be recommending in the Drupal Watchdog article, out this May): The figure-8 approachThis approach was recommended by @heyrocker after creating CMI for Drupal 8. It involves using your settings.php file to define different active and staging directories for each environment. Configuration of config directory
Additional set up
Deploying to prod - moving upstream
When you pull upstream, the config files from what was the active directory on local land in what is now the staging directory on production - ready for import. Sync local from prod - moving downstream
When you pull downstream, the config files from what was the active directory on production land in what is now the staging directory on local - ready for import. Upsides:
Downsides:
Here is a more detailed explanation of the two downsides mentioned above: (1) ACCIDENTAL REVERTS ARE POSSIBLE: If there was ever a config change made on production and not actively copied out of the (2) GIT SHOWS STATUS: OUT OF DATE. Git is tracking and reporting all the deleted config files in the |
Hey Guys, thanks for pointing this out. It makes it more clear for me now. In my opinion there must be a topic for that on backdropcms.org Handbook. This feature is so important. |
Note that my 'figure 8' idea stems from the very early stages of CMI, and I don't think it translates well to the way that the modern system (in Drupal or Backdrop) is architected and the thought-work that has gone into it since then. I hadn't considered the third directory option. It's a solid solution but I wish we had something a little more seamless. The whole thing of git status being out of date never really bothered me. |
@heyrocker what is it about the figure-8 that doesn't translate well to how Drupal 8 & Backdrop are architected? What is it about the other two options that translates better? I still prefer the figure-8 approach since it removes the need for copying anything anywhere (and needing to carefully think about where to copy it). Also, this set-up lends itself nicely to having more than 2 environments (like on Pantheon or Acquia) just by adding additional directories.
|
I'm pretty sure this is not possible when you are hosting on Pantheon, since the docroot is also the root of the git repository so you can't put it outside of that, and files is the only area that the web server has permission to update. So, am I correct in assuming that with Pantheon, you need to keep the config files in the hashed directory in files? Has anyone figured out a way around that? |
You could just add an .htaccess file to prevent it from being accessed directly. We're planning on adding one by default in the future over in #706. However I think the hash will stay either way, for sites that are not running Apache for basic security. |
FYI, the approach I ended up using on Pantheon was to leave the active config directory in its default location under the files folder where the pantheon web server can make changes, but to put the staging config directory in the site root under version control. This actually enforces a workflow that I prefer to the default one where the contents of the staging directory are emptied after import. Since backdrop can't delete the files in the staging directory if they are under version control, I can go to the config management page at any time and see all the active config changes that have been made by users since the last code release, just like how with features you can see what has been overridden from the version in code. The only messy part is how it generates dozens of "Warning: unlink() permission denied" errors after you hit Import All. We should get CMI to play nice with version controlled config directories, perhaps as part of the 2.x plans in #435. |
We could gracefully handle this one situation. Just suppress errors from unlink with the
|
Is there an argument to be made that you shouldn't delete after import at all? I know this argument was made during dev on d8 and i was against it, but i might be warming to it now. |
I was trying to remember back to how this whole thing came about, and here's a discussion of the problem. https://www.drupal.org/node/1697256#comment-6641656 It really stems from "How do you stage deletes?" When a config file previously existed and then disappears, the config system sees this as a delete. There are situations where this can get totally foobar'd if your import directory is not cleaned out after every use. Here is an example:
Now sure, you can be extremely careful when doing that copy from dir to dir, but we were trying to figure out how to manage that in a more foolproof manner. Note that the management of how to stage deletes was easily the most complicated problem we had to solve in the base system. You can read that entire thread for tons of alternate approaches we tried and finally abandoned. Just wanted to throw that background out there, for people who might be thinking about trying to work around that directory emptying behavior. |
Or we could just check if the system has write permission in the staging directory, and present a single clear notice such as "backdrop cannot automatically remove the staging files".
This is definitely a problem if the user is manually copying config files around, but should not come up if the config is in version control. We may want to think about how to handle each of these two very different use cases in their own fashion. |
Personally, I'm thinking that a better solution for this would be to export a config file with a list of all the elements that have been deleted, which can be checked on import to see if anything needs to be removed. That seems much more foolproof than assuming that a missing file means that configuration and content should be deleted. What would the drawbacks be to this approach? |
We actually implemented and later backed out that approach. I highly On Mon, Dec 21, 2015 at 1:21 PM, Mike McCaffrey [email protected]
|
Hi all, I just started to collect information about and try Backdrop. And I'd like to tell you that it is really strange that such an important feature like this, which is listed in the second position of the Backdrop homepage(!), has not a dedicated documentation section! So one have to start search for information and arrives to an issue queue where the actuality of the information available is not known… |
Hello, I have personally determined to work only on documentation after version 1.4.0. Sorry about this. |
@docwilmot ++ |
@docwilmot @jenlampton I know that a new release is coming in a few days and I can imagine how hard you work! |
I've written a And I'd be grateful for testers and reviews of that workflow. This downside:
Is one I'm used to living with this in the I'm for documenting this as well. If we can get consensus that using the Now with thanks, |
Is there any update on Full import/export documentation? The import part does not work. While moving a Backdrop site to a new host, I add to import all the configurations manually by adding all the files in the staging folder. Something more automatic would have been more helpful. :-) |
@xmacinfo I share your concern that this does not seem to be documented (if it is, where is it?), but the other day I successfully used the import part. It seems to be critical to do things in the right order. Some time ago a made a personal copy of the procedure to follow - I think it may have been written somewhere by @jenlampton. This is it: Suggested procedure for moving a site to new server space:
|
I had tried out putting the staging directory into version control, but in the case of a particular site, it can lead to problems. It's probably an edge case, but thought I'd mention it. This site uses a service to deploy the code. It has the option to deploy via FTP or git. In this case it's deploying via FTP and will only FTP the files which it detects had changed. So what happens is that the staging folder will only contain the files that changed. Backdrop will assume that all the rest of the missing JSON files means the config was deleted. So the sync can't be used to import the new changes; it'll just ruin the site. So I guess we'll just use a third folder to hold the versioned files and use the export/import tarballs instead, or connect via an ftp app and upload/copy the files from the versioned directory. Though it's bit of a bother in our workflow if we're mostly just using a service to deploy code. |
I was bold and created a page about this topic on BackdropCMS.org: https://backdropcms.org/user-guide/configuration-management I don't have access to mark it unpublished, so it's live, but feel free to take it offline if it needs changes first. I basically just copied @jenlampton's post re. the 3 methods above. |
Thanks @BWPanda for doing that 👍 ...I have split that page into 3 separate child pages 😉 |
@xmacinfo, @Graham-72 is https://backdropcms.org/develop/moving-backdrop-your-local-live-server-using-cmi and https://backdropcms.org/develop/moving-backdrop-site-new-server what you were talking about, or do we need a separate documentation page for import/export specifically? |
Our dev docs have the following structure right now (omitting certain unrelated topics): ...
I would like to propose the following restructuring:
Reasoning: The initial documentation for Config Management, as written by @BWPanda, was a single-page article, which included a 3 different approaches. Splitting each approach to its own page, allowed for the parent "Configuration Management" page to serve as a landing page. There is nothing substantial there at the moment, but we have a place for things to be added.
Moving the 2 "Moving Backdrop ..." documentation pages under a parent page would allow the parent page to serve as a place for that intro documentation you are proposing @Graham-72 |
All these pages are on the API site, right? With our developer
documentation?
…On Sat, Jun 8, 2019, 5:40 PM Gregory Netsas ***@***.***> wrote:
...our dev docs have the following structure right now (omitting certain
unrelated topics):
...
- Moving Backdrop from local to live
- Moving a Backdrop site to a new server
- Configuration Management
--The extra directory approach
--The figure-8 approach
--The versioned staging directory approach
I would like to propose the following restructuring:
- Moving a Backdrop site
-- from local to live
-- to a new server
- Configuration Management
--The extra directory approach
--The figure-8 approach
--The versioned staging directory approach
Reasoning: The initial documentation for Config Management, as written by
@BWPanda <https://github.com/BWPanda>, was a single-page article, which
included a 3 different approaches. Splitting each approach to its own page,
allowed for the parent "Configuration Management" page to serve as a
landing page. There is nothing substantial there at the moment, but we have
a place for things to be added.
I think perhaps it would be helpful to also have a short tutorial that
covers the basic principles for the benefit of newcomers and also
old-timers like me who forget things.
Moving the 2 "Moving Backdrop ..." documentation pages under a parent page
would allow the parent page to serve as a place for that intro
documentation you are proposing @Graham-72 <https://github.com/Graham-72>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#855?email_source=notifications&email_token=AADBER6JEPENB4BWX52C4NDPZQYPNA5CNFSM4A7R3V4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXIAAHQ#issuecomment-500170782>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADBERY5PO6WW5YOKUVOLBTPZQYPNANCNFSM4A7R3V4A>
.
|
Nope; they live under the dev guide in b.org: https://backdropcms.org/develop/configuration-management |
Let's move them. It's going to get really confusing if we start mixing up
our docs.
…On Sat, Jun 8, 2019, 5:46 PM Gregory Netsas ***@***.***> wrote:
Nope; they live under the dev guide in b.org:
https://backdropcms.org/develop/configuration-management
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#855?email_source=notifications&email_token=AADBER76LM2PNHKVODIKPZTPZQZE3A5CNFSM4A7R3V4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXIACIY#issuecomment-500171043>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADBER7BFLK37GGH4G44HTLPZQZE3ANCNFSM4A7R3V4A>
.
|
@jenlampton Which of the config management approaches are used on Backdrop's sites:
As developers working on those sites, do we have to use a specific method, or can we use whatever we like? |
@BWPanda its all documented in the readme on each site:
These sites are all using the Versioned staging directory approach.
You have to use the method that's set up for the site. If you don't like the method we're using we can open a ticket and discuss -- and maybe choose a better one. But everyone needs to use the same method for each site. |
I think I'm confused then... The 'versioned' approach seems to indicate that:
|
Every Backdrop site will always need an active directory. Maybe that bit of
the docs needs to be updated? The point might have been that only one
directory needs to be in version control.
We've also added the live directory in Git on our sites, but only for
convenience. It doesn't need to be comitted for this pattern to work.
|
Discussion re. possible changes to our config management approach are happening in backdrop-ops/backdropcms.org#612, so considering the documentation pages have been created for the 3 approaches in general, should we close this issue now? |
Sure? |
Is there any documentation besides this area? https://api.backdropcms.org/documentation/working-configuration That gives three different workflows, but doesn't give any sort of overview of how configuration management works in the first place. For example it says "all configuration is stored in JSON files instead" but it doesn't mention where these files are found. Typos - "It's" should be "its" in two places: https://api.backdropcms.org/documentation/working-configuration
https://api.backdropcms.org/documentation/versioned-staging-directory
|
@markabur - Good points. This is probably not what you are looking for, but there are some videos that demonstrate how it works in our Youtube channel. Here is a 30 minute demonstration: |
Thanks @markabur 👍 ...I've fixed the typos + a grammar mistake. I've also tweaked https://api.backdropcms.org/documentation/working-configuration to mention where the config files are stored by default, as well as where you can look if you want to change that location. Care to have a look and let us know if that looks a bit better now? |
Not directly the same, but possibly related: It has also been suggested to make the docblocks of function config_get() and related easier to understand - currently they're pretty misleading. |
Thanks @klonos, that's a little better. Really I was looking for some sort of technical explanation of how the system works. E.g. Do the files get read from the filesystem on every page request? Is it safe to edit the configuration files directly? Is there any sort of hierarchy for overriding config files in custom modules or themes, like there is with tpl files? That sort of thing. But I can dig around and figure it out -- I was just wondering of there were more docs that I hadn't seen. |
The configuration directories are specified in
Yes.
No.
No, the only copy that matters is the one in the active directory (but all values can be overridden individually in Thank you for working on this for us!!! |
This surprises me a bit. I need to follow up on this later and understand it better. It's not something I would do often, but I also would have assumed it was possible. I suppose that "possible" and "safe" are not the same thing. ;-) |
It's possible, it's just not always safe. Since database schemas are dependent on the state of the config files, changing a file alone (but not also updating the schema) could cause serious problems for your site. You would need to know if there are any ramifications of making the change in order to do it safely. If there's a UI to change that setting in Backdrop, then the schema changes would handled as part of the submit or update handler on the form, or they could be triggered by using the config-sync UI. (These are the safe ways to manage configuration.) If there's not a UI to change that setting in Backdrop, it could be because the schema changes that would be necessary haven't been written yet, either because they are too hard, or because that change isn't possible. (Sometimes the only "safe" way to make this kind of change is to delete the old thing and create a new one) |
When we were developing the config system I always liked to say "90% of the
time it will be fine, but the other 10% you'll hose your site so badly it
will never recover."
…On Mon, Nov 30, 2020 at 12:51 PM Jen Lampton ***@***.***> wrote:
It's possible, it's just not safe. Since database schemas are dependent on
the state of the config files, changing a file alone (but not also updating
the schema) could cause serious problems.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#855 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABHY54UPUHRTEKG6HL32JDSSQAWNANCNFSM4A7R3V4A>
.
|
So whenever I synchronize my files folder down from Pantheon, I should also download the latest database -- and vice-versa? |
Either that, or you should run the config-sync UI on your local site (this is what I do with my Pantheon sites).
No, never vice-versa. Always use the config-sync tool when deploying, otherwise you are likely to overwrite anything that's happened in production while you were working locally. I also recommend using different config directories on your local site than on Pantheon. (see https://www.jenlampton.com/blog/move-your-backdrop-site-to-pantheon for more details) |
Thanks, by vice-versa I meant that whenever I copy the database down from Pantheon, I should also copy the config folder -- otherwise there could be schema issues, right? Basically, the idea is that the database snapshot is no good unless the corresponding config files are present. Is there a way to update configuration programmatically? E.g. could I save a config file in a custom module, and use an update hook to copy it into the staging directory and then sync it? Or is the UI going to be involved no matter what? |
Ah, that makes more sense :) Yes, this is correct.
Yes, this is possible (though, uncommon). It would be easier to commit the staging directory so you don't need to copy files around (see blog post above for how to do so safely on Pantheon), then use the update hook run the config-sync. Adding the update hook step would make sense if you had another update that you needed to run anyway -- but if you don't, what's the motivation for adding one? Doing a config sync is simpler than running an update, and there are drush commands for both (for sites not on pantheon) if you wanted it scripted. |
Well, on Pantheon the update functions can run automatically when the code is pushed, and there's no need to log into the site to complete the process, so to me it seems simpler and more foolproof to use an update function in that case. If I'm picturing the workflow correctly -- to me, committing to the staging directory isn't ideal as the commit history wouldn't show which lines changed in the config file, and I probably want the changes stored with a module anyway. E.g. if I have a module that creates a content type or something, and I've exported the config to files stored in that module, then later when I make changes, I'd have to export the updated config into the module (for anyone who installs the module on a fresh site later) and a second copy of it to the staging folder (to update the current site). Yes? So I figure if my module is going to have the authoritative copy of some config anyway, then it would hopefully not be too complicated to deploy that exact file rather than a second copy of it. TLDR: How do core and contrib deal with config changes? They don't ask people to use the config sync UI, or do they? |
I was afraid you might say that. This isn't the case for Backdrop sites on Pantheon. That "Run updates" checkbox does not actually run the updates.
It does for my sites. I commit the entire
Ah yeah. Using modules to manage content types is a rare occurrence in Backdrop sites now that we have config. Definitely still possible though.
Yep. But I expect you may still find copying a .json file twice faster than writing an update hook. :)
No, they use update hooks. The update loads the item that has been changed (a view, for example), modifies it exactly how needed (changes the page title, for example), and saves the item. No config files are ever re-imported, as you might loose any changes a particular site might have made to that item (a new field added to the view, for example). If you were sure that on your site no other changes had been made to the content type, your update hook could re-import the config if you wanted :) |
When config is synced via the UI or drush it will also trigger hooks such as the one in locale to search for translatable config strings. If config files are directly changed these books don't get triggered. |
@herbdool Not entirely true... Drush doesn't do this. See backdrop-contrib/backdrop-drush-extension#75 (comment) and backdrop-contrib/backdrop-drush-extension#162 |
Hi, where can I find some docs about the configuration management?
How can i work with the staging dir in files/config/staging - or what is this?
What is the best practice to work with GIT (or other version control) with my exported config files?
In other words how can I deploy my config changes without uploading a file - instead using the filesystem?
Thanks for enlighten me. ;-)
The text was updated successfully, but these errors were encountered: