diff --git a/cmd/ddev/cmd/remove.go b/cmd/ddev/cmd/remove.go index 60ccc0f48bd..793144eda3a 100644 --- a/cmd/ddev/cmd/remove.go +++ b/cmd/ddev/cmd/remove.go @@ -58,7 +58,7 @@ To snapshot the database on remove, use "ddev remove --snapshot"; A snapshot is // We do the snapshot if either --snapshot or --remove-data UNLESS omit-snapshot is set doSnapshot := ((createSnapshot || removeData) && !omitSnapshot) if err := app.Down(removeData, doSnapshot); err != nil { - util.Failed("Failed to remove ddev project %s: %v", app.GetName(), err) + util.Failed("Failed to remove project %s: \n%v", app.GetName(), err) } util.Success("Project %s has been removed.", app.GetName()) diff --git a/pkg/ddevapp/ddevapp.go b/pkg/ddevapp/ddevapp.go index 8915c4d92cb..315260ee5fe 100644 --- a/pkg/ddevapp/ddevapp.go +++ b/pkg/ddevapp/ddevapp.go @@ -125,7 +125,7 @@ func (app *DdevApp) Init(basePath string) error { return fmt.Errorf("a project (web container) in %s state already exists for %s that was created at %s", web.State, app.Name, containerApproot) } return nil - } else if strings.Contains(err.Error(), "could not find containers") { + } else if strings.Contains(err.Error(), "unable to find any running or stopped containers") { // Init() is just putting together the DdevApp struct, the containers do // not have to exist (app doesn't have to have been started, so the fact // we didn't find any is not an error. @@ -857,10 +857,7 @@ func (app *DdevApp) SnapshotDatabase(snapshotName string) (string, error) { } if app.SiteStatus() != SiteRunning { - err = app.Start() - if err != nil { - return snapshotName, fmt.Errorf("Failed to start project %s to snapshot database: %v", app.Name, err) - } + return "", fmt.Errorf("unable to snapshot database, \nyour project %v is not running. \nPlease start the project if you want to snapshot it. \nIf removing, you can remove without a snapshot using \n'ddev remove --remove-data --omit-snapshot', \nwhich will destroy your database", app.Name) } util.Warning("Creating database snapshot %s", snapshotName) @@ -924,7 +921,7 @@ func (app *DdevApp) Down(removeData bool, createSnapshot bool) error { // Remove all the containers and volumes for app. err = Cleanup(app) if err != nil { - return fmt.Errorf("failed to remove ddev project %s: %v", app.GetName(), err) + return err } // Remove data/database/hostname if we need to. diff --git a/pkg/dockerutil/dockerutils.go b/pkg/dockerutil/dockerutils.go index 5c47bb7d606..50b923f08fd 100644 --- a/pkg/dockerutil/dockerutils.go +++ b/pkg/dockerutil/dockerutils.go @@ -112,7 +112,7 @@ func FindContainersByLabels(labels map[string]string) ([]docker.APIContainers, e // If we couldn't find a match return a list with a single (empty) element alongside the error. if len(containerMatches) < 1 { containerMatches = []docker.APIContainers{{}} - returnError = fmt.Errorf("could not find containers which matched search criteria: %+v", labels) + returnError = fmt.Errorf("unable to find any running or stopped containers") } return containerMatches, returnError