Skip to content

Use named volumes for MySQL volume - #340

Merged
rickmanelius merged 11 commits into
ddev:masterfrom
beeradb:named-volumes
Jun 21, 2017
Merged

rickmanelius merged 11 commits into
ddev:masterfrom
beeradb:named-volumes

Conversation

@beeradb

@beeradb beeradb commented Jun 19, 2017 •

Copy link
Copy Markdown
Contributor

The Problem:

This is an alternative approach to #337 which uses named volumes instead of host mounted directories.

It allows MySQL data to persist even when a site is removed using ddev rm, but rather than host mounting the files, it uses the native docker volume functionality, https://docs.docker.com/compose/compose-file/#volume-configuration-reference. Personally, I think it will be easier to maintain in the long run if we just rely on what docker is giving us. That being said, I can also understand the potential UX benefits of exposing the volume as a directory.

I mostly put this together to prove to myself it would work as I expected and from there the changes were small enough that it made sense to just open a PR to compare the approaches.

The Test:

  • Start a site
  • Install drupal/wordpress
  • Remove the site
  • Start the site again
  • Observe previously installed Drupal/WP site still active.

you should also be able to change MySQL container versions without any data loss.

If we stick with this method, it might make sense to expand the ddev rm command to have an option for cleaning up the volume as well, in case users really want to start completely from scratch

Automation Overview:

I removed the previous tests around the -y flag, as ddev rm is no longer a destructive operation.

Related Issue Link(s):

#208 #337

@beeradb

beeradb commented Jun 19, 2017 •

Copy link
Copy Markdown
Contributor Author

Did some install time metrics on a vanilla d8 installation. I did three passes:

  • Pass 1: 0.66s user 0.15s system 0% cpu 1:47.35 total
  • Pass 2: 0.63s user 0.14s system 0% cpu 1:46.18 total
  • Pass 3: 0.66s user 0.16s system 0% cpu 1:46.20 total

It looks to be very consistent for me, at least.

Tested on a macbook pro with a 2.5 GHz I7 and 16 gigs of ram. My docker-for-mac settings allocate 4 CPUs and 2.0 GB of ram.

@tannerjfco

Copy link
Copy Markdown
Contributor

This approach seems to work well from my testing, and we don't incur any performance penalties going this route, which is preferable even if the penalty was determined to be negligible. I don't think I have any objections taking this approach, but we do need to figure out how data will be destroyed if desired. With the host mounted approach, we could potentially just instruct users to delete the directory to destroy. With volumes, we likely need a flag of some sort on the remove command, though I would have found one useful for the host-mounted approach as well.

@beeradb

beeradb commented Jun 20, 2017 •

Copy link
Copy Markdown
Contributor Author

Based on initial feedback from @tannerjfco and @rickmanelius it feels like there is some momentum for this direction. As such, I've updated the PR to include the following items:

  • A new flag for ddev rm, --remove-data which includes the -v flag when running docker-compose down to clean up old volumes. This doesn't currently remove settings.php, but perhaps it should?
  • Updated help text for ddev RM to reflect the new behavior.
  • removeSites() which occurs at the end of test teardown now includes the --remove-data flag. It also has a check to ensure the volumes are properly removed
  • a nginx-logs volume. It already was a volume, all this does is gives is a nice name for anyone poking around in docker volume list. We could remove this as a volume as well, the only real benefit of having it as one is that logs get persisted between container restarts, which isn't a particularly high-value feature.

@rickmanelius rickmanelius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding your question of whether we should remove settings.php. There was a PR merged last week while you were out that adds a string to the settings.php to denote whether or not ddev manages it or not. If we're managing it (along with wp-config.php for WordPress), we should remove because it would be regenerated when running ddev import-db.

@rickmanelius

Copy link
Copy Markdown
Contributor

Other than my one requested change, I think the updated flag and helper text looks good.

@tannerjfco
tannerjfco removed their request for review June 20, 2017 21:44
@tannerjfco

Copy link
Copy Markdown
Contributor

I have added the requested functionality to this PR to remove ddev-generated settings files on remove.

@rickmanelius

Copy link
Copy Markdown
Contributor

Noting that I'm beginning a test.

@rickmanelius

Copy link
Copy Markdown
Contributor

Binary Setup

➜ ~ ddev version
cli: v0.7-19-gc88cf176
web: drud/nginx-php-fpm7-local:v0.7.3
db: drud/mysql-local-57:v0.5.0
dba: drud/phpmyadmin:v0.2.0
router: drud/ddev-router:v0.4.3
commit: v0.7-19-gc88cf176
build info: Built Tue Jun 20 17:22:22 UTC 2017 circleci@default-1497979176912 drud/golang-build-container:v0.4.2

App Setup

  • Clean [email protected]:drud/wordpress.git
  • Removed the .ddev folder
  • Re-ran ddev configuration
  • ddev start

Scenario Tests

Here are the 4 things to test.

  1. Allow ddev to manage config, remove site and confirm db is there.
  2. Allow ddev to manage config, remove site w/flag and confirm db and settings are gone.
  3. Override ddev to manage config, remove site and confirm db is there.
  4. Override ddev to manage config, remove site w/flag and confirm db is gone while settings remains.

See #308 for details on removing settings.php and wp-config.php

Test 1

  • Finished the WordPress site install
  • ddev rm
  • ISSUE: wp-config.php is still there!
  • ddev start
  • Confirmed that the database is present!

Test 2

  • Using the test run from Test 1.
  • ddev rm --remove-data
  • Confirmed I see
    • Removing volume ddevwordpress_nginx-logs
    • Removing volume ddevwordpress_mysql
  • ISSUE: wp-config.php is still there!
  • ddev start
  • Confirmed that I'm at a default install page.

NOTES

@rickmanelius rickmanelius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per a conversation in Slack. The issues surrounding the generation and management of settings.php OR wp-config.php are not regressions but rather a misunderstanding on my part about the use cases when/where we consider this "managed". To that end, this functionality works as expected and I'd rather open a follow-up ticket to hash through that user flow rather than block this working functionality.

@rickmanelius

Copy link
Copy Markdown
Contributor

@beeradb Given that Tanner reviewed your previous work and that I already reviewed some of Tanner's additions, any objection to merging?

@rickmanelius
rickmanelius merged commit a489d66 into ddev:master Jun 21, 2017
beeradb added a commit that referenced this pull request Jun 22, 2017
beeradb added a commit that referenced this pull request Jun 22, 2017
rfay pushed a commit to rfay/ddev that referenced this pull request Jun 27, 2017
* [named-volumes] Use named volumes for mysql so data persists

* [named-volumes] Clean up tests and remove -y flag from ddev remove

* [named-volumes] remove -y from cleanup

* [named-volumes] remove AskForConfirmation

* [named-volumes] Add volume check during removal

* [named-volumes] Add removeData flag to remove data during site removal

* [named-volumes] Add GetVolumes() util function

* [named-volumes] update app.Down usage in local platform tests

* [named-volumes] update docs

* [named-volumes] add comment to exported function

* configure site settings path on config read, remove site settings on destructive remove
rfay pushed a commit to rfay/ddev that referenced this pull request Jun 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants