'juju list-models' loads each Model object 3 times
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Fix Released
|
High
|
John A Meinel |
Bug Description
Tracking through the code, we have a couple bugs.
List models does this:
for _, modelUUID := range modelUUIDs {
st, release, err := m.state.
^- GetBackend is a modelManagerSta
otherState, release, err := st.pool.
...
otherModel, err := otherState.Model()
...
return modelManagerSta
that is the first load. AFAICT ListModels does nothing with this object, but we still do all the work to read it from the DB.
if err != nil {
// This model could have been removed.
if errors.
continue
}
return result, errors.Trace(err)
}
defer release()
model, err := st.Model()
if err != nil {
return result, errors.Trace(err)
}
^- our first use to load it directly
var lastConn *time.Time
userLastConn, err := model.LastModel
if err != nil {
if !state.
return result, errors.Trace(err)
}
} else {
lastConn = &userLastConn
}
model, err = st.Model()
if err != nil {
return result, errors.Trace(err)
}
^- we then load it one more time, just to be sure.
result.UserModels = append(
Model: params.Model{
Name: model.Name(),
UUID: model.UUID(),
OwnerTag: model.Owner(
},
LastConnection: lastConn,
})
}
There might be a different function we could use:
func (st modelManagerSta
model, release, err := st.pool.
...
return modelShim{model}, release, nil
}
But the above is calling st.Model() and not st.GetModel.
Changed in juju: | |
milestone: | 2.3-rc1 → 2.3.1 |
Changed in juju: | |
status: | In Progress → Fix Committed |
Changed in juju: | |
status: | Fix Committed → Fix Released |
https:/ /github. com/juju/ juju/pull/ 8128