id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c4100
continue } w.logger.Errorf("failed to unpin leader for application %q: %s", app, err.Error()) lastErr = err } if lastErr == nil { w.leadersPinned = false return nil } return errors.Trace(lastErr) }
c4101
return nil, errors.Trace(err) } return service.FindUnitServiceNames(services), nil }
c4102
range units { unitIds[i] = u i++ } return strings.Join(unitIds, ", ") }
c4103
fmt.Sprintf(HTTPEndpointPath, application, name) }
c4104
= url.Query().Get(":resource") return application, name }
c4105
`Basic realm="juju"`) } w.Header().Set("Content-Type", params.ContentTypeJSON) w.Header().Set("Content-Length", fmt.Sprint(len(body))) w.WriteHeader(statusCode) w.Write(body) }
c4106
return config.Facade.SetModelStatus(config.ModelTag, s, info, nil) } if err := setStatus(status.Available, ""); err != nil { return errors.Trace(err) } config.GateUnlocker.Unlock() return nil }), nil }
c4107
{ return nil, errors.Trace(err) } return &API{ access: getState(st, m), authorizer: authorizer, }, nil }
c4108
entityResults := []params.AnnotationsGetResult{} for _, entity := range args.Entities { anEntityResult := params.AnnotationsGetResult{EntityTag: entity.Tag} if annts, err := api.getEntityAnnotations(entity.Tag); err != nil { anEntityResult.Error = params.ErrorResult{annotateError(err, entity.Tag, "getting")} } else { anEntityResult.Annotations = annts } entityResults = append(entityResults, anEntityResult) } return params.AnnotationsGetResults{Results: entityResults} }
c4109
:= api.setEntityAnnotations(entityAnnotation.EntityTag, entityAnnotation.Annotations) if err != nil { setErrors = append(setErrors, params.ErrorResult{Error: annotateError(err, entityAnnotation.EntityTag, "setting")}) } } return params.ErrorResults{Results: setErrors} }
c4110
err != nil { return errors.Trace(err) } if err := c.promptConfirmation(ctx, units); err != nil { return errors.Trace(err) } if err = c.upgradeMachineSeriesClient.UpgradeSeriesPrepare(c.machineNumber, c.series, c.force); err != nil { return errors.Trace(err) } if err = c.handleNotifications(ctx); err != nil { return errors.Trace(err) } m := UpgradeSeriesPrepareFinishedMessage + "\n" ctx.Infof(m, c.machineNumber) return nil }
c4111
for { select { case <-c.catacomb.Dying(): return c.catacomb.ErrDying() case <-uw.Changes(): err = c.handleUpgradeSeriesChange(ctx, wid) if err != nil { return errors.Trace(err) } } } } }
c4112
if err := c.handleNotifications(ctx); err != nil { return errors.Trace(err) } m := UpgradeSeriesCompleteFinishedMessage + "\n" ctx.Infof(m, c.machineNumber) return nil }
c4113
fixed, also fix code in status.go for UnitAgent. if info.Status == status.Error { return status.StatusInfo{ Status: status.Idle, Message: "", Data: map[string]interface{}{}, Since: info.Since, }, nil } return info, nil }
c4114
shouldBeAssigned { return errors.Errorf("cannot set invalid status %q", unitAgentStatus.Status) } case status.Lost: return errors.Errorf("cannot set status %q", unitAgentStatus.Status) default: return errors.Errorf("cannot set invalid status %q", unitAgentStatus.Status) } return setStatus(u.st.db(), setStatusParams{ badge: "agent", globalKey: u.globalKey(), status: unitAgentStatus.Status, message: unitAgentStatus.Message, rawData: unitAgentStatus.Data, updated: timeOrNow(unitAgentStatus.Since, u.st.clock()), }) }
c4115
= networkDefaultName } return networkPathRoot + name }
c4116
if using a reserved public IP) }) // TODO(ericsnow) Will we need to support more access configs? } return &compute.NetworkInterface{ Network: ns.Path(), AccessConfigs: access, } }
c4117
sort.Strings(sortedProtocols) for _, protocol := range sortedProtocols { allowed := compute.FirewallAllowed{ IPProtocol: protocol, Ports: ports.portStrings(protocol), } firewall.Allowed = append(firewall.Allowed, &allowed) } return &firewall }
c4118
!= nil { status[i].Error = ServerError(err) continue } status[i] = modelStatus } return params.ModelStatusResults{Results: status}, nil }
c4119
} out[i] = params.ModelFilesystemInfo{ Id: in.Tag().Id(), ProviderId: providerId, Status: statusString, Message: status.Message, Detachable: in.Detachable(), } } return out }
c4120
} out[i] = params.ModelVolumeInfo{ Id: in.Tag().Id(), ProviderId: providerId, Status: statusString, Message: status.Message, Detachable: in.Detachable(), } } return out }
c4121
v.value = r.FakeId() } else if !errors.IsNotFound(err) { return nil, errors.Trace(err) } *result = id return v, nil }
c4122
} if _, err := v.ctx.Relation(id); err != nil { return errors.Trace(err) } *v.result = id v.value = value return nil }
c4123
return "" } return UserFriendlyDuration(*when, now) }
c4124
modelInfo.Status = status } status.Migration = info.Migration.Status status.MigrationStart = FriendlyDuration(info.Migration.Start, now) status.MigrationEnd = FriendlyDuration(info.Migration.End, now) } if info.ProviderType != "" { modelInfo.ProviderType = info.ProviderType } if len(info.Users) != 0 { modelInfo.Users = ModelUserInfoFromParams(info.Users, now) } if len(info.Machines) != 0 { modelInfo.Machines = ModelMachineInfoFromParams(info.Machines) } if info.SLA != nil { modelInfo.SLA = ModelSLAFromParams(info.SLA) modelInfo.SLAOwner = ModelSLAOwnerFromParams(info.SLA) } if info.CloudCredentialTag != "" { credTag, err := names.ParseCloudCredentialTag(info.CloudCredentialTag) if err != nil { return ModelInfo{}, errors.Trace(err) } modelInfo.Credential = &ModelCredential{ Name: credTag.Name(), Owner: credTag.Owner().Id(), Cloud: credTag.Cloud().Id(), } } return modelInfo, nil }
c4125
return modelName } return jujuclient.JoinOwnerModelName(owner, modelName) }
c4126
CharmResourcesCommand c.setResourceLister(resourceLister) return modelcmd.Wrap(&c) }
c4127
:= getCharmStoreAPIURL(conAPIRoot) if err != nil { return nil, errors.Trace(err) } client, err := charmstore.NewCustomClient(bakeryClient, csURL) if err != nil { return nil, errors.Trace(err) } return client.ListResources(ids) }
c4128
if newMaxAge != maxAge || newMaxCollectionMB != maxCollectionMB { logger.Infof("status history config: max age: %v, max collection size %dM for %s (%s)", newMaxAge, newMaxCollectionMB, modelConfig.Name(), modelConfig.UUID()) maxAge = newMaxAge maxCollectionMB = newMaxCollectionMB } if timer == nil { timer = w.config.Clock.NewTimer(w.config.PruneInterval) timerCh = timer.Chan() } case <-timerCh: err := w.config.Facade.Prune(maxAge, int(maxCollectionMB)) if err != nil { return errors.Trace(err) } timer.Reset(w.config.PruneInterval) } } }
c4129
values failed") } cfg, err = provider.PrepareConfig(environs.PrepareConfigParams{ Cloud: cloud, Config: cfg, }) if err != nil { return nil, errors.Annotate(err, "provider config preparation failed") } cfg, err = provider.Validate(cfg, nil) if err != nil { return nil, errors.Annotate(err, "provider config validation failed") } return cfg, nil }
c4130
:= args.Client.ProvisioningScript(params.ProvisioningScriptParams{ MachineId: machineId, Nonce: machineParams.Nonce, DisablePackageCommands: !args.EnableOSRefreshUpdate && !args.EnableOSUpgrade, }) if err != nil { logger.Errorf("cannot obtain provisioning script") return "", err } // Finally, provision the machine agent. err = runProvisionScript(provisioningScript, args.Host, args.Stderr) if err != nil { return machineId, err } logger.Infof("Provisioned machine %v", machineId) return machineId, nil }
c4131
return credentialvalidator.NewFacade(apiCaller), nil }
c4132
dying, InvalidateCredentialFunc: c.InvalidateModelCredential, } }
c4133
newAPIRoot) (blockClientAPI, error) { return getBlockAPI(c) }, }) }
c4134
return &DeployerAPI{ Remover: common.NewRemover(st, true, getAuthFunc), PasswordChanger: common.NewPasswordChanger(st, getAuthFunc), LifeGetter: common.NewLifeGetter(st, getAuthFunc), APIAddresser: common.NewAPIAddresser(st, resources), UnitsWatcher: common.NewUnitsWatcher(st, resources, getCanWatch), StatusSetter: common.NewStatusSetter(st, getAuthFunc), st: st, resources: resources, authorizer: authorizer, }, nil }
c4135
return d.StatusSetter.SetStatus(args) }
c4136
ok := <-watch.Changes(); ok { return units, nil } return nil, fmt.Errorf("cannot obtain units of machine %q: %v", tag, watch.Err()) }
c4137
{ return c.NewModelManagerAPIClient() } return modelcmd.Wrap(c) }
c4138
the backup") f.StringVar(&c.BackupId, "id", "", "Provide the name of the backup to be restored") }
c4139
backup id but not both.") } if c.Filename != "" { var err error c.Filename, err = filepath.Abs(c.Filename) if err != nil { return errors.Trace(err) } } return nil }
c4140
client, err := c.NewAPIClient() if err != nil { return errors.Trace(err) } defer client.Close() // We have a backup client, now use the relevant method // to restore the backup. if c.Filename != "" { err = client.RestoreReader(archive, meta, c.newClient) } else { err = client.Restore(c.BackupId, c.newClient) } if err != nil { return errors.Trace(err) } fmt.Fprintf(ctx.Stdout, "restore from %q completed\n", target) return nil }
c4141
error { return w.loop(started) }) select { case <-started: case <-time.After(10 * time.Second): return nil, errors.New("worker failed to start properly") } return w, nil }
c4142
return manager.Claimer(singularControllerNamespace, st.modelUUID()) }} }
c4143
charm.RolePeer: return charm.RolePeer } panic(fmt.Errorf("unknown relation role %q", r)) }
c4144
ep.Role != charm.RolePeer && counterpartRole(ep.Role) == other.Role }
c4145
common.AuthFuncForTag(m.ModelTag()), ) return NewFirewallerAPI(stateShim{st: st, State: firewall.StateShim(st, m)}, context.Resources(), context.Auth(), cloudSpecAPI) }
c4146
ControllerConfigAPI: common.NewStateControllerConfig(context.State()), FirewallerAPIV3: facadev3, }, nil }
c4147
return nil, err } return &FirewallerAPIV5{ FirewallerAPIV4: facadev4, }, nil }
c4148
) // WatchModelMachines() is allowed with unrestricted access. machinesWatcher := common.NewModelMachinesWatcher( st, resources, authorizer, ) // InstanceId() is supported for machines. instanceIdGetter := common.NewInstanceIdGetter( st, accessMachine, ) return &FirewallerAPIV3{ LifeGetter: lifeGetter, ModelWatcher: modelWatcher, AgentEntityWatcher: entityWatcher, UnitsWatcher: unitsWatcher, ModelMachinesWatcher: machinesWatcher, InstanceIdGetter: instanceIdGetter, CloudSpecAPI: cloudSpecAPI, st: st, resources: resources, authorizer: authorizer, accessUnit: accessUnit, accessApplication: accessApplication, accessMachine: accessMachine, accessModel: accessModel, }, nil }
c4149
if !canWatch(tag) { result.Results[i].Error = common.ServerError(common.ErrPerm) continue } watcherId, initial, err := f.watchOneModelOpenedPorts(tag) if err != nil { result.Results[i].Error = common.ServerError(err) continue } result.Results[i].StringsWatcherId = watcherId result.Results[i].Changes = initial } return result, nil }
c4150
continue } if ports != nil { portRangeMap := ports.AllPortRanges() var portRanges []network.PortRange for portRange := range portRangeMap { portRanges = append(portRanges, portRange) } network.SortPortRanges(portRanges) for _, portRange := range portRanges { unitTag := names.NewUnitTag(portRangeMap[portRange]).String() result.Results[i].Ports = append(result.Results[i].Ports, params.MachinePortRange{ UnitTag: unitTag, PortRange: params.FromNetworkPortRange(portRange), }) } } } return result, nil }
c4151
} application, err := f.getApplication(canAccess, tag) if err == nil { result.Results[i].Result = application.IsExposed() } result.Results[i].Error = common.ServerError(err) } return result, nil }
c4152
!= nil { return "", nil, errors.Trace(err) } rel, err := f.st.KeyRelation(relationTag.Id()) if err != nil { return "", nil, errors.Trace(err) } w := rel.WatchRelationIngressNetworks() changes, ok := <-w.Changes() if !ok { return "", nil, common.ServerError(watcher.EnsureErr(w)) } return f.resources.Register(w), changes, nil } for i, e := range relations.Entities { watcherId, changes, err := one(e.Tag) if err != nil { results.Results[i].Error = common.ServerError(err) continue } results.Results[i].StringsWatcherId = watcherId results.Results[i].Changes = changes } return results, nil }
c4153
relationTag, err := names.ParseRelationTag(entity.Tag) if err != nil { result.Results[i].Error = common.ServerError(err) continue } mac, err := f.st.GetMacaroon(relationTag) if err != nil { result.Results[i].Error = common.ServerError(err) continue } result.Results[i].Result = mac } return result, nil }
c4154
result.Results[i].Error = common.ServerError(err) continue } err = rel.SetStatus(status.StatusInfo{ Status: status.Status(entity.Status), Message: entity.Info, }) result.Results[i].Error = common.ServerError(err) } return result, nil }
c4155
if err != nil { continue } result.Rules = append(result.Rules, params.FirewallRule{ KnownService: knownService, WhitelistCIDRS: rule.WhitelistCIDRs, }) } return result, nil }
c4156
version, } // TODO(dfc) Backup should take a Tag. if mgoInfo.Tag != nil { info.Username = mgoInfo.Tag.String() } return &info, nil }
c4157
return nil, errors.Annotate(err, "mongodump not available") } dumper := mongoDumper{ DBInfo: info, binPath: mongodumpPath, } return &dumper, nil }
c4158
the dump dir. ignored := found.Difference(md.Targets) // Admin must be removed only if the mongo version is 3.x or // above, since 2.x will not restore properly without admin. if md.DBInfo.MongoVersion.NewerThan(mongo.Mongo26) == -1 { ignored.Remove("admin") } err = stripIgnored(ignored, baseDumpDir) return errors.Trace(err) }
c4159
!info.IsDir() { // Notably, oplog.bson is thus excluded here. continue } databases.Add(info.Name()) } return databases, nil }
c4160
} switch args.Version.Major { case 2: restorer = &mongoRestorer24{ mongoRestorer: mgoRestorer, startMongo: args.StartMongo, stopMongo: args.StopMongo, } case 3: restorer = &mongoRestorer32{ mongoRestorer: mgoRestorer, getDB: args.GetDB, newMongoSession: args.NewMongoSession, } default: return nil, errors.Errorf("cannot restore from mongo version %q", args.Version.String()) } return restorer, nil }
c4161
mgoErr != nil { return errors.Errorf("could not grant special role to %q, result was: %#v", md.DialInfo.Username, mgoErr) } grant = bson.D{ {"grantRolesToUser", "admin"}, {"roles", []string{"oploger"}}, } err = s.Run(grant, &mgoErr) if err != nil { return errors.Trace(err) } result, ok = mgoErr["ok"] success, isFloat = result.(float64) if (!ok || !isFloat || success != 1) && mgoErr != nil { return errors.Errorf("could not grant special role to \"admin\", result was: %#v", mgoErr) } if err := admin.UpsertUser(&mgo.User{ Username: md.DialInfo.Username, Password: md.DialInfo.Password, }); err != nil { return errors.Errorf("cannot set new admin credentials: %v", err) } return nil }
c4162
{ startFunc := newUniter(uniterParams) w, err := startFunc() return w.(*Uniter), err }
c4163
uniter for %q", params.UnitTag.Id()) err := runner.StartWorker(params.UnitTag.Id(), startFunc) return errors.Annotate(err, "error starting uniter worker") }
c4164
return ErrCAASUnitDead } return jworker.ErrTerminateAgent }
c4165
Comment: action, } releaser, err := u.hookLock.Acquire(spec) if err != nil { return nil, errors.Trace(err) } return releaser, nil }
c4166
err = errors.NotFoundf("%s", path) } return "", errors.Trace(err) } return string(data), nil } clientCert, err := readFileString(clientCertPath) if err != nil { return cloud.Credential{}, errors.Annotate(err, "reading client certificate") } clientKey, err := readFileString(clientKeyPath) if err != nil { return cloud.Credential{}, errors.Annotate(err, "reading client key") } serverCert, err := readFileString(serverCertPath) if err != nil { return cloud.Credential{}, errors.Annotate(err, "reading server certificate") } return cloud.NewCredential(cloud.CertificateAuthType, map[string]string{ credAttrServerCert: serverCert, credAttrClientCert: clientCert, credAttrClientKey: clientKey, }), nil }
c4167
} storedCredential, err := backend.CloudCredential(credentialTag) if err != nil { return params.ErrorResults{}, errors.Trace(err) } if !storedCredential.IsValid() { return params.ErrorResults{}, errors.NotValidf("credential %q", storedCredential.Name) } credential := cloud.NewCredential(cloud.AuthType(storedCredential.AuthType), storedCredential.Attributes) return ValidateNewModelCredential(backend, callCtx, credentialTag, &credential) }
c4168
} model, err := backend.Model() if err != nil { return params.ErrorResults{}, errors.Trace(err) } switch model.Type() { case state.ModelTypeCAAS: return checkCAASModelCredential(openParams) case state.ModelTypeIAAS: return checkIAASModelCredential(openParams, backend, callCtx) default: return params.ErrorResults{}, errors.NotSupportedf("model type %q", model.Type()) } }
c4169
append(results, serverError(errors.Annotatef(err, "getting instance id for machine %s", machine.Id()))) continue } machinesByInstance[string(instanceId)] = machine.Id() } // Check can see all machines' instances instances, err := provider.AllInstances(callCtx) if err != nil { return fail(errors.Trace(err)) } instanceIds := set.NewStrings() for _, instance := range instances { id := string(instance.Id()) instanceIds.Add(id) if _, found := machinesByInstance[id]; !found { results = append(results, serverError(errors.Errorf("no machine with instance %q", id))) } } for instanceId, name := range machinesByInstance { if !instanceIds.Contains(instanceId) { results = append(results, serverError(errors.Errorf("couldn't find instance %q for machine %s", instanceId, name))) } } return params.ErrorResults{Results: results}, nil }
c4170
(*environs.BootstrapResult, error) { result, err := Bootstrap(ctx, dp.Env, callCtx, args) if err != nil { return nil, errors.Trace(err) } return result, nil }
c4171
!= nil { return errors.Trace(err) } return nil }
c4172
the environ // setting, otherwise bootstrap or provisioning will fail. if config.SeriesRequiresCloudArchiveTools(series) && !addUpdateScripts { addUpdateScripts = true } // Bring packages up-to-date. cfg.SetSystemUpdate(addUpdateScripts) cfg.SetSystemUpgrade(addUpgradeScripts) // Always run this step - this is where we install packages that juju // requires. cfg.addRequiredPackages() // TODO(bogdanteleaga): Deal with proxy settings on CentOS cfg.updateProxySettings(packageProxySettings) }
c4173
// the subshell and redirecting stderr. script = append(script, InitProgressCmd()) stdout, stderr := cfg.Output(OutAll) script = append(script, "(") if stderr != "" { script = append(script, "(") } script = append(script, bootcmds...) script = append(script, pkgcmds...) script = append(script, runcmds...) if stderr != "" { script = append(script, ") "+stdout) script = append(script, ") "+stderr) } else { script = append(script, ") "+stdout+" 2>&1") } return strings.Join(script, "\n"), nil }
c4174
return &restrictedRoot{ Root: root, check: check, } }
c4175
!= nil { return nil, err } return r.Root.FindMethod(facadeName, version, methodName) }
c4176
func(string, string) error { return err }) }
c4177
case jujuos.Windows: return winVals[valname], nil default: return nixVals[valname], nil } }
c4178
return caller.APICall(facadeName, bestVersion, watcherId, request, nil, &result) } }
c4179
} if w.call == nil { panic("call must be set") } }
c4180
result := w.newResult() err := w.call("Next", &result) if err != nil { if params.IsCodeStopped(err) || params.IsCodeNotFound(err) { if w.tomb.Err() != tomb.ErrStillAlive { // The watcher has been stopped at the client end, so we're // expecting one of the above two kinds of error. // We might see the same errors if the server itself // has been shut down, in which case we leave them // untouched. err = tomb.ErrDying } } // Something went wrong, just report the error and bail out. w.tomb.Kill(err) return } select { case <-w.tomb.Dying(): return case w.in <- result: // Report back the result we just got. } } }() wg.Wait() }
c4181
caller: caller, notifyWatcherId: result.NotifyWatcherId, out: make(chan struct{}), } w.tomb.Go(w.loop) return w }
c4182
make(chan []watcher.RelationStatusChange), } w.tomb.Go(func() error { return w.loop(result.Changes) }) return w }
c4183
make(chan []watcher.OfferStatusChange), } w.tomb.Go(func() error { return w.loop(result.Changes) }) return w }
c4184
newMachineStorageIdsWatcher("VolumeAttachmentsWatcher", caller, result) }
c4185
out: make(chan watcher.MigrationStatus), } w.tomb.Go(w.loop) return w }
c4186
{ netplan.Rollback() return nil, err } environ := os.Environ() // TODO(wpk) 2017-06-21 Is there a way to verify that apply is finished? // https://bugs.launchpad.net/netplan/+bug/1701436 command := fmt.Sprintf("%snetplan generate && netplan apply && sleep 10", params.RunPrefix) result, err := scriptrunner.RunCommand(command, environ, params.Clock, params.Timeout) activationResult := ActivationResult{ Stderr: string(result.Stderr), Stdout: string(result.Stdout), Code: result.Code, } logger.Debugf("Netplan activation result %q %q %d", result.Stderr, result.Stdout, result.Code) if err != nil { netplan.Rollback() return &activationResult, errors.Errorf("bridge activation error: %s", err) } if result.Code != 0 { netplan.Rollback() return &activationResult, errors.Errorf("bridge activation error code %d", result.Code) } return nil, nil }
c4187
out: out, errOut: errOut, in: in, } }
c4188
p.SelectVerify(l, VerifyOptions(l.Singular, l.Options, l.Default != "")) }
c4189
QueryVerify(question, p.scanner, p.out, p.errOut, verify) if err != nil { return "", errors.Trace(err) } if val == "" { return l.Default, nil } return val, nil }
c4190
msg string, err error) { return s != "", "", nil }) }
c4191
} value, err := terminal.ReadPassword(int(f.Fd())) if err != nil { return "", errors.Trace(err) } return string(value), nil } return p.Enter(valueName) }
c4192
return p.EnterVerifyDefault(valueName, nil, defVal) }
c4193
"+valueName+" (optional): ", p.scanner, p.out, p.errOut, nil) }
c4194
err := QueryVerify("Enter "+valueName+" ["+defVal+"]: ", p.scanner, p.out, p.errOut, verifyDefault) if err != nil { return "", errors.Trace(err) } if s == "" { return defVal, nil } return s, nil }
c4195
:= range options { if strings.ToLower(opt) == strings.ToLower(s) { return true, "", nil } } return false, fmt.Sprintf("Invalid %s: %q", singular, s), nil } }
c4196
ret = append(ret, n) } sort.Strings(ret) return ret }
c4197
default: return nil, errors.Errorf("unknown value for boolean type: %q", s) } default: return nil, errors.Errorf("don't know how to convert value %q of type %q", s, t) } }
c4198
make(chan struct{}), initialUpgradeCheckComplete: gate.NewLock(), bufferedLogger: bufferedLogger, prometheusRegistry: prometheusRegistry, preUpgradeSteps: upgrades.PreUpgradeSteps, }, nil }
c4199
{ a.errReason = err close(a.dead) }