~juju-qa/ubuntu/yakkety/juju/2.0-beta10

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/upgrades.go

  • Committer: Martin Packman
  • Date: 2016-06-28 11:15:00 UTC
  • mfrom: (1.4.3)
  • Revision ID: martin.packman@canonical.com-20160628111500-3vabmx2cls3plbp1
Merge new upstream source 2.0~beta10

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
        "github.com/juju/errors"
10
10
        "github.com/juju/juju/status"
11
11
        "github.com/juju/loggo"
12
 
        "github.com/juju/names"
 
12
        "gopkg.in/juju/names.v2"
13
13
        "gopkg.in/mgo.v2/bson"
14
14
        "gopkg.in/mgo.v2/txn"
15
15
)
86
86
                        if err != nil {
87
87
                                return errors.Annotate(err, "deciding filesystem status")
88
88
                        }
 
89
                        // TODO(perrito666) 2016-05-02 lp:1558657
89
90
                        ops = append(ops, createStatusOp(st, filesystem.globalKey(), statusDoc{
90
91
                                Status:  status,
91
92
                                Updated: time.Now().UnixNano(),
214
215
}
215
216
 
216
217
func addDefaultBindingsToServices(st *State) error {
217
 
        services, err := st.AllServices()
 
218
        applications, err := st.AllApplications()
218
219
        if err != nil {
219
220
                return errors.Trace(err)
220
221
        }
221
222
 
222
 
        upgradesLogger.Debugf("adding default endpoint bindings to services (where missing)")
223
 
        ops := make([]txn.Op, 0, len(services))
224
 
        for _, service := range services {
225
 
                ch, _, err := service.Charm()
 
223
        upgradesLogger.Debugf("adding default endpoint bindings to applications (where missing)")
 
224
        ops := make([]txn.Op, 0, len(applications))
 
225
        for _, application := range applications {
 
226
                ch, _, err := application.Charm()
226
227
                if err != nil {
227
 
                        return errors.Annotatef(err, "cannot get charm for service %q", service.Name())
 
228
                        return errors.Annotatef(err, "cannot get charm for application %q", application.Name())
228
229
                }
229
 
                if _, err := service.EndpointBindings(); err == nil {
230
 
                        upgradesLogger.Debugf("service %q already has bindings (skipping)", service.Name())
 
230
                if _, err := application.EndpointBindings(); err == nil {
 
231
                        upgradesLogger.Debugf("application %q already has bindings (skipping)", application.Name())
231
232
                        continue
232
233
                } else if !errors.IsNotFound(err) {
233
 
                        return errors.Annotatef(err, "checking service %q for existing bindings", service.Name())
 
234
                        return errors.Annotatef(err, "checking application %q for existing bindings", application.Name())
234
235
                }
235
236
                // Passing nil for the bindings map will use the defaults.
236
 
                createOp, err := createEndpointBindingsOp(st, service.globalKey(), nil, ch.Meta())
 
237
                createOp, err := createEndpointBindingsOp(st, application.globalKey(), nil, ch.Meta())
237
238
                if err != nil {
238
 
                        return errors.Annotatef(err, "setting default endpoint bindings for service %q", service.Name())
 
239
                        return errors.Annotatef(err, "setting default endpoint bindings for application %q", application.Name())
239
240
                }
240
241
                ops = append(ops, createOp)
241
242
        }