Skip to content

Commit

Permalink
Convert fortress errors in the uniter
Browse files Browse the repository at this point in the history
In order to prevent the uniter from putting the unit into error when
it's dependents shut down in preparation for a model migration, an error
translation function is now injected.
  • Loading branch information
Menno Smits committed Dec 15, 2016
1 parent 9f5f26d commit a9445ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/jujud/agent/unit/manifolds.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func Manifolds(config ManifoldsConfig) dependency.Manifolds {
LeadershipTrackerName: leadershipTrackerName,
CharmDirName: charmDirName,
HookRetryStrategyName: hookRetryStrategyName,
TranslateResolverErr: uniter.TranslateFortressErrors,
})),

// TODO (mattyw) should be added to machine agent.
Expand Down
12 changes: 12 additions & 0 deletions worker/uniter/manifold.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/juju/juju/worker/dependency"
"github.com/juju/juju/worker/fortress"
"github.com/juju/juju/worker/uniter/operation"
"github.com/juju/juju/worker/uniter/resolver"
)

// ManifoldConfig defines the names of the manifolds on which a
Expand Down Expand Up @@ -109,3 +110,14 @@ func Manifold(config ManifoldConfig) dependency.Manifold {
},
}
}

// TranslateFortressErrors turns errors returned by dependent
// manifolds due to fortress lockdown (i.e. model migration) into an
// error which causes the resolver loop to be restarted. When this
// happens the uniter is about to be shut down anyway.
func TranslateFortressErrors(err error) error {
if fortress.IsFortressError(err) {
return resolver.ErrRestart
}
return err
}

0 comments on commit a9445ca

Please sign in to comment.