id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c15400 | next(rw, r)
} else {
v2.Write(401, v2.UnauthError{Code: 401, Message: "Not authorized. Please specify the same password that used to start snapteld. E.g: [snaptel -p plugin list] or [curl http://localhost:8181/v2/plugins -u snap]"}, rw)
}
} else {
next(rw, r)
}
} | |
c15401 | rw.Header().Set("Access-Control-Allow-Origin", ro)
rw.Header().Set("Access-Control-Allow-Methods", allowedMethods)
rw.Header().Set("Access-Control-Allow-Headers", allowedHeaders)
rw.Header().Set("Access-Control-Max-Age", strconv.Itoa(maxAge))
}
}
} | |
c15402 | entry,
schedule: schedule,
enabled: false,
}
} | |
c15403 | ErrMissingCronEntry
}
_, err := cron.Parse(c.entry)
if err != nil {
return err
}
return nil
} | |
c15404 | calculate misses
for next := last; next.Before(now); {
next = s.Next(next)
if next.After(now) {
break
}
misses++
}
// wait
waitTime := s.Next(now)
time.Sleep(waitTime.Sub(now))
}
return &CronScheduleResponse{
state: c.GetState(),
err: err,
missed: misses,
lastTime: time.... | |
c15405 | cdn *ConfigDataNode) {
c.cTree.Add(ns, cdn)
} | |
c15406 | nil {
return nil
}
switch t := n.(type) {
case ConfigDataNode:
return &t
default:
return t.(*ConfigDataNode)
}
} | |
c15407 | *PluginMeta) {
m.CacheTTL = t
}
} | |
c15408 | version, s))
}
}
p := &PluginMeta{
Name: name,
Version: version,
Type: pluginType,
AcceptedContentTypes: acceptContentTypes,
ReturnedContentTypes: returnContentTypes,
//set the default for concurrency count to 1
ConcurrencyCount: 1,
}
for _, opt := ra... | |
c15409 |
return ap, nil
}
}
cb.logger.WithFields(log.Fields{
"_block": "findAvailablePlugin",
"strategy": cb.String(),
"error": fmt.Sprintf("%v of %v plugins are available", len(aps)-len(cb.plugins), len(aps)),
}).Error(ErrCouldNotSelect)
return nil, ErrCouldNotSelect
} | |
c15410 | err := encoder.Encode(&c.table); err != nil {
return nil, err
}
return w.Bytes(), nil
} | |
c15411 |
c.mutex = new(sync.Mutex)
decoder := gob.NewDecoder(r)
return decoder.Decode(&c.table)
} | |
c15412 | int(v)}
continue
}
if v, err := t.Float64(); err == nil {
c.table[k] = ctypes.ConfigValueFloat{Value: v}
continue
}
default:
return fmt.Errorf("Error Unmarshalling JSON ConfigDataNode. Key: %v Type: %v is unsupported.", k, t)
}
}
c.mutex = new(sync.Mutex)
return nil
} | |
c15413 |
mutex: new(sync.Mutex),
table: make(map[string]ctypes.ConfigValue),
}
} | |
c15414 | empty is a noop
if k == "" {
return
}
c.mutex.Lock()
defer c.mutex.Unlock()
c.table[k] = v
} | |
c15415 | c.table
for k, v := range t {
new_table[k] = v
}
for k, v := range t2 {
new_table[k] = v
}
c.table = new_table
return c
} | |
c15416 | NewNode()
t2 := c.table
for k, v := range cd.Table() {
copy.table[k] = v
}
for k, v := range t2 {
copy.table[k] = v
}
return copy
} | |
c15417 | name, def := range defaults {
if _, ok := c.table[name]; !ok {
c.table[name] = def
}
}
} | |
c15418 | defer c.mutex.Unlock()
delete(c.table, k)
} | |
c15419 | msg)
if err != nil {
return err
}
t.broadcasts.QueueBroadcast(&broadcast{
msg: raw,
notify: notify,
})
return nil
} | |
c15420 | RestCertificate: defaultRestCertificate,
RestKey: defaultRestKey,
RestAuth: defaultAuth,
RestAuthPassword: defaultAuthPassword,
portSetByConfig: defaultPortSetByConfig,
Pprof: defaultPprof,
Corsd: defaultCorsd,
}
} | |
c15421 | "core",
"_block": "TaskDeadlineDuration",
"task-id": t.ID(),
"task-name": t.GetName(),
"task deadline duration": t.DeadlineDuration(),
}).Debug("Setting deadlineDuration on task")
return TaskDeadlineDuration(previous)
}
} | |
c15422 | "_block": "OptionStopOnFailure",
"task-id": t.ID(),
"task-name": t.GetName(),
"consecutive failure limit": t.GetStopOnFailure(),
}).Debug("Setting stop-on-failure limit for task")
return OptionStopOnFailure(previous)
}
} | |
c15423 | {
return func(c *pluginControl) {
strategy.GlobalCacheExpiration = t
}
} | |
c15424 | c.pluginManager.SetPluginLoadTimeout(c.Config.PluginLoadTimeout)
c.pluginRunner.SetPluginLoadTimeout(c.Config.PluginLoadTimeout)
}
} | |
c15425 | *pluginControl) {
c.pluginManager.SetPluginTags(tags)
}
} | |
c15426 | "_block": "new",
}).Debug("signing manager created")
// Plugin Runner
c.pluginRunner = newRunner(runnerOpts...)
controlLogger.WithFields(log.Fields{
"_block": "new",
}).Debug("runner created")
c.pluginRunner.AddDelegates(c.eventManager)
c.pluginRunner.SetEmitter(c.eventManager)
c.pluginRunner.SetMetricCata... | |
c15427 | If plugin was loaded from a package, remove ExecPath for
// the temporary plugin that was used for load
if pl.Details.IsPackage {
pl.Details.ExecPath = ""
}
// defer sending event
event := &control_event.LoadPluginEvent{
Name: pl.Meta.Name,
Version: pl.Meta.Version,
Type: int(pl.Meta.Type),
Signe... | |
c15428 | configTree *cdata.ConfigDataTree) (serrs []serror.SnapError) {
return p.subscriptionGroups.Add(id, requested, configTree, plugins)
} | |
c15429 | {
// update view and unsubscribe to plugins
return p.subscriptionGroups.Remove(id)
} | |
c15430 | ...monitorOption) {
p.pluginRunner.Monitor().Option(options...)
} | |
c15431 | "ns": ns,
"tag-key": k,
"tag-val": v,
}).Debug("Tags in CollectMetrics")
}
}
cMetrics := make(chan []core.Metric)
cError := make(chan error)
var wg sync.WaitGroup
// For each available plugin call available plugin using RPC client and wait for response (goroutines)
for pluginKey, pmt := range... | |
c15432 | gomit.NewEventController(),
taskWatcherColl: newTaskWatcherCollection(),
}
// we are setting the size of the queue and number of workers for
// collect, process and publish consistently for now
s.workManager = newWorkManager(opts...)
s.workManager.Start()
s.eventManager.RegisterHandler(HandlerRegistrationNa... | |
c15433 | core.TaskErrors) {
return s.createTask(sch, wfMap, startOnCreate, "user", opts...)
} | |
c15434 | := range s.tasks.Table() {
tasks[id] = t
}
return tasks
} | |
c15435 | }).Error("error getting task")
return nil, err // We do this to send back an explicit nil on the interface
}
return t, nil
} | |
c15436 | []serror.SnapError {
return s.startTask(id, "user")
} | |
c15437 | []serror.SnapError {
return s.stopTask(id, "user")
} | |
c15438 | }).Error("error enabling task")
return nil, err
}
schedulerLogger.WithFields(log.Fields{
"_block": "enable-task",
"task-id": t.ID(),
"task-state": t.State(),
}).Info("task enabled")
return t, nil
} | |
c15439 | "_block": "set-metric-manager",
}).Debug("metric manager linked")
} | |
c15440 |
task.UnsubscribePlugins()
s.taskWatcherColl.handleTaskEnded(v.TaskID)
case *scheduler_event.TaskDisabledEvent:
log.WithFields(log.Fields{
"_module": "scheduler-events",
"_block": "handle-events",
"event-namespace": e.Namespace(),
"task-id": v.TaskID,
"disabled-reason": v.... | |
c15441 | rbody.FromError(err), w)
return
}
task := &rbody.ScheduledTaskEnabled{}
task.AddScheduledTask = *rbody.AddSchedulerTaskFromTask(tsk)
rbody.Write(200, task, w)
} | |
c15442 |
m, err := specaci.ManifestFromImage(f)
if err != nil {
return nil, err
}
return m, nil
} | |
c15443 | err = os.Chmod(file, fileMode)
if err != nil {
return "", fmt.Errorf("%v: %v\n%v", ErrChmod, file, err)
}
case tar.TypeDir:
err = os.MkdirAll(file, fileMode)
if err != nil {
return "", fmt.Errorf("%v: %v\n%v", ErrMkdirAll, file, err)
}
case tar.TypeSymlink:
err := os.Symlink(
filepath... | |
c15444 | specaci.ValidateArchive(tr.Reader); err != nil {
return err
}
return nil
} | |
c15445 | defer s.Unlock()
return s.remove(id)
} | |
c15446 |
if err := group.validatePluginUnloading(id, pluginToUnload); err != nil {
errs = append(errs, err)
}
}
return errs
} | |
c15447 | there
for _, sp := range s.plugins {
if sp.TypeName() == plugin.TypeName() && sp.Name() == plugin.Name() && sp.Version() == plugin.Version() {
return true
}
}
return false
} | |
c15448 | those which are not impacted by unloading (version different than plgToUnload.Version())
if requestedMetric.Version() == plgToUnload.Version() {
plgsInVer := []core.CatalogedPlugin{}
for _, plg := range plgs {
if plg.Version() == requestedMetric.Version() {
plgsInVer = append(plgsInVer, plg)
... | |
c15449 | continue
}
adds = append(adds, n)
}
for _, o := range oldPlugins {
if newMap[key(o)] > 0 {
newMap[key(o)]--
continue
}
removes = append(removes, o)
}
return
} | |
c15450 | := make(map[string]interface{})
for k, v := range f {
fields[k] = v
}
r.Err = serror.New(resp.Body.(*rbody.Error), fields)
default:
r.Err = serror.New(ErrAPIResponseMetaType)
}
return r
} | |
c15451 | if err != nil {
r.Err = err
return r
}
switch resp.Meta.Type {
case rbody.PluginUnloadedType:
// Success
up := resp.Body.(*rbody.PluginUnloaded)
r = &UnloadPluginResult{up, nil}
case rbody.ErrorType:
r.Err = resp.Body.(*rbody.Error)
default:
r.Err = ErrAPIResponseMetaType
}
return r
} | |
c15452 | {
// TODO change this to concrete const type when Joel adds it
case rbody.PluginListType:
// Success
b := resp.Body.(*rbody.PluginList)
r.LoadedPlugins = convertLoadedPlugins(b.LoadedPlugins)
r.AvailablePlugins = convertAvailablePlugins(b.AvailablePlugins)
return r
case rbody.ErrorType:
r.Err = resp.Bod... | |
c15453 | := resp.Body.(*rbody.PluginReturned)
r.ReturnedPlugin = ReturnedPlugin{b}
return r
case rbody.ErrorType:
r.Err = resp.Body.(*rbody.Error)
default:
r.Err = ErrAPIResponseMetaType
}
return r
} | |
c15454 | _, x := range t.taskIDs {
t.parent.rm(x, t)
}
return nil
} | |
c15455 | set correctly on an insert.
if len(p.plugins) == 0 {
if err := p.applyPluginMeta(a); err != nil {
return err
}
}
a.SetID(p.generatePID())
p.plugins[a.ID()] = a
return nil
} | |
c15456 | case plugin.DefaultRouting:
p.RoutingAndCaching = NewLRU(cacheTTL)
case plugin.StickyRouting:
p.RoutingAndCaching = NewSticky(cacheTTL)
p.concurrencyCount = 1
case plugin.ConfigRouting:
p.RoutingAndCaching = NewConfigBased(cacheTTL)
default:
return ErrBadStrategy
}
return nil
} | |
c15457 | the subscription.
p.subs[taskID] = &subscription{
TaskID: taskID,
Version: p.version,
}
}
} | |
c15458 | defer p.Unlock()
delete(p.subs, taskID)
} | |
c15459 | if pool is eligible and number of plugins is less than maximum allowed
if len(p.subs) > p.concurrencyCount*len(p.plugins) {
return true
}
return false
} | |
c15460 | ok {
ap.Kill(reason)
delete(p.plugins, id)
}
} | |
c15461 | nil {
log.WithFields(log.Fields{
"_block": "KillAll",
"reason": reason,
}).Error(err)
}
p.Kill(id, reason)
}
} | |
c15462 | err := rp.Kill(reason); err != nil {
log.WithFields(log.Fields{
"_block": "SelectAndKill",
"taskID": id,
"reason": reason,
}).Error(err)
}
p.remove(rp.ID())
} | |
c15463 | p.Unlock()
delete(p.plugins, id)
} | |
c15464 |
defer p.RUnlock()
return len(p.plugins)
} | |
c15465 | defer p.RUnlock()
return len(p.subs)
} | |
c15466 | case "config-based":
id = idFromCfg(config)
default:
return nil, serror.New(ErrBadStrategy)
}
ap, err := p.Select(aps, id)
if err != nil {
return nil, serror.New(err)
}
return ap, nil
} | |
c15467 | atomic.AddUint32(&p.pidCounter, 1)
return p.pidCounter
} | |
c15468 |
}
return p.RoutingAndCaching.CacheTTL(taskID)
} | |
c15469 | armored detached signature
checked, e = openpgp.CheckArmoredDetachedSignature(keyring, signed, bytes.NewReader(signature))
if e == nil {
for k := range checked.Identities {
signedby = signedby + k
}
fmt.Printf("Signature made %v using RSA key ID %v\nGood signature from %v\n", time.Now().Format(time.RF... | |
c15470 | := []string{
// String
ConfigValueStr{}.Type(),
// Integer
ConfigValueInt{}.Type(),
// Float
ConfigValueFloat{}.Type(),
// Bool
ConfigValueBool{}.Type(),
}
return t
} | |
c15471 | return nil, err
}
stderr, err := cmd.StderrPipe()
if err != nil {
return nil, err
}
return &ExecutablePlugin{
cmd: &commandWrapper{cmd},
stdout: stdout,
stderr: stderr,
}, nil
} | |
c15472 | b) The timeout expires
select {
case <-doneChan:
case <-time.After(timeout):
// We timed out waiting for the plugin's response. Set err.
err = fmt.Errorf("timed out waiting for plugin %s", path.Base(e.cmd.Path()))
}
if err != nil {
execLogger.WithFields(log.Fields{
"received_response": string(respBytes)... | |
c15473 | = append(ns, namespaceElement.Value)
}
return ns
} | |
c15474 | separator list
for _, s := range nsPriorityList {
if v, ok := smap[s]; ok && !v {
return s
}
}
return Separator
} | |
c15475 |
for _, s := range nsPriorityList {
m[s] = false
}
return m
} | |
c15476 |
n[i] = NamespaceElement{Value: ns}
}
return n
} | |
c15477 | NamespaceElement{Name: name, Description: description, Value: "*"}
return append(n, nse)
} | |
c15478 | NamespaceElement{Value: value}
return append(n, nse)
} | |
c15479 |
n = append(n, NamespaceElement{Value: value})
}
return n
} | |
c15480 | not run
q.Job().AddErrors(errors.New("Worker refused to run overdue job."))
}
// mark the job complete
q.Promise().Complete(q.Job().Errors())
// the single kill-channel -- used when resizing worker pools
case <-w.kamikaze:
return
//the broadcast that kills all workers
case <-workerKillChan:
... | |
c15481 | = convertCatalog(mc)
case rbody.MetricReturnedType:
mc := resp.Body.(*rbody.MetricReturned)
r.Catalog = []*rbody.Metric{mc.Metric}
case rbody.ErrorType:
r.Err = resp.Body.(*rbody.Error)
default:
r.Err = ErrAPIResponseMetaType
}
return r
} | |
c15482 | := resp.Body.(*rbody.MetricsReturned)
r.Catalog = convertCatalog(mc)
case rbody.ErrorType:
r.Err = resp.Body.(*rbody.Error)
default:
r.Err = ErrAPIResponseMetaType
}
return r
} | |
c15483 | = fmt.Sprintf("%c", r)
break
}
return firstChar
} | |
c15484 |
if err := encoder.Encode(c.root); err != nil {
return nil, err
}
return w.Bytes(), nil
} | |
c15485 |
decoder := gob.NewDecoder(r)
if err := decoder.Decode(&c.root); err != nil {
return err
}
return nil
} | |
c15486 | Root *node `json:"root"`
}{
Root: c.root,
})
} | |
c15487 | at this root level
if len(remain) == 0 {
c.log(fmt.Sprintf("adding node at root level\n"))
c.root.Node = inNode
// And return since we are done
return
}
} else {
if f != c.root.keys[0] {
panic("Can't add a new root namespace")
}
}
c.root.add(remain, inNode)
} | |
c15488 | {
c.log(fmt.Sprintf("adding root node (not nil) to nodes to merge (%v)\n", c.root.Node))
*retNodes = append(*retNodes, c.root.Node)
}
c.log(fmt.Sprintf("children to get from (%d)\n", len(c.root.nodes)))
for _, child := range c.root.nodes {
childNodes := child.get(remain)
*retNodes = append(*retNodes, *chil... | |
c15489 | `json:"node"`
}{
Nodes: n.nodes,
Keys: n.keys,
KeysBytes: n.keysBytes,
Node: n.Node,
})
} | |
c15490 |
if err := encoder.Encode(n.keysBytes); err != nil {
return nil, err
}
if err := encoder.Encode(&n.Node); err != nil {
return nil, err
}
return w.Bytes(), nil
} | |
c15491 | {
return err
}
if err := decoder.Decode(&n.keysBytes); err != nil {
return err
}
return decoder.Decode(&n.Node)
} | |
c15492 | Minimum ctypes.ConfigValue `json:"minimum,omitempty"`
Maximum ctypes.ConfigValue `json:"maximum,omitempty"`
Type string `json:"type"`
}{
Key: f.key,
Required: f.required,
Default: f.Default(),
Minimum: f.Minimum(),
Maximum: f.Maximum(),
Type: FloatType,
})
} | |
c15493 | else {
encoder.Encode(true)
if err := encoder.Encode(f.minimum); err != nil {
return nil, err
}
}
if f.maximum == nil {
encoder.Encode(false)
} else {
encoder.Encode(true)
if err := encoder.Encode(f.maximum); err != nil {
return nil, err
}
}
return w.Bytes(), nil
} | |
c15494 | return ctypes.ConfigValueFloat{Value: *f.default_}
}
return nil
} | |
c15495 | in the format of http(s)://<ip>:<port>", url)
}
return nil
} | |
c15496 | c.Password = strings.TrimSpace(p)
}
} | |
c15497 | *Client) {
c.http.Timeout = t
}
} | |
c15498 | insecure {
t = insecureTransport
} else {
t = secureTransport
}
c := &Client{
URL: url,
Version: ver,
http: &http.Client{
Transport: t,
},
}
for _, opt := range opts {
opt(c)
}
c.prefix = url + "/" + ver
return c, nil
} | |
c15499 | rsp, err := c.http.Do(req)
if err != nil {
return nil, err
}
return rsp, nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.