Skip to content

Splits "add" command into "start" and "import" commands - #52

Merged
tannerjfco merged 9 commits into
ddev:masterfrom
tannerjfco:start-cmd
Mar 13, 2017
Merged

tannerjfco merged 9 commits into
ddev:masterfrom
tannerjfco:start-cmd

Conversation

@tannerjfco

@tannerjfco tannerjfco commented Mar 8, 2017 •

Copy link
Copy Markdown
Contributor

The Problem:

To satisfy our 0.1 target, we must be able to initialize an environment for a site without requiring an existing site's assets to import. Currently our "add" command does both.

The Fix:

This introduces a new "start" command (nevermind there was one i didn't know about somehow) and a new "import" command.

The "start" command only handles the configuration and initialization of the docker containers, returning the URL the site will be accessible at.

The "import" command handles the collection and import of assets for an existing site. It will also write the app configuration and check for 200 status.

These commands should work with both the legacy and local plugins.

The Test:

These notes are all using the drud-d7 staging site - once you are successful w/ this site feel free to test others, the process should generally be the same.

start

You should be able to reach the drupal install page following these steps:

ddev start drud-d7 staging
cd ~/.drud/local/drud-d7-staging
rm -rf src && git clone [email protected]:newmediadenver/drud-d7.git -b staging src
ddev start drud-d7 staging --db-image-tag no-db-import

This should return successfully with the URL of the site, which should then lead you to the install page.

import

Ensure that you have the latest archive saved to ~/.drud/local/staging-drud-d7.tar.gz

ddev import drud-d7 staging

This should complete the placement of files and import the database, resulting in an imported site.

Automation Overview:

We discussed and reached the concensus that we will not introduce new tests for this change, as we expect major upcoming changes would largely invalidate any tests written at this stage.

Related Issue Link(s):

#48 - parent issue
drud/mysql-docker-local#8 - removes db import from mysql container start.

Release/Deployment notes:

Does this affect anything else, or are there ramifications for other code? Does anything have to be done on deployment?

drud/mysql-docker-local#8 will need review and merge, with a new version tag to be pushed after.

@tannerjfco tannerjfco added this to the v0.1 milestone Mar 8, 2017
@rfay

rfay commented Mar 9, 2017

Copy link
Copy Markdown
Member
  1. Please update the OP to use the right verbs (instead of "add")

  2. @tannerjfco and I had a long conversation about the future of these verbs, and probably we more or less see a similar future but definitely don't have the same words yet.

I would argue for 3 basic functions (in this realm here, replacing "add")

  • init or create: Write any required site-level config files (docker-compose, whatever). It's possible these would currently not create any user-editable files.
  • start or up: With the converse verbs: Start or stop the related infrastructure (docker compose)
  • import: Pull assets into the site (will be repeatable, but explicit).

@rfay

rfay commented Mar 9, 2017

Copy link
Copy Markdown
Member

Can't ddev import please please take the name of the tarball instead of expecting it to be magically named? If that needs to be later it's ok with me.

@rfay

rfay commented Mar 9, 2017

Copy link
Copy Markdown
Member

What caught me about this is that you have to have the source checked out (or gotten another way) in the src directory first. If you just have the tarball it can't detect the type of the site.

Probably the site type should be a required argument for an init-type command? I'm not sure we're doing the right thing by auto-detecting anyway.

Probably also I don't understand the long-term intent here, and when I do it will go down better.

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Import fails on a d7 import - do we still have to push and specify a new mysql container?

Getting Resources.
time="2017-03-09T07:44:52-07:00" level=info msg="Running Command" Command="tar -xzvf /Users/rfay/.drud/local/production-drud-d7.tar.gz -C /Users/rfay/.drud/local/drud-d7-production/files --exclude=sites/default/settings.php --exclude=docroot/wp-config.php" 
time="2017-03-09T07:44:52-07:00" level=info msg="Running Command" Command="rsync -avz --recursive /Users/rfay/.drud/local/drud-d7-production/files/docroot/sites/default/files/ /Users/rfay/.drud/local/drud-d7-production/src/docroot/sites/default/files" 
time="2017-03-09T07:44:52-07:00" level=info msg="Running Command" Command="chmod -R ugo+rw /Users/rfay/.drud/local/drud-d7-production/files" 
time="2017-03-09T07:44:55-07:00" level=info msg="Drupal site. Creating settings.php file." 
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"./import.sh\": stat ./import.sh: no such file or directory"

2017-03-09 07:45:06.472888 I | exit status 126
Could not execute command.

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Most of my comments are about longstanding issues, but we need to improve error output and overall code quality as we go. Thanks for the good work on this.

Comment thread cmd/ddev/cmd/dev_sequelpro.go Outdated
if scaffold != true {
exec.Command("open", tmpFilePath).Run()
}
exec.Command("open", tmpFilePath).Run()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please check this for error and emit appropriate debugging information. I know this was pre-existing code, but we just have to fix things like this as we go.

Comment thread cmd/ddev/cmd/import.go Outdated
err = dockerutil.DockerCompose(cmdArgs...)
if err != nil {
log.Println(err)
Failed("Could not execute command.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please include the command that was trying to be executed in the Failed(). (or in the log.Println() above). It makes sorting these things out so much easier.

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.

IMHO the answer here is to make sure the DockerCompose function outputs when DRUD_DEBUG is enabled, and not make it the responsibility of the caller. In that case, we probably do need something better than "could not execute command" as output, though.

Comment thread cmd/ddev/cmd/import.go Outdated
Failed("Site never became ready")
}

color.Cyan("Successfully imported %s-%s", activeApp, activeDeploy)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a note for action as we go forward: We should be creating status functions that are named for their type rather than their color. For example, something like statusOutput(SUCCESS, "Successfully imported..."), which would then be implemented with Cyan.

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.

We actually have those, https://github.com/drud/ddev/blob/master/cmd/ddev/cmd/utils.go#L148

Could be that we want to move them out of a generic utils and into somewhere more visible.

Comment thread cmd/ddev/cmd/start.go
if err != nil {
log.Println(err)
Failed("Failed to start application.")
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd like to see these two error messages concatenated rather than using separate output techniques. Also, please add the name of the "application" for context.

Comment thread Makefile Outdated
WebTag ?= 0.2.0
DBImg ?= drud/mysql-docker-local-57
DBTag ?= 0.1.0
DBTag ?= 0.2.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good stuff. Could you edit https://github.com/drud/mysql-docker-local/releases/tag/v0.2.0 to remind us in the future what this was about? Just a trivial explanation with a link. Kind of an experimental technique for documenting tags, but might have some value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@TopherGopher

Copy link
Copy Markdown
Contributor

I tested - start and import work great. I approve

@TopherGopher TopherGopher self-assigned this Mar 10, 2017
Comment thread cmd/ddev/cmd/import.go
if err != nil {
log.Println(err)
Failed("Could not execute command.")
Failed("Could not execute command: %s", err)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd be happier if this said the command it was trying to execute, but a good step forward, thanks.

@rfay

rfay commented Mar 10, 2017

Copy link
Copy Markdown
Member

Approved, thanks. Only reservations: 1) Get @rickmanelius go-ahead from the semantic point of view (OK with me if it's not perfect) and 2) Pass tests of course.

@tannerjfco
tannerjfco merged commit 1dc4744 into ddev:master Mar 13, 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.

5 participants