Skip to content

Commit

Permalink
Construct *Unit properly for destroying;
Browse files Browse the repository at this point in the history
  • Loading branch information
ycliuhw committed Oct 22, 2020
1 parent ea0aafb commit f33c58f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions state/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,6 @@ func (st *State) cleanupUnitsForDyingApplication(applicationname string, cleanup
units, closer := st.db().GetCollection(unitsC)
defer closer()

unit := Unit{st: st}
sel := bson.D{{"application", applicationname}}
// If we're forcing then include dying and dead units, since we
// still want the opportunity to schedule fallback cleanups if the
Expand All @@ -716,7 +715,14 @@ func (st *State) cleanupUnitsForDyingApplication(applicationname string, cleanup
}
iter := units.Find(sel).Iter()
defer closeIter(iter, &err, "reading unit document")
for iter.Next(&unit.doc) {

m, err := st.Model()
if err != nil {
return errors.Trace(err)
}
var unitDoc unitDoc
for iter.Next(&unitDoc) {
unit := newUnit(st, m.Type(), &unitDoc)
op := unit.DestroyOperation()
op.DestroyStorage = destroyStorage
op.Force = force
Expand Down
2 changes: 1 addition & 1 deletion state/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (u *Unit) ContainerInfo() (CloudContainer, error) {
// ShouldBeAssigned returns whether the unit should be assigned to a machine.
// IAAS models require units to be assigned.
func (u *Unit) ShouldBeAssigned() bool {
return u.modelType == ModelTypeIAAS
return u.modelType != ModelTypeCAAS
}

// Application returns the application.
Expand Down

0 comments on commit f33c58f

Please sign in to comment.