id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c177700
return nil, err } return tree, nil } parentTree, err := d.getTreeForCommit(pachClient, commitInfo.ParentCommit) if err != nil { return nil, err } return d.getTreeForOpenCommit(pachClient, file, parentTree) }
c177701
if p.Commit.Repo.Name == ppsconsts.SpecRepo { provenanceCount-- break } } return provenanceCount > 0 }
c177702
Committed: ci.Finished, } if node.FileNode != nil { fileInfo.FileType = pfs.FileType_FILE if full { fileInfo.Objects = node.FileNode.Objects fileInfo.BlockRefs = node.FileNode.BlockRefs } } else if node.DirNode != nil { fileInfo.FileType = pfs.FileType_DIR if full { fileInfo.Children = node.DirNode.Children } } return fileInfo }
c177703
nil } } } fi = _fi ci, err := d.inspectCommit(pachClient, file.Commit, pfs.CommitState_STARTED) if err != nil { return err } if ci.ParentCommit == nil { return f(fi) } file.Commit = ci.ParentCommit } }
c177704
} recordsCol := d.putFileRecords.ReadWrite(stm) var existingRecords pfs.PutFileRecords return recordsCol.Upsert(prefix, &existingRecords, func() error { if newRecords.Tombstone { existingRecords.Tombstone = true existingRecords.Records = nil } existingRecords.Split = newRecords.Split existingRecords.Records = append(existingRecords.Records, newRecords.Records...) existingRecords.Header = newRecords.Header existingRecords.Footer = newRecords.Footer return nil }) }) if err != nil { return err } return err }
c177705
row[len(row)-2] == '\r' { row[len(row)-2] = '\n' row = row[:len(row)-1] } if string(row) == endLine { r.Footer = append(r.Footer, row...) err = r.readFooter() row = nil // The endline is part of the footer } if err == io.EOF && len(r.Footer) == 0 { return nil, fmt.Errorf("invalid pgdump - missing footer") } return row, err }
c177706
kubeClient: kubeClient, } go reporter.reportClusterMetrics() return reporter }
c177707
return func(start time.Time, err error) { if err == nil { r.reportUserAction(ctx, fmt.Sprintf("%vFinished", action), time.Since(start).Seconds()) } else { r.reportUserAction(ctx, fmt.Sprintf("%vErrored", action), err.Error()) } } }
c177708
wait = reportAndFlushUserAction(fmt.Sprintf("%vFinished", action), time.Since(start).Seconds()) } return wait }
c177709
nil { return totalRead, err } } r.curr = r.dataRefs[0] r.dataRefs = r.dataRefs[1:] r.r = bytes.NewReader(r.buf.Bytes()[r.curr.OffsetBytes : r.curr.OffsetBytes+r.curr.SizeBytes]) } } return totalRead, nil }
c177710
return err } ts, err := types.TimestampFromProto(resp.Info.Expires) if err != nil { return fmt.Errorf("Activation request succeeded, but could not "+ "convert token expiration time to a timestamp: %s", err.Error()) } fmt.Printf("Activation succeeded. Your Pachyderm Enterprise token "+ "expires %s\n", ts.String()) return nil }), } activate.PersistentFlags().StringVar(&expires, "expires", "", "A timestamp "+ "indicating when the token provided above should expire (formatted as an "+ "RFC 3339/ISO 8601 datetime). This is only applied if it's earlier than "+ "the signed expiration time encoded in 'activation-code', and therefore "+ "is only useful for testing.") return cmdutil.CreateAlias(activate, "enterprise activate") }
c177711
if err != nil { return fmt.Errorf("Activation request succeeded, but could not "+ "convert token expiration time to a timestamp: %s", err.Error()) } fmt.Printf("Pachyderm Enterprise token state: %s\nExpiration: %s\n", resp.State.String(), ts.String()) return nil }), } return cmdutil.CreateAlias(getState, "enterprise get-state") }
c177712
= append(commands, ActivateCmd(noMetrics, noPortForwarding)) commands = append(commands, GetStateCmd(noMetrics, noPortForwarding)) return commands }
c177713
case *WorkerFullConfiguration: configuration.GlobalConfiguration = &config.(*WorkerFullConfiguration).GlobalConfiguration configuration.WorkerSpecificConfiguration = &config.(*WorkerFullConfiguration).WorkerSpecificConfiguration return configuration default: return nil } }
c177714
col.NewCollection( etcdClient, path.Join(etcdPrefix, reposPrefix), nil, &pfs.RepoInfo{}, nil, nil, ) }
c177715
col.NewCollection( etcdClient, path.Join(etcdPrefix, putFileRecordsPrefix), nil, &pfs.PutFileRecords{}, nil, nil, ) }
c177716
etcdClient, path.Join(etcdPrefix, commitsPrefix, repo), []*col.Index{ProvenanceIndex}, &pfs.CommitInfo{}, nil, nil, ) }
c177717
uuid.IsUUIDWithoutDashes(key) { return fmt.Errorf("branch name cannot be a UUID V4") } return nil }, nil, ) }
c177718
col.NewCollection( etcdClient, path.Join(etcdPrefix, openCommitsPrefix), nil, &pfs.Commit{}, nil, nil, ) }
c177719
for id, parents := range nodes { result.NewNode(id, parents) } return result }
c177720
d.leaves[parentID] = false } if _, ok := d.leaves[id]; !ok { d.leaves[id] = true } }
c177721
result = append(result, dfs(id, d.parents, seen)...) } return result }
c177722
// isLeaf might be false, explicit mark nodes as non leaves if isLeaf { result = append(result, id) } } return result }
c177723
seen[fromID] = true } return dfs(id, d.parents, seen) }
c177724
seen[toID] = true } return bfs(id, d.children, seen) }
c177725
!ok { result = append(result, id) } } return result }
c177726
core := client.CoreV1() return &PortForwarder{ core: core, client: core.RESTClient(), config: config, namespace: namespace, logger: log.StandardLogger().Writer(), stopChansLock: &sync.Mutex{}, stopChans: []chan struct{}{}, shutdown: false, }, nil }
c177727
so this forwarder can be closed f.stopChansLock.Lock() if f.shutdown { f.stopChansLock.Unlock() return fmt.Errorf("port forwarder is shutdown") } f.stopChans = append(f.stopChans, stopChan) f.stopChansLock.Unlock() fw, err := portforward.New(dialer, ports, stopChan, readyChan, ioutil.Discard, f.logger) if err != nil { return err } errChan := make(chan error, 1) go func() { errChan <- fw.ForwardPorts() }() select { case err = <-errChan: return fmt.Errorf("port forwarding failed: %v", err) case <-fw.Ready: return nil } }
c177728
localPort = pachdLocalPort } if remotePort == 0 { remotePort = pachdRemotePort } return f.Run("pachd", localPort, remotePort) }
c177729
= samlAcsLocalPort } return f.Run("pachd", localPort, 654) }
c177730
= dashUILocalPort } return f.Run("dash", localPort, 8080) }
c177731
= dashWebSocketLocalPort } return f.Run("dash", localPort, 8081) }
c177732
} return f.Run("pachd", localPort, 30652) }
c177733
= s3gatewayLocalPort } return f.Run("pachd", localPort, 600) }
c177734
".pachyderm/port-forward.pid")) return pidfile.Write() }
c177735
if f.shutdown { panic("port forwarder already shutdown") } f.shutdown = true for _, stopChan := range f.stopChans { close(stopChan) } }
c177736
} *key = string(e.Key) return proto.Unmarshal(e.Value, val) }
c177737
} *key = string(e.PrevKey) return proto.Unmarshal(e.PrevValue, val) }
c177738
Watcher { return &watcher{ eventCh: eventCh, done: done, } }
c177739
return fmt.Errorf("invalid type, got: %s, expected: %s", valType, templateType) } } return nil }
c177740
port, endpointsWatch: watch, opts: opts, done: make(chan struct{}), queueSize: queueSize, } pool.connsCond = sync.NewCond(&pool.connsLock) go pool.watchEndpoints() return pool, nil }
c177741
p.queueSize && (conn == nil || mapConnCount < atomic.LoadInt64(&conn.count)) { conn = mapConn } } } if conn == nil { p.connsCond.Wait() } else { atomic.AddInt64(&conn.count, 1) break } } return nil }(); err != nil { return err } defer p.connsCond.Broadcast() defer atomic.AddInt64(&conn.count, -1) return f(conn.cc) }
c177742
{ if conn.cc != nil { if err := conn.cc.Close(); err != nil { retErr = err } } } return retErr }
c177743
destImage, ContextDir: contextDir, Dockerfile: dockerfile, OutputStream: os.Stdout, }) if err != nil { return fmt.Errorf("could not build docker image: %s", err) } return nil }
c177744
fmt.Errorf("could not tag docker image: %s", err) return "", err } if err := client.PushImage( docker.PushImageOptions{ Name: repo, Tag: destTag, }, authConfig, ); err != nil { err = fmt.Errorf("could not push docker image: %s", err) return "", err } return destImage, nil }
c177745
:= minio.New(endpoint, id, secret, secure) if err != nil { return nil, err } return &minioClient{ bucket: bucket, Client: mclient, }, nil }
c177746
:= minio.NewV2(endpoint, id, secret, secure) if err != nil { return nil, err } return &minioClient{ bucket: bucket, Client: mclient, }, nil }
c177747
_, err := client.PutObject(client.bucket, name, reader, "application/octet-stream") if err != nil { reader.CloseWithError(err) } w.errChan <- err }() return w }
c177748
defer tracing.FinishAnySpan(span) if err := w.pipe.Close(); err != nil { return err } return <-w.errChan }
c177749
&pfs.Repo{Name: pipeline.Name} }
c177750
// or underscores // TODO: deal with name collision name = strings.Replace(name, "_", "-", -1) return fmt.Sprintf("pipeline-%s-v%d", strings.ToLower(name), version) }
c177751
getResourceListFromSpec(pipelineInfo.ResourceRequests, pipelineInfo.CacheSize) }
c177752
getResourceListFromSpec(pipelineInfo.ResourceLimits, pipelineInfo.CacheSize) }
c177753
fmt.Errorf("unable to retrieve node list from k8s to determine parallelism: %v", err) } if len(nodeList.Items) == 0 { return 0, fmt.Errorf("pachyderm.pps.jobserver: no k8s nodes found") } return len(nodeList.Items), nil }
c177754
nil { return 0, err } result := math.Floor(spec.Coefficient * float64(numNodes)) return int(math.Max(result, 1)), nil } return 0, fmt.Errorf("Unable to interpret ParallelismSpec %+v", spec) }
c177755
return int64(spec.Constant), nil } return 0, fmt.Errorf("unable to interpret HashtreeSpec %+v", spec) }
c177756
return err } pipelinePtr.State = pps.PipelineState_PIPELINE_FAILURE pipelinePtr.Reason = reason pipelines.Put(pipelineName, pipelinePtr) return nil }) return err }
c177757
} if input.Cron != nil { if commit, ok := branchToCommit[key(input.Cron.Repo, "master")]; ok { input.Cron.Commit = commit.ID } } if input.Git != nil { if commit, ok := branchToCommit[key(input.Git.Name, input.Git.Branch)]; ok { input.Git.Commit = commit.ID } } }) return jobInput }
c177758
pipelineInfo.ResourceRequests, ResourceLimits: pipelineInfo.ResourceLimits, Input: pipelineInfo.Input, Description: pipelineInfo.Description, CacheSize: pipelineInfo.CacheSize, EnableStats: pipelineInfo.EnableStats, Batch: pipelineInfo.Batch, MaxQueueSize: pipelineInfo.MaxQueueSize, Service: pipelineInfo.Service, ChunkSpec: pipelineInfo.ChunkSpec, DatumTimeout: pipelineInfo.DatumTimeout, JobTimeout: pipelineInfo.JobTimeout, Salt: pipelineInfo.Salt, } }
c177759
pipelineReader = io.TeeReader(strings.NewReader(string(rawBytes)), &result.buf) } else { rawBytes, err := ioutil.ReadFile(path) if err != nil { return nil, err } pipelineReader = io.TeeReader(strings.NewReader(string(rawBytes)), &result.buf) } result.decoder = json.NewDecoder(pipelineReader) return result, nil }
c177760
return nil, err } return nil, fmt.Errorf("malformed pipeline spec: %s", err) } return &result, nil }
c177761
strings.Split(string(buffer[:len(buffer)-1]), "\n") lineNumber := len(lines) descriptiveErrorString := fmt.Sprintf("Syntax Error on line %v:\n%v\n%v^\n%v\n", lineNumber, string(buffer[lineOffset:]), strings.Repeat(" ", int(sErr.Offset)-2-lineOffset), originalErr, ) return errors.New(descriptiveErrorString) }
c177762
var err error if state == pps.JobState_JOB_STARTING { jobPtr.Started, err = types.TimestampProto(time.Now()) } else if IsTerminal(state) { jobPtr.Finished, err = types.TimestampProto(time.Now()) } if err != nil { return err } jobPtr.State = state jobPtr.Reason = reason return jobs.Put(jobPtr.Job.ID, jobPtr) }
c177763
time.Duration) error { fmt.Printf("error from uuid.NewV4: %v", err) return nil }) return result }
c177764
h == nil { return http.StatusOK } return h.code }
c177765
*HTTPError { return &HTTPError{ code: code, err: fmt.Sprintf(formatStr, args...), } }
c177766
*Storage { return &Storage{ objC: objC, prefix: prefix, } }
c177767
error { return s.objC.Delete(ctx, hash) }) }
c177768
end = len(data) } result = append(result, data[i:end]) } return result }
c177769
return total, err } if err := f(buf[:n]); err != nil { return total, err } total += n } }
c177770
&streamingBytesReader{streamingBytesClient: streamingBytesClient, cancel: cancel} }
c177771
:= io.CopyBuffer(NewStreamingBytesWriter(streamingBytesServer), ReaderWrapper{reader}, buf) return err }
c177772
return err } if _, err = writer.Write(bytesValue.Value); err != nil { return err } } return nil }
c177773
reporter: reporter, workerUsesRoot: true, pipelines: ppsdb.Pipelines(env.GetEtcdClient(), etcdPrefix), jobs: ppsdb.Jobs(env.GetEtcdClient(), etcdPrefix), workerGrpcPort: workerGrpcPort, pprofPort: pprofPort, httpPort: httpPort, peerPort: peerPort, } return apiServer, nil }
c177774
nil, &ec.EnterpriseRecord{}, nil, nil, ), } s.enterpriseExpiration.Store(time.Time{}) go s.watchEnterpriseToken(etcdPrefix) return s, nil }
c177775
hashedToken[:], decodedSignature); err != nil { return time.Time{}, fmt.Errorf("invalid signature in activation code") } // Unmarshal the token token := token{} if err := json.Unmarshal([]byte(activationCode.Token), &token); err != nil { return time.Time{}, fmt.Errorf("token is not valid JSON") } // Parse the expiration. Note that this string is generated by Date.toJSON() // running in node, so Go's definition of RFC 3339 timestamps (which is // incomplete) must be compatible with the strings that node generates. So far // it seems to work. expiration, err = time.Parse(time.RFC3339, token.Expiry) if err != nil { return time.Time{}, fmt.Errorf("expiration is not valid ISO 8601 string") } // Check that the activation code has not expired if time.Now().After(expiration) { return time.Time{}, fmt.Errorf("the activation code has expired") } return expiration, nil }
c177776
expirationProto, }) }); err != nil { return nil, err } // Wait until watcher observes the write if err := backoff.Retry(func() error { if t := a.enterpriseExpiration.Load().(time.Time); t.IsZero() { return fmt.Errorf("enterprise not activated") } return nil }, backoff.RetryEvery(time.Second)); err != nil { return nil, err } time.Sleep(time.Second) // give other pachd nodes time to observe the write return &ec.ActivateResponse{ Info: &ec.TokenInfo{ Expires: expirationProto, }, }, nil }
c177777
watcher observes the write if err := backoff.Retry(func() error { if t := a.enterpriseExpiration.Load().(time.Time); !t.IsZero() { return fmt.Errorf("enterprise still activated") } return nil }, backoff.RetryEvery(time.Second)); err != nil { return nil, err } time.Sleep(time.Second) // give other pachd nodes time to observe the write return &ec.DeactivateResponse{}, nil }
c177778
:= filepath.Join(dir, path) // We assume that LookPath will only add file extension. lp, err := exec.LookPath(dirandpath) if err != nil { return "", err } ext := strings.TrimPrefix(lp, dirandpath) return path + ext, nil }
c177779
Files: c.childFiles, Env: dedupEnv(c.envv()), Sys: c.SysProcAttr, }) if err != nil { c.closeDescriptors(c.closeAfterStart) c.closeDescriptors(c.closeAfterWait) return err } c.closeDescriptors(c.closeAfterStart) c.errch = make(chan error, len(c.goroutine)) for _, fn := range c.goroutine { go func(fn func() error) { c.errch <- fn() }(fn) } if c.ctx != nil { c.waitDone = make(chan struct{}) go func() { select { case <-c.ctx.Done(): c.Process.Kill() case <-c.waitDone: } }() } return nil }
c177780
var b bytes.Buffer c.Stdout = &b c.Stderr = &b err := c.Run() return b.Bytes(), err }
c177781
started") } pr, pw, err := os.Pipe() if err != nil { return nil, err } c.Stdin = pr c.closeAfterStart = append(c.closeAfterStart, pr) wc := &closeOnce{File: pw} c.closeAfterWait = append(c.closeAfterWait, closerFunc(wc.safeClose)) return wc, nil }
c177782
return nil, err } c.Stdout = pw c.closeAfterStart = append(c.closeAfterStart, pw) c.closeAfterWait = append(c.closeAfterWait, pr) return pr, nil }
c177783
= strings.ToLower(k) } if dupIdx, isDup := saw[k]; isDup { out[dupIdx] = kv continue } saw[k] = len(out) out = append(out, kv) } return out }
c177784
case input.Union != nil: if len(input.Union) > 0 { return InputName(input.Union[0]) } } return "" }
c177785
case input.Cross != nil: SortInputs(input.Cross) case input.Union != nil: SortInputs(input.Union) } }) }
c177786
}) } if input.Git != nil { result = append(result, &pfs.Branch{ Repo: &pfs.Repo{Name: input.Git.Name}, Name: input.Git.Branch, }) } }) return result }
c177787
// svn_url: "https://github.com/sjezewski/testgithook", invalidErr := fmt.Errorf("clone URL is missing .git suffix (example clone URL %v)", exampleURL) if !strings.HasSuffix(url, ".git") { // svn_url case return invalidErr } if !strings.HasPrefix(url, "https://") { // git_url or ssh_url cases return invalidErr } return nil }
c177788
"" { return true } } return false }
c177789
log.NewLogger("admin.API"), address: address, storageRoot: storageRoot, clusterInfo: clusterInfo, } }
c177790
} return fmt.Sprintf("%s ago", units.HumanDuration(time.Since(t))) }
c177791
_ := types.TimestampFromProto(from) tTo, _ := types.TimestampFromProto(to) return units.HumanDuration(tTo.Sub(tFrom)) }
c177792
return units.HumanDuration(duration) }
c177793
!= nil { return nil, grpcutil.ScrubGRPC(err) } return clusterInfo, nil }
c177794
err != nil { return grpcutil.ScrubGRPC(err) } for { op, err := extractClient.Recv() if err == io.EOF { break } if err != nil { return grpcutil.ScrubGRPC(err) } if err := f(op); err != nil { return err } } return nil }
c177795
append(result, op) return nil }); err != nil { return nil, err } return result, nil }
c177796
*admin.Op) error { _, err := writer.Write(op) return err }) }
c177797
nil { return fmt.Errorf("unexpected response from extract: %v", resp) } if err != io.EOF { return err } return nil }
c177798
nil || op.Op1_9.Pipeline == nil { return nil, fmt.Errorf("malformed response is missing pipeline") } return op.Op1_9.Pipeline, nil }
c177799
if _, err := restoreClient.CloseAndRecv(); err != nil && retErr == nil { retErr = grpcutil.ScrubGRPC(err) } }() for _, op := range ops { if err := restoreClient.Send(&admin.RestoreRequest{Op: op}); err != nil { return grpcutil.ScrubGRPC(err) } } return nil }