id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c3400
errors.NotProvisionedf("volume attachment plan %q on %q", v.doc.Volume, v.doc.Machine) } return *v.doc.PlanInfo, nil }
c3401
{ return names.NewVolumeTag(v.doc.Volume) }
c3402
errors.NotProvisionedf("volume attachment %q on %q", v.doc.Volume, names.ReadableString(host)) } return *v.doc.Info, nil }
c3403
VolumeAttachmentParams{}, false } return *v.doc.Params, true }
c3404
(Volume, error) { v, err := getVolumeByTag(sb.mb, tag) return v, err }
c3405
(Volume, error) { v, err := sb.storageInstanceVolume(tag) return v, err }
c3406
if err == mgo.ErrNotFound { return nil, errors.NotFoundf("volume %q on %q", volume.Id(), names.ReadableString(host)) } else if err != nil { return nil, errors.Annotatef(err, "getting volume %q on %q", volume.Id(), names.ReadableString(host)) } return &att, nil }
c3407
return nil, errors.Annotatef(err, "getting volume attachments for machine %q", machine.Id()) } return attachments, nil }
c3408
return nil, errors.Annotatef(err, "getting volume attachments for unit %q", unit.Id()) } return attachments, nil }
c3409
return nil, errors.Annotatef(err, "getting volume attachments for volume %q", volume.Id()) } return attachments, nil }
c3410
return nil, errors.Annotatef(err, "getting volume attachment plans for volume %q", volume.Id()) } return attachmentPlans, nil }
c3411
Remove: true, }) } for _, v := range machineVolumes { if v.doc.StorageId != "" { // The volume is assigned to a storage instance; // make sure we also remove the storage instance. // There should be no storage attachments remaining, // as the units must have been removed before the // machine can be; and the storage attachments must // have been removed before the unit can be. ops = append(ops, txn.Op{ C: storageInstancesC, Id: v.doc.StorageId, Assert: txn.DocExists, Remove: true, }, ) } ops = append(ops, sb.removeVolumeOps(v.VolumeTag())...) } return ops, nil }
c3412
return false, errors.Trace(err) } return detachableVolumeDoc(&doc), nil }
c3413
create non- // persistent storage. None of the storage providers do // this, so we assume it will be persistent for now. // // TODO(axw) get rid of the Persistent field from Volume // and Filesystem. We only need to care whether the // storage is dynamic and model-scoped. return true, nil } // Volume is static, so it will be tied to the machine. return false, nil }
c3414
errors.Trace(err) } if !detachable { return nil, errors.New("volume is not detachable") } if plans, err := sb.machineVolumeAttachmentPlans(host, volume); err != nil { return nil, errors.Trace(err) } else { if len(plans) > 0 { return detachStorageAttachmentOps(host, volume), nil } } return detachVolumeOps(host, volume), nil } return sb.mb.db().Run(buildTxn) }
c3415
{ // We only ignore IsNotFound on attempts after the // first, since we expect the volume attachment to // be there initially. return nil, jujutxn.ErrNoOperations } if err != nil { return nil, errors.Trace(err) } if attachment.Life() != Dying { return nil, errors.New("volume attachment is not dying") } v, err := getVolumeByTag(sb.mb, volume) if err != nil { return nil, errors.Trace(err) } return removeVolumeAttachmentOps(host, v), nil } return sb.mb.db().Run(buildTxn) }
c3416
{ // On the first attempt, we expect it to exist. return nil, jujutxn.ErrNoOperations } else if err != nil { return nil, errors.Trace(err) } if volume.doc.StorageId != "" { return nil, errors.Errorf( "volume is assigned to %s", names.ReadableString(names.NewStorageTag(volume.doc.StorageId)), ) } if volume.Life() != Alive { return nil, jujutxn.ErrNoOperations } hasNoStorageAssignment := bson.D{{"$or", []bson.D{ {{"storageid", ""}}, {{"storageid", bson.D{{"$exists", false}}}}, }}} return destroyVolumeOps(sb, volume, false, hasNoStorageAssignment) } return sb.mb.db().Run(buildTxn) }
c3417
if errors.IsNotFound(err) { return nil, jujutxn.ErrNoOperations } else if err != nil { return nil, errors.Trace(err) } if volume.Life() != Dead { return nil, errors.New("volume is not dead") } return sb.removeVolumeOps(tag), nil } return sb.mb.db().Run(buildTxn) }
c3418
provisioned volume into the // model. Set provisioned info rather than params, and set // the status to "detached". statusDoc.Status = status.Detached doc.Info = params.volumeInfo } else { // Every new volume is created with one attachment. doc.Params = &params doc.AttachmentCount = 1 } if !detachable { doc.HostId = origHostId } return sb.newVolumeOps(doc, statusDoc), names.NewVolumeTag(name), nil }
c3419
return "", err } if params.Size == 0 { return "", errors.New("invalid size 0") } return machineId, nil }
c3420
if names.IsValidMachine(fields[0]) { hostTag = names.NewMachineTag(fields[0]) } else { hostTag = names.NewUnitTag(fields[0]) } volumeTag := names.NewVolumeTag(fields[1]) return hostTag, volumeTag, nil }
c3421
} if attachment.existing { ops = append(ops, txn.Op{ C: volumesC, Id: attachment.tag.Id(), Assert: txn.DocExists, Update: bson.D{{"$inc", bson.D{{"attachmentcount", 1}}}}, }) } } return ops }
c3422
if err := sb.setVolumeAttachmentInfo(machineTag, volumeTag, info); err != nil { return errors.Annotatef(err, "setting attachment info for volume %s", volumeTag.Id()) } } return nil }
c3423
return errors.Trace(err) } // Also ensure the machine is provisioned. if _, ok := hostTag.(names.MachineTag); ok { m, err := sb.machine(hostTag.Id()) if err != nil { return errors.Trace(err) } if _, err := m.InstanceId(); err != nil { return errors.Trace(err) } } return sb.setVolumeAttachmentInfo(hostTag, volumeTag, info) }
c3424
only have one plan for a volume if plans != nil && len(plans) > 0 { if plans[0].Life() != Dying { return nil, jujutxn.ErrNoOperations } } else { return nil, jujutxn.ErrNoOperations } return removeVolumeAttachmentPlanOps(hostTag, volume), nil } return sb.mb.db().Run(buildTxn) }
c3425
volume.Id()), Assert: bson.D{{"life", Dying}}, Remove: true, }} removeOps = append(removeOps, detachOps...) return removeOps }
c3426
if err := sb.SetVolumeInfo(volumeTag, info); err != nil { return errors.Trace(err) } } return nil }
c3427
= true } else { // Ensure immutable properties do not change. oldInfo, err := v.Info() if err != nil { return nil, err } if err := validateVolumeInfoChange(info, oldInfo); err != nil { return nil, err } } ops = append(ops, setVolumeInfoOps(tag, info, unsetParams)...) return ops, nil } return sb.mb.db().Run(buildTxn) }
c3428
nil, errors.Annotate(err, "cannot get volumes") } return volumesToInterfaces(volumes), nil }
c3429
case <-p.context.dying(): return p.context.errDying() case ids, ok := <-machinesWatcher.Changes(): if !ok { return errors.New("machines watcher closed") } tags := make([]names.MachineTag, len(ids)) for i := range ids { tags[i] = names.NewMachineTag(ids[i]) } if err := p.startMachines(tags); err != nil { return err } case m := <-p.machineDead: delete(p.machines, m.Tag()) } } }
c3430
m: return case <-changed: } } }() if err := machineLoop(context, m, changed, clock); err != nil { context.kill(err) } }
c3431
currentInstStatus { logger.Infof("machine %q instance status changed from %q to %q", m.Id(), currentInstStatus, instInfo.status) if err = m.SetInstanceStatus(instInfo.status.Status, instInfo.status.Message, nil); err != nil { logger.Errorf("cannot set instance status on %q: %v", m, err) return instanceInfo{}, err } } } if m.Life() != params.Dead { providerAddresses, err := m.ProviderAddresses() if err != nil { return instanceInfo{}, err } if !addressesEqual(providerAddresses, instInfo.addresses) { logger.Infof("machine %q has new addresses: %v", m.Id(), instInfo.addresses) if err := m.SetProviderAddresses(instInfo.addresses...); err != nil { logger.Errorf("cannot set addresses on %q: %v", m, err) return instanceInfo{}, err } } } return instInfo, nil }
c3432
for i := range ca0 { if ca0[i] != ca1[i] { logger.Tracef("address entry at offset %d has a different value for %v != %v", i, ca0, ca1) return false } } return true }
c3433
c.WriteCollection.Find(bson.D{{"model-uuid", c.modelUUID}}).Count() }
c3434
mungeDocForMultiModel(doc, c.modelUUID, modelUUIDRequired) if err != nil { return errors.Trace(err) } mungedDocs = append(mungedDocs, mungedDoc) } return c.WriteCollection.Insert(mungedDocs...) }
c3435
return c.WriteCollection.UpdateId(ensureModelUUID(c.modelUUID, sid), update) } return c.WriteCollection.UpdateId(bson.D{{"_id", id}}, update) }
c3436
service, err := st.Application(name) if err != nil { return nil, err } units, err := service.AllUnits() if err != nil { return nil, err } for _, unit := range units { unitsSet.Add(unit.Name()) } } for _, unitName := range unitsSet.SortedValues() { if !names.IsValidUnit(unitName) { return nil, errors.Errorf("invalid unit name %q", unitName) } result = append(result, names.NewUnitTag(unitName)) } return result, nil }
c3437
results, errors.Errorf("invalid machine id %q", machineId) } machines[i] = names.NewMachineTag(machineId) } actionParams := a.createActionsParams(append(units, machines...), run.Commands, run.Timeout) return queueActions(a, actionParams) }
c3438
} machines, err := a.state.AllMachines() if err != nil { return results, err } machineTags := make([]names.Tag, len(machines)) for i, machine := range machines { machineTags[i] = machine.Tag() } actionParams := a.createActionsParams(machineTags, run.Commands, run.Timeout) return queueActions(a, actionParams) }
c3439
return dependency.ErrBounce } return err }
c3440
targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().RemoveContainerImageStreamFromNonModelSettings() }, }, } }
c3441
= client.Call("Jujuc.Main", req, &resp) if err != nil && err.Error() == jujuc.ErrNoStdin.Error() { req.Stdin, err = ioutil.ReadAll(os.Stdin) if err != nil { err = errors.Annotate(err, "cannot read stdin") return } req.StdinSet = true err = client.Call("Jujuc.Main", req, &resp) } if err != nil { return } os.Stdout.Write(resp.Stdout) os.Stderr.Write(resp.Stderr) return resp.Code, nil }
c3442
upgrades.PreUpgradeSteps, "", ) jujud.Register(agentcmd.NewMachineAgentCmd(ctx, machineAgentFactory, agentConf, agentConf)) unitAgent, err := agentcmd.NewUnitAgent(ctx, bufferedLogger) if err != nil { return -1, errors.Trace(err) } jujud.Register(unitAgent) caasOperatorAgent, err := agentcmd.NewCaasOperatorAgent(ctx, bufferedLogger) if err != nil { return -1, errors.Trace(err) } jujud.Register(caasOperatorAgent) jujud.Register(agentcmd.NewCheckConnectionCommand(agentConf, agentcmd.ConnectAsAgent)) code = cmd.Main(jujud, ctx, args[1:]) return code, nil }
c3443
{ p.provisioners = make(map[string]worker.Worker) } p.provisioners[appName] = aw }
c3444
err := c.facade.FacadeCall("RunOnAllMachines", args, &results) return results.Results, err }
c3445
err := c.facade.FacadeCall("Run", run, &results) return results.Results, err }
c3446
} broker, err := newBroker(environs.OpenParams{ ControllerUUID: ctrlCfg.ControllerUUID(), Cloud: spec, Config: cfg, }) if err != nil { return "", errors.Trace(err) } return broker.APIVersion() }
c3447
return nil, errors.Trace(err) } g := EnvironConfigGetter{State: st, Model: m} return environs.GetEnviron(g, newEnviron) } }
c3448
nil, errors.Trace(err) } ctrlCfg, err := g.ControllerConfig() if err != nil { return nil, errors.Trace(err) } return newBroker(environs.OpenParams{ ControllerUUID: ctrlCfg.ControllerUUID(), Cloud: cloudSpec, Config: cfg, }) } }
c3449
err := st.db().RunTransactionFor(modelUUID, []txn.Op{op}) if err == txn.ErrAborted { return errors.NotFoundf("existing permissions") } return errors.Trace(err) }
c3450
err := lastConnections.FindId(m.st.docID(username)).Select(bson.D{{"last-connection", 1}}).One(&lastConn) if err != nil { if err == mgo.ErrNotFound { err = errors.Wrap(err, NeverConnectedError(username)) } return time.Time{}, errors.Trace(err) } return lastConn.LastConnection.UTC(), nil }
c3451
:= errors.Cause(err).(NeverConnectedError) return ok }
c3452
m.updateLastModelConnection(user, m.st.nowToTheSecond()) }
c3453
err != nil { return userAccessDoc{}, errors.Trace(err) } // DateCreated is inserted as UTC, but read out as local time. So we // convert it back to UTC here. modelUser.DateCreated = modelUser.DateCreated.UTC() return modelUser, nil }
c3454
= errors.NewNotFound(nil, fmt.Sprintf("model user %q does not exist", user.Id())) } if err != nil { return errors.Trace(err) } return nil }
c3455
asking for all=true. return false, errors.Trace(err) } isControllerSuperuser := (access.Access == permission.SuperuserAccess) return isControllerSuperuser, nil }
c3456
query.Select(bson.M{"object-uuid": 1, "_id": 0}) query.Batch(100) iter := query.Iter() var modelUUIDs []string for iter.Next(&modelUUID) { modelUUIDs = append(modelUUIDs, modelUUID.UUID) } if err := iter.Close(); err != nil { closer() return nil, nil, errors.Trace(err) } modelQuery = models.Find(bson.M{ "_id": bson.M{"$in": modelUUIDs}, "migration-mode": bson.M{"$ne": MigrationModeImporting}, }) } modelQuery.Sort("name", "owner") return modelQuery, closer, nil }
c3457
:= st.db().GetRawCollection(modelUserLastConnectionC) defer closer2() query := lastConnections.Find(bson.M{"_id": bson.M{"$in": connDocIds}}) query.Select(bson.M{"last-connection": 1, "_id": 0, "model-uuid": 1}) query.Batch(100) iter := query.Iter() lastConns := make(map[string]time.Time, len(connDocIds)) var connInfo modelUserLastConnectionDoc for iter.Next(&connInfo) { lastConns[connInfo.ModelUUID] = connInfo.LastConnection } if err := iter.Close(); err != nil { return nil, errors.Trace(err) } for i := range accessInfo { uuid := accessInfo[i].UUID accessInfo[i].LastConnection = lastConns[uuid] } return accessInfo, nil }
c3458
} if err != nil { return false, errors.Trace(err) } return ua.Access == permission.SuperuserAccess, nil }
c3459
s.ChangeConfig(func(c ConfigSetter) error { c.SetAPIHostPorts(servers) return nil }) }
c3460
= newPaths.MetricsSpoolDir } if newPaths.ConfDir != "" { p.ConfDir = newPaths.ConfDir } }
c3461
paths.MetricsSpoolDir = p.MetricsSpoolDir } if p.ConfDir != "" { paths.ConfDir = p.ConfDir } return paths }
c3462
filepath.Join(c.LogDir(), c.Tag().String()+".log") }
c3463
{ return filepath.Join(c.LogDir(), machinelock.Filename) }
c3464
configParams.Jobs, upgradedToVersion: configParams.UpgradedToVersion, tag: configParams.Tag, nonce: configParams.Nonce, controller: configParams.Controller, model: configParams.Model, caCert: configParams.CACert, oldPassword: configParams.Password, values: configParams.Values, mongoVersion: configParams.MongoVersion.String(), mongoMemoryProfile: configParams.MongoMemoryProfile.String(), } if len(configParams.APIAddresses) > 0 { config.apiDetails = &apiDetails{ addresses: configParams.APIAddresses, } } if err := config.check(); err != nil { return nil, err } if config.values == nil { config.values = make(map[string]string) } config.configFilePath = ConfigPath(config.paths.DataDir, config.tag) return config, nil }
c3465
} if serverInfo.CAPrivateKey == "" { return nil, errors.Trace(requiredError("ca cert key")) } if serverInfo.StatePort == 0 { return nil, errors.Trace(requiredError("state port")) } if serverInfo.APIPort == 0 { return nil, errors.Trace(requiredError("api port")) } config, err := NewAgentConfig(configParams) if err != nil { return nil, err } config.SetStateServingInfo(serverInfo) return config, nil }
c3466
the client on Windows. return path.Join(BaseDir(dataDir), tag.String()) }
c3467
err != nil { return nil, err } logger.Debugf("read agent config, format %q", format.version()) config.configFilePath = configFilePath return config, nil }
c3468
err != nil { return mongo.Mongo24 } return v }
c3469
return mongo.MemoryProfileLow } return mongo.MemoryProfile(c.mongoMemoryProfile) }
c3470
mongo.Version) { c.mongoVersion = v.String() }
c3471
mongo.MemoryProfile) { c.mongoMemoryProfile = v.String() }
c3472
commands = append(commands, renderer.WriteFile(filename, data)...) commands = append(commands, renderer.Chmod(filename, 0600)...) return commands, nil }
c3473
TODO(macgreagoir) IPv6. Ubuntu still always provides IPv4 // loopback, and when/if this changes localhost should resolve // to IPv6 loopback in any case (lp:1644009). Review. localAPIAddr := net.JoinHostPort("localhost", strconv.Itoa(port)) addrs = []string{localAPIAddr} } return &api.Info{ Addrs: addrs, Password: c.apiDetails.password, CACert: c.caCert, Tag: c.tag, Nonce: c.nonce, ModelTag: c.model, }, true }
c3474
c.apiDetails.addresses { host, _, err := net.SplitHostPort(addr) if err != nil { return nil, false } if host := net.JoinHostPort(host, strconv.Itoa(ssi.StatePort)); host != local { addrs = append(addrs, host) } } return &mongo.MongoInfo{ Info: mongo.Info{ Addrs: addrs, CACert: c.caCert, }, Password: c.statePassword, Tag: c.tag, }, true }
c3475
|| commonModelFacadeNames.Contains(facadeName) || commonFacadeNames.Contains(facadeName) }
c3476
" ") return errors.Wrap(e, errors.Errorf(`Declined: some terms require agreement. Try: "juju agree %s"`, terms)) }
c3477
ic.Region, ic.Series, ic.Arches, ic.Constraints, ic.Storage, ) }
c3478
Image doesn't specify virtualisation type. We allow it // to match, but prefer exact matches. return partialMatch } return nonMatch }
c3479
bool { return false }, // If the API connection fails, try again in 1 minute. RestartDelay: time.Minute, Clock: clock, }), } if err := catacomb.Invoke(catacomb.Plan{ Site: &w.catacomb, Work: w.loop, Init: []worker.Worker{w.runner}, }); err != nil { return nil, errors.Trace(err) } return &w, nil }
c3480
ctrl} mock.recorder = &MockAvailabilityZoneMockRecorder{mock} return mock }
c3481
ret0, _ := ret[0].(bool) return ret0 }
c3482
mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Available", reflect.TypeOf((*MockAvailabilityZone)(nil).Available)) }
c3483
ctrl} mock.recorder = &MockMetricsCollectorMockRecorder{mock} return mock }
c3484
{ ret := m.ctrl.Call(m, "Connections") ret0, _ := ret[0].(prometheus.Gauge) return ret0 }
c3485
{ ret := m.ctrl.Call(m, "LogReadCount", arg0, arg1) ret0, _ := ret[0].(prometheus.Counter) return ret0 }
c3486
reflect.TypeOf((*MockMetricsCollector)(nil).LogReadCount), arg0, arg1) }
c3487
m.ctrl.Call(m, "PingFailureCount", arg0) ret0, _ := ret[0].(prometheus.Counter) return ret0 }
c3488
{ ret := m.ctrl.Call(m, "TotalConnections") ret0, _ := ret[0].(prometheus.Counter) return ret0 }
c3489
apiCaller, watcher.NewStringsWatcher, ), nil }
c3490
{ l.tomb.Kill(nil) return l.tomb.Wait() }
c3491
Stop this (and parent) worker. l.tomb.Kill(ErrAddressTimeout) return invalidAddr case addr := <-l.addr: return addr } }
c3492
r.registerHookContext() return nil }
c3493
{ return } charmrevisionupdater.RegisterLatestCharmHandler("resources", resourceadapters.NewLatestCharmHandler) }
c3494
mock.recorder = &MockZonedEnvironMockRecorder{mock} return mock }
c3495
arg2 version.Number) error { ret := m.ctrl.Call(m, "AdoptResources", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 }
c3496
ret0, _ := ret[0].([]common.AvailabilityZone) ret1, _ := ret[1].(error) return ret0, ret1 }
c3497
ret0, _ := ret[0].(constraints.Validator) ret1, _ := ret[1].(error) return ret0, ret1 }
c3498
arg1) ret0, _ := ret[0].([]string) ret1, _ := ret[1].(error) return ret0, ret1 }
c3499
error { ret := m.ctrl.Call(m, "Destroy", arg0) ret0, _ := ret[0].(error) return ret0 }