Skip to content

Commit

Permalink
app: disable routes rebuild during app update
Browse files Browse the repository at this point in the history
  • Loading branch information
andrestc committed Nov 30, 2018
1 parent 8a82867 commit d8ff339
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 15 additions & 1 deletion app/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/tsuru/tsuru/provision"
"github.com/tsuru/tsuru/repository"
"github.com/tsuru/tsuru/router"
"github.com/tsuru/tsuru/router/rebuild"
"github.com/tsuru/tsuru/servicemanager"
appTypes "github.com/tsuru/tsuru/types/app"
permTypes "github.com/tsuru/tsuru/types/permission"
Expand Down Expand Up @@ -476,7 +477,7 @@ var provisionAppNewProvisioner = action.Action{

var provisionAppAddUnits = action.Action{
Name: "provision-app-add-unit",
Forward: func(ctx action.FWContext) (action.Result, error) {
Forward: func(ctx action.FWContext) (result action.Result, err error) {
app, ok := ctx.Params[0].(*App)
if !ok {
return nil, errors.New("expected app ptr as first arg")
Expand All @@ -494,6 +495,17 @@ var provisionAppAddUnits = action.Action{
for _, u := range units {
unitCount[u.ProcessName]++
}
routers := app.Routers
router := app.Router
app.Routers = nil
app.Router = ""
defer func() {
app.Routers = routers
app.Router = router
if err == nil {
_, err = rebuild.RebuildRoutes(app, false)
}
}()
for process, count := range unitCount {
err = app.AddUnits(count, process, w)
if err != nil {
Expand All @@ -503,6 +515,8 @@ var provisionAppAddUnits = action.Action{
return nil, err
},
Backward: func(ctx action.BWContext) {
app := ctx.Params[0].(*App)
rebuild.RoutesRebuildOrEnqueue(app.Name)
},
}

Expand Down
5 changes: 3 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ func (app *App) Update(updateData App, w io.Writer) (err error) {
if updateData.UpdatePlatform {
app.UpdatePlatform = true
}

err = app.validate()
if err != nil {
return err
Expand All @@ -520,11 +519,13 @@ func (app *App) Update(updateData App, w io.Writer) (err error) {
actions = append(actions, &updateAppProvisioner)
}
if newProv.GetName() != oldProv.GetName() {
defer func() {
rebuild.RoutesRebuildOrEnqueue(app.Name)
}()
err = validateVolumes(app)
if err != nil {
return err
}

actions = append(actions,
&provisionAppNewProvisioner,
&provisionAppAddUnits,
Expand Down

0 comments on commit d8ff339

Please sign in to comment.