id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c3600 |
if err := st.db().RunTransaction(ops); err == txn.ErrAborted {
if _, err := st.Space(name); err == nil {
return nil, errors.AlreadyExistsf("space %q", name)
}
for _, subnetId := range subnets {
subnet, err := st.Subnet(subnetId)
if errors.IsNotFound(err) {
return nil, err
}
if subnet.FanLocal... | |
c3601 | if err == mgo.ErrNotFound {
return nil, errors.NotFoundf("space %q", name)
}
if err != nil {
return nil, errors.Annotatef(err, "cannot get space %q", name)
}
return &Space{st, doc}, nil
} | |
c3602 | spaces := make([]*Space, len(docs))
for i, doc := range docs {
spaces[i] = &Space{st: st, doc: doc}
}
return spaces, nil
} | |
c3603 | C: spacesC,
Id: s.doc.Name,
Update: bson.D{{"$set", bson.D{{"life", Dead}}}},
Assert: isAliveDoc,
}}
txnErr := s.st.db().RunTransaction(ops)
if txnErr == nil {
s.doc.Life = Dead
return nil
}
return onAbort(txnErr, spaceNotAliveErr)
} | |
c3604 |
if s.ProviderId() != "" {
ops = append(ops, s.st.networkEntityGlobalKeyRemoveOp("space", s.ProviderId()))
}
txnErr := s.st.db().RunTransaction(ops)
if txnErr == nil {
return nil
}
return onAbort(txnErr, errors.New("not found or not dead"))
} | |
c3605 | {
mock := &MockUpgradeSeriesBackend{ctrl: ctrl}
mock.recorder = &MockUpgradeSeriesBackendMockRecorder{mock}
return mock
} | |
c3606 | {
mock := &MockUpgradeSeriesMachine{ctrl: ctrl}
mock.recorder = &MockUpgradeSeriesMachineMockRecorder{mock}
return mock
} | |
c3607 | m.ctrl.Call(m, "RemoveUpgradeSeriesLock")
ret0, _ := ret[0].(error)
return ret0
} | |
c3608 | "RemoveUpgradeSeriesLock", reflect.TypeOf((*MockUpgradeSeriesMachine)(nil).RemoveUpgradeSeriesLock))
} | |
c3609 | "Series")
ret0, _ := ret[0].(string)
return ret0
} | |
c3610 | arg1 string) error {
ret := m.ctrl.Call(m, "SetUpgradeSeriesStatus", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
} | |
c3611 | := m.ctrl.Call(m, "StartUpgradeSeriesUnitCompletion", arg0)
ret0, _ := ret[0].(error)
return ret0
} | |
c3612 | := m.ctrl.Call(m, "UpdateMachineSeries", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
} | |
c3613 | ret[0].(model.UpgradeSeriesStatus)
ret1, _ := ret[1].(error)
return ret0, ret1
} | |
c3614 | := m.ctrl.Call(m, "UpgradeSeriesTarget")
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
} | |
c3615 | := ret[0].(map[string]state.UpgradeSeriesUnitStatus)
ret1, _ := ret[1].(error)
return ret0, ret1
} | |
c3616 | ctrl}
mock.recorder = &MockUpgradeSeriesUnitMockRecorder{mock}
return mock
} | |
c3617 | "UpgradeSeriesStatus", reflect.TypeOf((*MockUpgradeSeriesUnit)(nil).UpgradeSeriesStatus))
} | |
c3618 | name, alias...); err != nil {
panic(fmt.Errorf("juju: %v", err))
}
return func() {
environs.GlobalProviderRegistry().UnregisterProvider(name)
}
} | |
c3619 | := p.(ContainerEnvironProvider); !ok {
return nil, errors.NotValidf("container environ provider %T", p)
} else {
return envProvider.Open(args)
}
} | |
c3620 | args.Charm,
Channel: args.Channel,
Storage: stateStorageConstraints(args.Storage),
Devices: stateDeviceConstraints(args.Devices),
AttachStorage: args.AttachStorage,
ApplicationConfig: args.ApplicationConfig,
CharmConfig: charmConfig,
NumUnits: args.Num... | |
c3621 | attachStorage,
})
if err != nil {
return nil, errors.Annotatef(err, "cannot add unit %d/%d to application %q", i+1, n, appName)
}
units[i] = unit
if !assignUnits {
continue
}
// Are there still placement directives to use?
if i > len(placement)-1 {
if err := unit.AssignWithPolicy(policy); err... | |
c3622 | "bootstrap-state",
Purpose: "initialize juju state",
})
} | |
c3623 | "timeout", time.Duration(0), "set the bootstrap timeout")
} | |
c3624 | toolsVersion := tools.Version
toolsVersion.Series = series
toolsVersions = append(toolsVersions, toolsVersion)
}
} else {
// Tools were downloaded from an external source: don't clone.
toolsVersions = []version.Binary{tools.Version}
}
for _, toolsVersion := range toolsVersions {
metadata := binaryst... | |
c3625 | binarystorage.Metadata{
Version: gui.Version.String(),
Size: gui.Size,
SHA256: gui.SHA256,
}); err != nil {
return errors.Annotate(err, "cannot store GUI archive")
}
if err = st.GUISetVersion(gui.Version); err != nil {
return errors.Annotate(err, "cannot set current GUI version")
}
return nil
} | |
c3626 | storeImageMetadataInState(st, env, "custom", simplestreams.CUSTOM_CLOUD_DATA, imageMetadata)
} | |
c3627 | one.Version,
},
Priority: priority,
ImageId: one.Id,
}
s, err := seriesFromVersion(one.Version)
if err != nil {
return errors.Annotatef(err, "cannot determine series for version %v", one.Version)
}
m.Series = s
if m.Stream == "" {
m.Stream = cfg.ImageStream()
}
if m.Source == "" {... | |
c3628 |
w.tomb.Go(func() error {
defer signal.Stop(c)
return w.loop(c)
})
return &w
} | |
c3629 | = func() (StorageListAPI, error) {
return cmd.NewStorageAPI()
}
return modelcmd.Wrap(cmd)
} | |
c3630 | volumes
}
if p.WantStorage {
storageInstances, err := generateListStorageOutput(p.Context, p.APIClient)
if err != nil {
return nil, errors.Trace(err)
}
combined.StorageInstances = storageInstances
}
return combined, nil
} | |
c3631 | := api.ListStorageDetails()
if err != nil {
return nil, errors.Trace(err)
}
if len(results) == 0 {
return nil, nil
}
return formatStorageDetails(results)
} | |
c3632 | == 0 && len(c.Filesystems) == 0 && len(c.Volumes) == 0
} | |
c3633 | return formatListTabular(writer, value, false)
} | |
c3634 | return formatListTabular(writer, value, true)
} | |
c3635 | return nil, err
}
if config.Clock == nil {
return nil, errors.NotValidf("missing Clock")
}
if config.MachineLock == nil {
return nil, errors.NotValidf("missing MachineLock")
}
return newWorker(agent, apiCaller, config.MachineLock, config.Clock)
},
}
} | |
c3636 | err != nil {
return nil, err
}
instanceId, err := machine.InstanceId()
if err == nil {
instanceIds = append(instanceIds, instanceId)
} else if errors.IsNotProvisioned(err) {
continue
} else {
return nil, err
}
}
return instanceIds, nil
} | |
c3637 | principal := range machine.Principals() {
principalSet.Add(unitAppName(principal))
}
if principalSet.Contains(applicationName) {
machineIds = append(machineIds, machine.Id())
}
}
return machineIds, nil
} | |
c3638 | NewAddress(value)
addr.SpaceName = SpaceName(spaceName)
return addr
} | |
c3639 | len(inAddresses))
for i, address := range inAddresses {
outAddresses[i] = NewAddress(address)
}
return outAddresses
} | |
c3640 | inAddresses {
outAddresses[i] = NewAddressOnSpace(spaceName, address)
}
return outAddresses
} | |
c3641 |
case ip.To16() != nil:
return IPv6Address
default:
panic("Unknown form of IP address")
}
} | |
c3642 |
return ScopeFanLocal
}
if ip.IsLinkLocalMulticast() ||
ip.IsLinkLocalUnicast() ||
ip.IsInterfaceLocalMulticast() {
return ScopeLinkLocal
}
if ip.IsGlobalUnicast() {
return ScopePublic
}
return addr.Scope
} | |
c3643 | addr.Scope == scope {
return true
}
}
return false
} | |
c3644 | address in space %q", addr.Value, addr.SpaceName)
selectedAddresses = append(selectedAddresses, addr)
}
}
if len(selectedAddresses) > 0 {
return selectedAddresses, true
}
logger.Errorf("no addresses found in spaces %s", spaceNames)
return addresses, false
} | |
c3645 | a hostPort in space %q", hp.Value, hp.SpaceName)
selectedHostPorts = append(selectedHostPorts, hp)
}
}
if len(selectedHostPorts) > 0 {
return selectedHostPorts, true
}
logger.Errorf("no hostPorts found in spaces %s", spaceNames)
return hps, false
} | |
c3646 | }, publicMatch)
if index < 0 {
return ""
}
return hps[index].NetAddr()
} | |
c3647 | out := make([]Address, 0, len(indexes))
for _, index := range indexes {
out = append(out, addresses[index])
}
return out
} | |
c3648 | }, internalAddressMatcher(machineLocal))
if index < 0 {
return ""
}
return hps[index].NetAddr()
} | |
c3649 |
out := make([]string, 0, len(indexes))
for _, index := range indexes {
out = append(out, hps[index].NetAddr())
}
return out
} | |
c3650 | binary.BigEndian.PutUint32(bytes, addr)
return net.IP(bytes)
} | |
c3651 | valid IPv4 address", ipv4Addr.String())
}
return binary.BigEndian.Uint32([]byte(ip)), nil
} | |
c3652 | filesystem.Volume == (names.VolumeTag{}) {
// Filesystem is not volume-backed.
continue
}
if _, ok := ctx.volumeBlockDevices[filesystem.Volume]; ok {
// Backing-volume's block device is already attached.
continue
}
var found bool
for _, tag := range volumeTags {
if filesystem.Volume == tag {
... | |
c3653 | Clear out the pending set, so we don't force-refresh again.
ctx.pendingVolumeBlockDevices = names.NewSet()
return refreshVolumeBlockDevices(ctx, volumeTags)
} | |
c3654 | filesystem, ok := ctx.filesystems[params.Filesystem]
if !ok {
continue
}
if filesystem.Volume == volumeTags[i] {
updatePendingFilesystemAttachment(ctx, id, params)
}
}
} else if params.IsCodeNotProvisioned(result.Error) || params.IsCodeNotFound(result.Error) {
// Either the volume (a... | |
c3655 | <= 1 {
return nil, errors.Errorf("expected multiple stores")
}
return layeredStorage(s), nil
} | |
c3656 | m Metadata) error {
return s[0].Add(r, m)
} | |
c3657 | = s.Open(v)
if !errors.IsNotFound(err) {
break
}
}
return m, rc, err
} | |
c3658 | if !errors.IsNotFound(err) {
break
}
}
return m, err
} | |
c3659 |
if err != nil {
return nil, err
}
for _, m := range sm {
if seen.Contains(m.Version) {
continue
}
all = append(all, m)
seen.Add(m.Version)
}
}
return all, nil
} | |
c3660 | := newRemoveStagedResourceOps(staged.id)
return ops, nil
}
if err := staged.base.Run(buildTxn); err != nil {
return errors.Trace(err)
}
return nil
} | |
c3661 | if err != nil {
logger.Errorf("can't read existing resource during activate: %v", errors.Details(err))
return nil, errors.Trace(err)
}
if hasNewBytes {
incOps := staged.base.IncCharmModifiedVersionOps(staged.stored.ApplicationID)
ops = append(ops, incOps...)
}
}
return ops, nil
}
if er... | |
c3662 | {
return a.st.localID(a.doc.DocId)
} | |
c3663 | a.doc.Results, a.doc.Message
} | |
c3664 | Update: bson.D{{"$set", bson.D{
{"status", ActionRunning},
{"started", a.st.nowToTheSecond()},
}}},
}})
if err != nil {
return nil, err
}
return m.Action(a.Id())
} | |
c3665 | a.removeAndLog(results.Status, results.Results, results.Message)
} | |
c3666 | {"status", finalStatus},
{"message", message},
{"results", results},
{"completed", a.st.nowToTheSecond()},
}}},
}, {
C: actionNotificationsC,
Id: m.st.docID(ensureActionMarker(a.Receiver()) + a.Id()),
Remove: true,
}})
if err != nil {
return nil, err
}
return m.Action(a.Id(... | |
c3667 | &action{
st: st,
doc: adoc,
}
} | |
c3668 | receiverTag.Id(),
Name: actionName,
Parameters: parameters,
Enqueued: mb.nowToTheSecond(),
Status: ActionPending,
}, actionNotificationDoc{
DocId: mb.docID(prefix + actionId.String()),
ModelUUID: modelUUID,
Receiver: receiverTag.Id(),
ActionID: actionId.String(),
}, nil
} | |
c3669 | }
if err != nil {
return nil, errors.Annotatef(err, "cannot get action %q", id)
}
actionLogger.Tracef("Action() %q found %+v", id, doc)
return newAction(st, doc), nil
} | |
c3670 | errors.Annotatef(err, "cannot get all actions")
}
for _, doc := range docs {
results = append(results, newAction(m.st, doc))
}
return results, nil
} | |
c3671 | (Action, error) {
return m.Action(tag.Id())
} | |
c3672 | %+v", doc)
localID := m.st.localID(doc.Id)
if names.IsValidAction(localID) {
results = append(results, names.NewActionTag(localID))
}
}
actionLogger.Tracef("FindActionTagsByPrefix() %q found %+v", prefix, results)
return results
} | |
c3673 |
for iter.Next(&doc) {
results = append(results, newAction(m.st, doc))
}
return results, errors.Trace(iter.Close())
} | |
c3674 | return st.matchingActionsByReceiverId(ar.Tag().Id())
} | |
c3675 |
for iter.Next(&doc) {
actions = append(actions, newAction(st, doc))
}
return actions, errors.Trace(iter.Close())
} | |
c3676 |
completed := bson.D{{"status", ActionPending}}
return st.matchingActionsByReceiverAndStatus(ar.Tag(), completed)
} | |
c3677 |
completed := bson.D{{"status", ActionRunning}}
return st.matchingActionsByReceiverAndStatus(ar.Tag(), completed)
} | |
c3678 | {{"status", ActionFailed}},
}}}
return st.matchingActionsByReceiverAndStatus(ar.Tag(), completed)
} | |
c3679 | statusCondition...)
iter := actionsCollection.Find(sel).Iter()
for iter.Next(&doc) {
actions = append(actions, newAction(st, doc))
}
return actions, errors.Trace(iter.Close())
} | |
c3680 | Config: convertCharmConfig(info.Config),
Meta: meta,
Actions: convertCharmActions(info.Actions),
Metrics: convertCharmMetrics(info.Metrics),
LXDProfile: convertCharmLXDProfile(info.LXDProfile),
}
return result, nil
} | |
c3681 | tests where we don't actually want to
// require a valid cloud.
Ping: func(p environs.EnvironProvider, endpoint string) error {
return p.Ping(cloudCallCtx, endpoint)
},
store: store,
}
c.addCloudAPIFunc = c.cloudAPI
return modelcmd.WrapBase(c)
} | |
c3682 | ctxt.Infof(
"There are no controllers running.\nAdding cloud to local cache so you can use it to bootstrap a controller.\n")
}
return addLocalCloud(c.cloudMetadataStore, *newCloud)
}
// A controller has been specified so upload the cloud details
// plus a corresponding credential to the controller.
api,... | |
c3683 | := cert.ParseCert(certificate); err != nil {
return filename, nil, errors.Annotate(err, "bad cloud CA certificate")
}
vals["ca-certificates"] = []string{certificate}
} else {
return filename, nil, errors.NotFoundf("yaml has no certificate file")
}
alt, err := yaml.Marshal(vals)
return filename, alt, err
... | |
c3684 | = append(providers, name)
} else {
unsupported = append(unsupported, name)
}
}
sort.Strings(providers)
return providers, unsupported, nil
} | |
c3685 | return "", errors.Trace(err)
}
if _, ok := builtin[name]; ok {
return fmt.Sprintf("%q is the name of a built-in cloud", name), nil
}
return "", nil
} | |
c3686 | common.ErrPerm
}
return &Facade{
backend: backend,
resources: resources,
}, nil
} | |
c3687 |
}
for i, entity := range entities.Entities {
phase, err := facade.onePhase(entity.Tag)
results.Results[i].Phase = phase
results.Results[i].Error = common.ServerError(err)
}
return results
} | |
c3688 | phase, err := facade.backend.MigrationPhase()
if err != nil {
return "", errors.Trace(err)
}
return phase.String(), nil
} | |
c3689 | count),
}
for i, entity := range entities.Entities {
id, err := facade.oneWatch(entity.Tag)
results.Results[i].NotifyWatcherId = id
results.Results[i].Error = common.ServerError(err)
}
return results
} | |
c3690 | if err != nil {
return nil, err
}
return spool.NewPeriodicWorker(collector.Do, collector.period, jworker.NewTimer, collector.stop), nil
},
}
} | |
c3691 | else if err != nil {
return errors.Annotate(err, "failed to instantiate metric recorder")
}
err = w.charmdir.Visit(func() error {
return w.runner.do(recorder)
}, stop)
if err == fortress.ErrAborted {
logger.Tracef("cannot execute collect-metrics: %v", err)
return nil
}
if spool.IsMetricsDataError(err) {... | |
c3692 | {
return internalNewCredentialValidatorAPI(NewBackend(NewStateShim(ctx.State())), ctx.Resources(), ctx.Auth())
} | |
c3693 | != nil {
return nil, err
}
return &CredentialValidatorAPIV1{v2}, nil
} | |
c3694 | // Consume the initial event. Technically, API calls to Watch
// 'transmit' the initial event in the Watch response. But
// NotifyWatchers have no state to transmit.
if _, ok := <-watch.Changes(); ok {
result.NotifyWatcherId = api.resources.Register(watch)
} else {
err = watcher.EnsureErr(watch)
result.Error... | |
c3695 | c.Model.String(),
CloudCredential: c.Credential.String(),
Exists: c.Exists,
Valid: c.Valid,
}, nil
} | |
c3696 | initial event. Technically, API calls to Watch
// 'transmit' the initial event in the Watch response. But
// NotifyWatchers have no state to transmit.
if _, ok := <-watch.Changes(); ok {
result.NotifyWatcherId = api.resources.Register(watch)
} else {
err = watcher.EnsureErr(watch)
result.Error = common.Serve... | |
c3697 | return nil, common.ErrPerm
}
return &Facade{
LifeGetter: common.NewLifeGetter(
st, common.AuthAny(
common.AuthFuncForTagKind(names.ApplicationTagKind),
common.AuthFuncForTagKind(names.UnitTagKind),
),
),
resources: resources,
state: st,
storage: sb,
devices:... | |
c3698 | if err != nil {
results.Results[i].Error = common.ServerError(err)
continue
}
results.Results[i].NotifyWatcherId = id
}
return results, nil
} | |
c3699 | err := f.watchPodSpec(model, arg.Tag)
if err != nil {
results.Results[i].Error = common.ServerError(err)
continue
}
results.Results[i].NotifyWatcherId = id
}
return results, nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.