Hello!

First of all, I'd like to say that DevShop is awesome! I've been using Aegir for a long time and I don't know how I only first heard of DevShop from the Greater Los Angeles Drupal meetup a couple weeks ago. :-)

I'd like to explore either seperating the 'sync' task into it's own module that can be used outside of DevShop, in normal Aegir sites.

Please let me know what you think!

Use case

I'm using Aegir for hosting client websites. They aren't using Git - they work off a standard platform that I setup (from a Drush make file) and then they have FTP access to their sites' directory to add any new modules, themes, etc. Having sync functionality would be great, because they could copy back and forth between their staging and production sites without talking to me. :-)

Sandboxes

I've started working on extracting the 'sync' task into external modules in these two sandbox projects:

If anyone wants to help out, let me know and I'll give you access to commit to the sandboxes!

Plan

  1. Get the sandbox modules working and fully featured
  2. Make some patches to DevShop to use these modules to implement it's 'sync' task (to make sure it's possible)
  3. Find a permanent home for this code (maybe merge them into provision_tasks_extra/hosting_tasks_extra - see #2096777: Include hosting_sync / provision_sync
  4. Get patches to DevShop accepted
  5. Profit! :-)

Comments

dsnopek’s picture

Title: Seperate 'sync' task into independent module? Or allow projects without Git? » Seperate 'sync' task into independent modules

I've started working on extracting the 'sync' task into external modules in these two sandbox projects:

So far, the code doesn't actually work. ;-) But I'm going to be working on it some today and then probably slowly over the next days and weeks. If anyone wants to help out, let me know and I'll give you access to commit to the sandboxes!

Once we've got something working, I'll make some patches to DevShop to use these modules to implement it's 'sync' task, just to make sure it's possible (probably with some hooks so DevShop can do DevShop-specific things).

Then I'll start looking for a permanent home for this code. I'm not sure it really makes sense as independent modules - maybe I can get them merged into provision_tasks_extra/hosting_tasks_extra or into provision/hosting themselves.

I'll update the issue description to reflect these developments in a moment...

dsnopek’s picture

Issue summary: View changes

Updated description for change in direction from "requesting information" to actually "executing a plan"

dsnopek’s picture

Issue summary: View changes

Removed reference to "today" since that doesn't make sense in the issue description.

dsnopek’s picture

Issue summary: View changes

Made the plan less narrative and more bullet point.

dsnopek’s picture

FYI, the sandbox modules actually work now! There's still a bunch of things I want to do in them though:

  • Optionally backup the destination site before overwritting it
  • Copy private files as well as public files
  • Allow optional copying of modules, themes and libraries as well
  • Document hooks
  • General clean-up!
jon pugh’s picture

Just popping in to say I support this effort!

DevShop started without the "projects" entities, with "Sync" being available on site pages. You might learn some things by going back in the project history and reading the code.

I think keeping this in its own module for now is best. Once it matures its a good candidate for hosting_tasks_extra.

I am curious how you will handle a sync form for a very large number of sites.

In the very first version of "Sync" I had a textfield for the alias to sync from!

Good luck, and keep it up! Post your results here.

dsnopek’s picture

Hi Jon,

I'm very glad to hear that you support this effort!

I am curious how you will handle a sync form for a very large number of sites.

In the very first version of "Sync" I had a textfield for the alias to sync from!

Yeah, that's a very good question. Right now, it's limiting you to sites on the same platform with the same profile. Although, it could definitely allow different platforms (and would need to for DevShop) but that also means we'd need to make sure all the same modules are available on the other platform (kind of like the "migrate" task does) and I'm punting on that for now. :-)

Maybe we could show an autocompleting textbox if the user has access to greater than 10 sites or something similar?

I've already got it limiting the clients to just the sites they have access to (via hosting_client) which is usually a small number. But admins would have access to all clients and so it could be LOTS of sites.

Anyway, I'll keep you posted on my progress!

Best regards,
David.

dsnopek’s picture

The sandbox modules are starting to become relatively robust. Earlier versions could wipe out your database if you gave an invalid source alias but now it will validate everything before beginning, perform a backup of the original site and rollback in the case of an error during sync.

However, they could use a TON more testing!

I haven't yet attempted to patch DevShop to use them, but I did create a bunch of hooks that should allow it. That's probably the next step after this gets some more testing.

Please let me know what you think if you get a chance to take a look!

helmo’s picture

ergonlogic’s picture

First off, this is a great initiative!

Right now, it's limiting you to sites on the same platform with the same profile. Although, it could definitely allow different platforms (and would need to for DevShop) but that also means we'd need to make sure all the same modules are available on the other platform (kind of like the "migrate" task does) and I'm punting on that for now. :-)

Is this limitation still in place? I think we'd really need to be able to sync between servers for this to be complete. That would allow sync'ing a live DB to a remote dev or testing environment. You may want to look at remote_import for a model there.

dsnopek’s picture

@ergonlogic: Thanks!

Is this limitation still in place? I think we'd really need to be able to sync between servers for this to be complete. That would allow sync'ing a live DB to a remote dev or testing environment. You may want to look at remote_import for a model there.

Yes, the limitation is still in place. However, it's a "soft limitation" in that we are simply preventing those sites from being listed as available sources. I think it would actually work since underneath we're using the Drush sql-sync and rsync commands which work to remote servers (AFAIK).

I just don't want to give users the option to do something unsafe, ie. sync to a platform that's using a lower version of Drupal or missing key modules. So, it's a matter of coming up with a way to check that the sync is safe (similar to how the "Migrate" task does it) and then listing those as options.

Thanks for the suggestion about remote_import - I'll definitely take a look at that when I get a chance.

jon pugh’s picture

DevShop will need some kind of hook to determine which sites can be destinations or targets. We only let users sync between sites within the same project.

Might want to use this hook to add "the limitation" when desired... maybe a setting will work here?

[ ] Allow sync between sites on different platforms

dsnopek’s picture

There is already an alter hook (hook_hosting_sync_sources_alter), which DevShop could use to add/remove sites to the source list. But there will probably be other things that DevShop needs to make this work, which I'm sure we'll run into when we start trying to patch DevShop to use this. :-) That's the next step after the current code gets a little more testing - so, please help me test it!

Yeah, a config option sounds like a good idea. That would allow people who don't want to sync between platforms to cut down the list of options.

However, there is definitely a way to check if a cross-platform sync is safe, so I see no reason NOT to allow it by default. We just have to get that safety check in there first! (And then test it like crazy...)

jon pugh’s picture

Make sure that you can still sync even if the platforms don't match up. At least make it configurable.

Say you deleted a module and just want it gone (without bothering to "uninstall".) If the module is suddenly removed from your site, Drupal will happily ignore it and turn it off for you.

I think having a configurable option for that would be good, too.

dsnopek’s picture

Sure, we can give them a "warning" like the migrate task does, but still allow them to do it. What I'm most worried about is something that is definitely not safe, for example:

  • Syncing data to a Drupal site that has a lower version than the site the data comes from (Drupal 7.22 to 7.10)
  • Syncing data to site with a module that has a lower schema version, than the same module on the site the data comes from

We can always sync to a site with higher schema versions, because updatedb will get it. But going backwards will definitely break!

Anyway, I'm envisioning that this will work just like the migrate task does. I might even be able to reuse that code, but I haven't looked at it yet.

After discussing this so much, I should just sit down and do it! :-) But I probably won't find time until the weekend atleast. If anyone else wants to take a stab at it, just let me know and I'll give you access to push to the sandbox.

dsnopek’s picture

Ok! I stole a whole bunch of code from the migrate task for checking compatibility between platforms. So, it now allows you to sync from any site, with the same profile, on a compatible platform (ie. not going backwards with schema versions). It will even show the same Updates/Warnings/Errors numbers and the comparison table.

Please give it a try if you have a chance!

helmo’s picture

This is looking good.
Including in https://drupal.org/project/hosting_tasks_extra seems like a good idea. I've opened https://drupal.org/node/2096777 for it.

helmo’s picture

Issue summary: View changes

Final changes, I swear. :-) Now that they are working, the description doesn't make sense.

jon pugh’s picture

Title: Seperate 'sync' task into independent modules » Integrate Provision Sync/Hosting Sync modules into DevShop
Priority: Normal » Major

I am all for this. From basic testing it looks awesome. The first step would be either #2121089: Promote Hosting & Provision Sync to full projects., or #2096777: Include hosting_sync / provision_sync in Hosting Tasks Extras. I am not sure at this point which would be better...

But the DevShop scripts and devmaster profile do already include Hosting Tasks Extra, so at least that means it would be a little less work for us.

DevShop would still have the provision and hosting code, because our tasks are on Project nodes.

For example,

$ drush @project provision-devshop-sync live dev

will continue to work, we would change the code for the provision-devshop-sync command to invoke provision_sync instead of just doing drush sql-sync and drush rsync.

We'll have to explore how this will all fit together, but I'm marking priority major since it also adds a lot of features! (Backups! Source/target compatibility checking! Love it.)

I am not ready to start work on this personally so if someone wants to take it on, please comment and change Assigned to yourself. I am starting to look for maintainers I trust to give commit access to, so if your patches consistently look good, I'll consider giving access.

dsnopek’s picture

@Jon Pugh: Thanks so much for testing and taking an interest in this! Unfortunately, I won't personally have any time to work on this until at least the weekend after next. :-/ If no one has started working on it by then, I'll take a shot at the changes to DevShop.

dsnopek’s picture

Issue summary: View changes

Updated issue summary for progress.

dsnopek’s picture

Ok! I was planning to work on this today, but all I've managed to do was get a development environment setup for it. :-) I'll try to dig in for real tomorrow.

dsnopek’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new6.51 KB

Attached is an initial patch to devshop_provision to do the provision part of it. It can successfully sync the database, but not everything works because the hosting part needs some adjustment first.

dsnopek’s picture

StatusFileSize
new4.96 KB

And here is a patch against devshop_hosting which implements the hosting end! I've done a bunch of testing, but more is needed. So far, I can verify that the basics work: syncing database, files and making a backup.

There may also be more opportunities for code sharing, that I'm missing. I haven't tried to be too aggressive on that, this is just the smallest changes to get it to work.

Please let me know what you think!

dsnopek’s picture

Assigned: Unassigned » dsnopek

I forgot to assign it to myself. :-)

niccolox’s picture

flagging my own focus is turning to Aegir once more for something of a sprint

I did a 3 month spell working with a proprietary Drupal hosting cloud service for an allegedly top tier university and I am interested in integrating Drupalpro/Quickstart, Aegir BOA, Devshop into some kind of toolchain

dsnopek’s picture

Issue summary: View changes

The sync modules just got accepted into hosting_task_extra and provision_task_extra: #2096777: Include hosting_sync / provision_sync

Next it's just a matter of reviewing this patch and getting it accepted into DevShop!

niccolox’s picture

is there any reason these modules - or variants therof - couldn't be included in non aegir dev or other site?

I am thinking of a bridge between a drupalpro apache site and a devshop site and then an aegir production site?

(I did think about making an extension to Backup & Migrate )

niccolox’s picture

a slightly more focussed question regarding Devshop > Hosting Sync enabled Aegir Stage > Hosting Sync enabled Aegir Prod >

does this require Valkyrie?

helmo’s picture

Hosting_sync only works inside a single hostmaster instance (which could manage multiple servers).

To bridge multiple hostmaster installs some more work needs to be done. See also https://drupal.org/project/hosting_remote_import

But lets discuss that in a separate issue.

jon pugh’s picture

Bumping. I want to get this in.

dsnopek’s picture

Bumping. I want to get this in.

Still waiting on review of my patch in #19!

jon pugh’s picture

Status: Needs review » Needs work

Making major progress getting devshop working with aegir 2.x, in branch 6.x-1.x-aegir2

Re #19, I want to remove the Project tasks completely, so the patch needs work.

Regarding Hosting Sync module itself...

I find it a bit strange to have the "Sync Data" task be on the Target site, but maybe that's just me.

I want to add a feature to devshop called "Remote Environments" which are just additional drush aliases, so users could "Sync Data" from externally hosted sites to devshop sites (and vice versa). With this feature, the "remote" would not exist as a site node, so if you were using the remote as the "source", the Sync task would make sense as it currently works.

However if we were going to allow pushing data TO a remote, the Sync task wouldn't work.

Don't know if this makes sense, but I'm happy to accept new patches to remove the "devshop-sync" task completely!

Please patch from `6.x-1.x-aegir2`, as I am not merging this branch into devshop-1.x until it is ready.

jon pugh’s picture

I find it a bit strange to have the "Sync Data" task be on the Target site, but maybe that's just me.

I've changed my mind! After a lot of UI tweaking I think I've come to see that "Deploy" is a useful word for both code and data.

DevShop now has a UI for "Deploy Code" from a branch or tag, and I think I want to follow that pattern for databases. "Deploy Data" from an environment.

I'll be working on finishing the integration of this module in the next few weeks.

dsnopek’s picture

That's awesome, Jon! Sorry I haven't had a chance to roll a new patch since your comment in September, but I'm glad to hear that this is moving forward. :-)

dsnopek’s picture

jon pugh’s picture

Status: Needs work » Fixed

So hosting_sync has been fully incorporated into devshop.

Thanks a TON for this work, it's good to have the weight of maintaining this task off of the devshop project.

jon pugh’s picture

Component: devshop_projects » Front End (devmaster, devshop_hosting, contrib)
dsnopek’s picture

Woohoo! Thanks. :-)

Status: Fixed » Closed (fixed)

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