id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c4900
if err != nil { return nil, errors.Trace(err) } sListener := &socketListener{listener: listener, handler: handler} sListener.t.Go(sListener.loop) return sListener, nil }
c4901
to close the collect-metrics listener: %v", err) } return l.t.Wait() }
c4902
Worker: jworker.NewPeriodicWorker(do, period, newTimer, jworker.Jitter(0.2)), stop: stop, } }
c4903
Watchers that are added using catacomb.Add method // miss out on a first call of Worker's Plan.Work method and can, thus, // be missing out on an initial change. plan := catacomb.Plan{ Site: &v.catacomb, Work: v.loop, Init: []worker.Worker{v.modelCredentialWatcher}, } if mc.CloudCredential != "" { var er...
c4904
providerType, cfg, err := StoragePoolConfig(pool, poolManager, registry) if err != nil { return params.FilesystemParams{}, errors.Trace(err) } result := params.FilesystemParams{ f.Tag().String(), "", // volume tag size, string(providerType), cfg.Attrs(), filesystemTags, nil, // attachment params se...
c4905
if err != nil { return names.FilesystemTag{}, state.FilesystemInfo{}, errors.Trace(err) } return filesystemTag, state.FilesystemInfo{ v.Info.Size, "", // pool is set by state v.Info.FilesystemId, }, nil }
c4906
err == nil { result.VolumeTag = volumeTag.String() } else if err != state.ErrNoBackingVolume { return params.Filesystem{}, errors.Trace(err) } return result, nil }
c4907
info.FilesystemId, info.Pool, info.Size, } }
c4908
return names.MachineTag{}, names.FilesystemTag{}, state.FilesystemAttachmentInfo{}, err } info := state.FilesystemAttachmentInfo{ in.Info.MountPoint, in.Info.ReadOnly, } return machineTag, filesystemTag, info, nil }
c4909
return params.FilesystemAttachment{ v.Filesystem().String(), v.Host().String(), FilesystemAttachmentInfoFromState(info), }, nil }
c4910
{ return params.FilesystemAttachmentInfo{ info.MountPoint, info.ReadOnly, } }
c4911
return nil, err } ids[i] = params.MachineStorageId{ MachineTag: m.String(), AttachmentTag: f.String(), } } return ids, nil }
c4912
result.ID = id if r.Payload != nil { pl, err := api.API2Payload(*r.Payload) if err != nil { return result, errors.Trace(err) } result.Payload = &pl } if r.Error != nil { result.Error = common.RestoreError(r.Error) } return result, nil }
c4913
:= range payloads { fullPayload := payload.FullPayloadInfo{Payload: pl} arg := api.Payload2api(fullPayload) args.Payloads = append(args.Payloads, arg) } return args }
c4914
payload.ParseID(fullID) args.Args = append(args.Args, params.LookUpPayloadArg{ Name: name, ID: rawID, }) } return args }
c4915
} arg.Tag = names.NewPayloadTag(id).String() args.Args = append(args.Args, arg) } return args }
c4916
description: "correct relation unit counts for subordinates", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().CorrectRelationUnitCounts() }, }, } }
c4917
} else { results, err = e.getInstanceSubnets(ctx, inst, ids, zones) } if err != nil { return nil, errors.Trace(err) } if missing := ids.Missing(); len(missing) != 0 { return nil, errors.NotFoundf("subnets %v", formatMissing(missing)) } return results, nil }
c4918
err != nil { return nil, errors.Annotatef(err, "instance %q", instId) } results = append(results, network.InterfaceInfo{ DeviceIndex: i, CIDR: details.cidr, // The network interface has no id in GCE so it's // identified by the machine's id + its name. ProviderId: network.Id(fmt.Spr...
c4919
%q", iface.Network) } result.cidr = netwk.IPv4Range result.subnet = "" result.network = network.Id(netwk.Name) } else { subnet, ok := subnets[iface.Subnetwork] if !ok { return result, errors.NotFoundf("subnet %q", iface.Subnetwork) } result.cidr = subnet.CIDR result.subnet = subnet.ProviderId r...
c4920
error) { return nil, errors.NotSupportedf("container addresses") }
c4921
{ return []network.Address{bestAddress}, nil } else { // fallback return addresses, nil } }
c4922
{ s.items.Remove(item) return true } return false }
c4923
nil } return errors.NotValidf("known service %q", v) }
c4924
return errors.NotFoundf(path) } data = current return nil }
c4925
d[path] = data return nil }
c4926
!= nil { return errors.Trace(err) } return d.Put(path, buffer) }
c4927
*ChannelAwareFakeClient { return &ChannelAwareFakeClient{channel, c} }
c4928
return c.charmstore.Get(path, value) }
c4929
// } else { // return errors.NewAlreadyExists(errors.NewErr("%v already added in channel %v", id, channel)) // } } } r.added[string(channel)] = append(alreadyAdded, *withRevision) return nil }
c4930
macaroon *macaroon.Macaroon, force bool) error { return r.AddCharm(id, channel, force) }
c4931
{ return id, r.AddCharm(id, params.NoChannel, force) }
c4932
err != nil { return nil, errors.Trace(err) } info := charms.CharmInfo{ Revision: charmDetails.Revision(), URL: charmId.String(), Config: charmDetails.Config(), Meta: charmDetails.Meta(), Actions: charmDetails.Actions(), Metrics: charmDetails.Metrics(), } return &info, nil }
c4933
return r.addRevision(ref), []string{"trusty", "wily", "quantal"}, nil }
c4934
charmData, errors.NotFoundf("cannot retrieve \"%v\": charm", id.String()) } return charmData, nil }
c4935
return nil, errors.NotFoundf(id.String()) } return bundleData, nil }
c4936
for _, channel := range channels { published := r.published[channel] published.Add(id.String()) r.published[channel] = published } return nil }
c4937
return nil, errors.Trace(err) } hash = []byte(fmt.Sprintf("%x", h.Sum(nil))) return hash, nil }
c4938
modelUUID, managedStorage: managedStorage, metadataCollection: metadataCollection, txnRunner: runner, } }
c4939
op.Update = bson.D{{ "$set", bson.D{ {"size", metadata.Size}, {"sha256", metadata.SHA256}, {"path", path}, }, }} } } return []txn.Op{op}, nil } err := s.txnRunner.Run(buildTxn) if err != nil { return errors.Annotate(err, "cannot store binary metadata") } if oldPath != "...
c4940
= fmt.Sprintf("( %s )", strings.Join(ports, " AND ")) } else if len(ports) == 1 { portList = ports[0] } return fmt.Sprintf(firewallRuleVm, envName, machineId, strings.ToLower(portRange.Protocol), portList) }
c4941
(*bakery.PublicKey, error) { return b.Service.PublicKey(), nil }
c4942
"juju model " + st.ModelUUID(), Store: store, Key: key, Locator: locator, }) if err != nil { return nil, nil, errors.Trace(err) } return service, key, nil }
c4943
s.Key, Locator: s.Locator, }) if err != nil { return nil, errors.Trace(err) } return &ExpirableStorageBakeryService{service, s.Key, store, s.Locator}, nil }
c4944
params.WorkerName, machineLock: params.MachineLock, credentialAPI: params.CredentialAPI, getNetConfig: common.GetObservedNetworkConfig, } }
c4945
} // Listen to all container lifecycle events on our machine. if watcher, err = cs.machine.WatchAllContainers(); err != nil { return nil, err } return watcher, nil }
c4946
containerType, err) // Just because dealing with one type of container fails, we won't // exit the entire function because we still want to try and start // other container types. So we take note of and return the first // such error. if resultError == nil { resultError = err } } } return err...
c4947
if err != nil { return errors.Annotate(err, "cannot discover observed network config") } if len(observedConfig) > 0 { machineTag := cs.machine.MachineTag() logger.Tracef("updating observed network config for %q %s containers to %#v", machineTag, containerType, observedConfig) if err := cs.provisioner.Set...
c4948
create one. return runner.StartWorker(workerName, func() (worker.Worker, error) { w, err := NewContainerProvisioner(containerType, provisioner, config, broker, toolsFinder, distributionGroupFinder, credentialAPI, ) if err != nil { return nil, errors.Trace(err) } return w, nil }) }
c4949
return errors.NotValidf("nil ModelGetter") } if config.NewModelWorker == nil { return errors.NotValidf("nil NewModelWorker") } if config.ErrorDelay <= 0 { return errors.NotValidf("non-positive ErrorDelay") } return nil }
c4950
// it. https://pad.lv/1644084 // Prepare URL query attributes. attrs := args.URLQuery() connection, err := source.ConnectStream("/log", attrs) if err != nil { return nil, errors.Trace(err) } messages := make(chan LogMessage) go func() { defer close(messages) for { var msg params.LogMessage err ...
c4951
the controller. If we neglected to do so, the operation could // race with a new application-charm-url change on the controller, and lead to // failures on resume in which we try to obtain archive info for a charm that // has already been removed from the controller. if err := d.callbacks.SetCurrentCharm(d.charmUR...
c4952
if err != nil { return nil, errors.Trace(err) } return d.getState(state, Done), nil }
c4953
change.Hook = &hook.Info{Kind: deployHookKinds[d.kind]} change.Step = Queued } return change.apply(state), nil }
c4954
i, res := range sr.Resources { if res.Origin != resource.OriginStore { continue } csRes := storeResources[i] // If the revision is the same then all the other info must be. if res.Revision == csRes.Revision { continue } updates = append(updates, csRes) } return updates, nil }
c4955
{ mock := &MockApiextensionsV1beta1Interface{ctrl: ctrl} mock.recorder = &MockApiextensionsV1beta1InterfaceMockRecorder{mock} return mock }
c4956
{ ret := m.ctrl.Call(m, "CustomResourceDefinitions") ret0, _ := ret[0].(v1beta10.CustomResourceDefinitionInterface) return ret0 }
c4957
"CustomResourceDefinitions", reflect.TypeOf((*MockApiextensionsV1beta1Interface)(nil).CustomResourceDefinitions)) }
c4958
{ ret := m.ctrl.Call(m, "RESTClient") ret0, _ := ret[0].(rest.Interface) return ret0 }
c4959
{ mock := &MockCustomResourceDefinitionInterface{ctrl: ctrl} mock.recorder = &MockCustomResourceDefinitionInterfaceMockRecorder{mock} return mock }
c4960
WriteAccess, LoginAccess, AddModelAccess, SuperuserAccess: return nil } return errors.NotValidf("access level %s", a) }
c4961
WriteAccess, AdminAccess: return nil } return errors.NotValidf("%q model access", access) }
c4962
ConsumeAccess, AdminAccess: return nil } return errors.NotValidf("%q offer access", access) }
c4963
return errors.NotValidf("%q cloud access", access) }
c4964
return errors.NotValidf("%q controller access", access) }
c4965
v2 := a.modelValue(), access.modelValue() if v1 < 0 || v2 < 0 { return false } return v1 >= v2 }
c4966
if v1 < 0 || v2 < 0 { return false } return v1 >= v2 }
c4967
v2 := a.cloudValue(), access.cloudValue() if v1 < 0 || v2 < 0 { return false } return v1 >= v2 }
c4968
v2 := a.offerValue(), access.offerValue() if v1 < 0 || v2 < 0 { return false } return v1 >= v2 }
c4969
= func() (StorageShowAPI, error) { return cmd.NewStorageAPI() } return modelcmd.Wrap(cmd) }
c4970
response.Results, errors.NewNotSupported(nil, err.Error()) } return response.Results, err }
c4971
api.facade.FacadeCall("ReloadSpaces", nil, nil) if params.IsCodeNotSupported(err) { return errors.NewNotSupported(nil, err.Error()) } return err }
c4972
know where the third party might be. jar := &domainCookieJar{ CookieJar: jar0, domain: os.Getenv("JUJU_USER_DOMAIN"), } var visitors []httpbakery.Visitor if ctxt != nil && opts != nil && opts.NoBrowser { filler := &form.IOFiller{ In: ctxt.Stdin, Out: ctxt.Stdout, } newVisitor := ussologin.NewVi...
c4973
ctx.jar client.WebPageVisitor = ctx.webPageVisitor return client }
c4974
err != nil { return errors.Annotatef(err, "cannot save cookie jar") } return nil }
c4975
if c.Name == domainCookieName { return cookies } } return append(cookies, &http.Cookie{ Name: domainCookieName, Value: j.domain, }) }
c4976
} return errors.Trace(sendStatusAndJSON(w, http.StatusOK, &params.CharmsResponse{ Files: manifest.SortedValues(), })) }
c4977
if ctype == params.ContentTypeXJS { ctype = params.ContentTypeJS } w.Header().Set("Content-Type", ctype) } w.Header().Set("Content-Length", strconv.Itoa(len(contents))) w.WriteHeader(http.StatusOK) io.Copy(w, bytes.NewReader(contents)) return nil } }
c4978
can do about that, // except accept non-JSON error responses in the client, because // http.ServeFile does not provide a way of customizing its // error responses. http.ServeFile(w, r, bundle.Path) return nil }
c4979
defer os.RemoveAll(tempDir) if err := ziputil.Extract(zipr, tempDir, rootDir); err != nil { return errors.Annotate(err, "cannot extract charm archive") } dir, err := charm.ReadCharmDir(tempDir) if err != nil { return errors.Annotate(err, "cannot read extracted archive") } // Now repackage the dir as a bundl...
c4980
if depth(paths[0]) == depth(paths[1]) { return "", errors.Errorf("invalid charm archive: ambiguous root directory") } } return filepath.Dir(paths[0]), nil }
c4981
version = fmt.Sprintf("%.100s", revLine) } else if !os.IsNotExist(err) { return errors.Annotate(err, "cannot open version file") } // Bundle the charm and calculate its sha256 hash at the same time. var repackagedArchive bytes.Buffer hash := sha256.New() err = charmDir.ArchiveTo(io.MultiWriter(hash, &repack...
c4982
perr, status := common.ServerErrorAndStatus(err) return errors.Trace(sendStatusAndJSON(w, status, &params.CharmsResponse{ Error: perr.Message, ErrorCode: perr.Code, ErrorInfo: perr.Info, })) }
c4983
} // The bundleContentSenderFunc will set up and send an appropriate response. if err := sender(w, r, bundle); err != nil { return errors.Trace(err) } return nil }
c4984
nil { return nil, err } return storage.NewClient(root), nil }
c4985
for _, details := range storages { storageTag, storageInfo, err := createStorageInfo(details) if err != nil { return nil, errors.Trace(err) } output[storageTag.Id()] = storageInfo } return output, nil }
c4986
mock.recorder = &MockBaseWatcherMockRecorder{mock} return mock }
c4987
:= m.ctrl.Call(m, "Dead") ret0, _ := ret[0].(<-chan struct{}) return ret0 }
c4988
mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Dead", reflect.TypeOf((*MockBaseWatcher)(nil).Dead)) }
c4989
m.ctrl.Call(m, "WatchCollection", arg0, arg1) }
c4990
{ m.ctrl.Call(m, "WatchCollectionWithFilter", arg0, arg1, arg2) }
c4991
reflect.TypeOf((*MockBaseWatcher)(nil).WatchCollectionWithFilter), arg0, arg1, arg2) }
c4992
watcher.Change) error { ret := m.ctrl.Call(m, "WatchMulti", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 }
c4993
&storage{ config: config, rootKeys: mgostorage.NewRootKeys(5), }, nil }
c4994
lines = append(lines, "\nother members:") template := "\n rs_id=%d, rs_addr=%s, tags=%v, vote=%t" for _, em := range info.extra { vote := em.Votes != nil && *em.Votes > 0 lines = append(lines, fmt.Sprintf(template, em.Id, em.Address, em.Tags, vote)) } } return strings.Join(lines, "") }
c4995
the same pointer to the loop variable is used each time. m := p.info.recognised[id] rs[id] = &m } return rs }
c4996
I think the right answer is probably to downgrade unknown members from voting. for _, member := range p.info.extra { if isVotingMember(&member) { return fmt.Errorf("voting non-machine member %v found in peer group", member) } } if len(p.info.extra) > 0 { p.desired.isChanged = true } return nil }
c4997
number of voters return } if len(p.toAddVote) > 0 { last := p.toAddVote[len(p.toAddVote)-1] logger.Debugf("number of voters would be even, not adding %q to maintain odd", last) p.toAddVote = p.toAddVote[:len(p.toAddVote)-1] return } // we must remove an extra peer // make sure we don't pick the primary ...
c4998
0 || len(p.toKeepCreateNonVotingMember) > 0 { p.desired.isChanged = true } setVoting(p.toAddVote, true) setVoting(p.toRemoveVote, false) setVoting(p.toKeepCreateNonVotingMember, false) }
c4999
logger.Debugf("create member with id %q", id) p.info.maxMemberId++ member := &replicaset.Member{ Tags: map[string]string{ jujuMachineKey: id, }, Id: p.info.maxMemberId, } setMemberVoting(member, false) p.desired.members[id] = member } }