func setPoolToApps() error { db, err := db.Conn() if err != nil { return err } defer db.Close() var apps []app.App var tooManyPoolsApps []app.App err = db.Apps().Find(nil).All(&apps) if err != nil { return err } for _, a := range apps { err = a.SetPool() if err != nil { tooManyPoolsApps = append(tooManyPoolsApps, a) continue } err = db.Apps().Update(bson.M{"name": a.Name}, bson.M{"$set": bson.M{"pool": a.Pool}}) if err != nil { return err } } if len(tooManyPoolsApps) > 0 { fmt.Println("Apps bellow couldn't be migrated because they are in more than one pool.") fmt.Println("To fix this, please run `tsuru app-change-pool <pool_name> -a app` for each app.") fmt.Println("*****************************************") for _, a := range tooManyPoolsApps { fmt.Println(a.Name) } } return nil }
func migrateServiceProxyActions() error { db, err := db.Conn() if err != nil { return err } defer db.Close() _, err = db.UserActions().UpdateAll( bson.M{"action": "service-proxy-status"}, bson.M{"$set": bson.M{"action": "service-instance-proxy"}}, ) return err }
func migratePool() error { db, err := db.Conn() if err != nil { return err } defer db.Close() poolColl := db.Collection("pool") if err != nil { return err } var pools []provision.Pool err = db.Collection("docker_scheduler").Find(nil).All(&pools) if err != nil { return err } for _, p := range pools { err = poolColl.Insert(p) if err != nil { return err } } return nil }