Example #1
0
func (b *brancher) CommitOutstanding() error {
	if err := b.destroyable.Destroy(); err != nil {
		return err
	}
	for repositoryName, commitID := range b.outputRepositoryToBranchID {
		if err := pfsutil.Commit(
			b.pfsAPIClient,
			repositoryName,
			commitID,
		); err != nil {
			return err
		}
		for inputRepositoryCommit := range b.outputRepositoryToInputRepositories[repositoryName] {
			if err := b.storeClient.AddPfsCommitMapping(
				&pps.PfsCommitMapping{
					InputRepository:  inputRepositoryCommit.repositoryName,
					InputCommitId:    inputRepositoryCommit.commitID,
					OutputRepository: repositoryName,
					OutputCommitId:   commitID,
					Timestamp:        protoutil.TimeToTimestamp(b.timer.Now()),
				},
			); err != nil {
				return err
			}
		}
	}
	return nil
}
Example #2
0
func (c *rethinkClient) AddPipelineRunStatus(id string, statusType pps.PipelineRunStatusType) error {
	runStatus := &pps.PipelineRunStatus{
		PipelineRunId:         id,
		PipelineRunStatusType: statusType,
		Timestamp:             protoutil.TimeToTimestamp(c.timer.Now()),
	}
	data, err := marshaller.MarshalToString(runStatus)
	if err != nil {
		return err
	}
	_, err = c.statuses.Insert(gorethink.JSON(data)).RunWrite(c.session)
	return err
}
func (c *inMemoryClient) AddPipelineRunStatus(id string, statusType pps.PipelineRunStatusType) error {
	runStatus := &pps.PipelineRunStatus{
		PipelineRunId:         id,
		PipelineRunStatusType: statusType,
		Timestamp:             protoutil.TimeToTimestamp(c.timer.Now()),
	}
	c.runStatusesLock.Lock()
	defer c.runStatusesLock.Unlock()

	_, ok := c.idToRunStatuses[id]
	if !ok {
		return fmt.Errorf("no run for id %s", runStatus.PipelineRunId)
	}
	c.idToRunStatuses[id] =
		append(c.idToRunStatuses[id], runStatus)
	return nil
}
func (w *pipelineRunLogWriter) Write(p []byte) (int, error) {
	c := make([]byte, len(p))
	if n := copy(c, p); n != len(p) {
		return 0, fmt.Errorf("tried to copy %d bytes, only copied %d bytes", len(p), n)
	}
	if err := w.storeClient.AddPipelineRunLogs(
		&pps.PipelineRunLog{
			PipelineRunId: w.pipelineRunID,
			ContainerId:   w.containerID,
			Node:          w.node,
			OutputStream:  w.outputStream,
			Timestamp:     protoutil.TimeToTimestamp(w.timer.Now()),
			Data:          c,
		},
	); err != nil {
		return 0, err
	}
	return len(p), nil
}
func (c *inMemoryClient) AddPipelineRun(pipelineRun *pps.PipelineRun) error {
	c.runLock.Lock()
	defer c.runLock.Unlock()
	c.runStatusesLock.Lock()
	defer c.runStatusesLock.Unlock()
	c.containersLock.Lock()
	defer c.containersLock.Unlock()
	c.logsLock.Lock()
	defer c.logsLock.Unlock()

	if _, ok := c.idToRun[pipelineRun.Id]; ok {
		return fmt.Errorf("run with id %s already added", pipelineRun.Id)
	}
	c.idToRun[pipelineRun.Id] = pipelineRun
	c.idToRunStatuses[pipelineRun.Id] = make([]*pps.PipelineRunStatus, 1)
	c.idToRunStatuses[pipelineRun.Id][0] = &pps.PipelineRunStatus{
		PipelineRunStatusType: pps.PipelineRunStatusType_PIPELINE_RUN_STATUS_TYPE_ADDED,
		Timestamp:             protoutil.TimeToTimestamp(c.timer.Now()),
	}
	c.idToContainers[pipelineRun.Id] = make([]*pps.PipelineRunContainer, 0)
	c.idToLogs[pipelineRun.Id] = make([]*pps.PipelineRunLog, 0)
	return nil
}