Beispiel #1
0
// MarkStart updates the task, build, version and if necessary, patch documents with the task start time
func MarkStart(taskId string) error {
	t, err := task.FindOne(task.ById(taskId))
	if err != nil {
		return err
	}
	startTime := time.Now()
	if err = t.MarkStart(startTime); err != nil {
		return err
	}
	event.LogTaskStarted(t.Id)

	// ensure the appropriate build is marked as started if necessary
	if err = build.TryMarkStarted(t.BuildId, startTime); err != nil {
		return err
	}

	// ensure the appropriate version is marked as started if necessary
	if err = MarkVersionStarted(t.Version, startTime); err != nil {
		return err
	}

	// if it's a patch, mark the patch as started if necessary
	if t.Requester == evergreen.PatchVersionRequester {
		if err = patch.TryMarkStarted(t.Version, startTime); err != nil {
			return err
		}
	}

	// update the cached version of the task, in its build document
	return build.SetCachedTaskStarted(t.BuildId, t.Id, startTime)
}
Beispiel #2
0
func (t *Task) MarkStart() error {
	// record the start time in the in-memory task
	startTime := time.Now()
	t.StartTime = startTime
	t.Status = evergreen.TaskStarted
	err := UpdateOneTask(
		bson.M{
			TaskIdKey: t.Id,
		},
		bson.M{
			"$set": bson.M{
				TaskStatusKey:    evergreen.TaskStarted,
				TaskStartTimeKey: startTime,
			},
		},
	)
	if err != nil {
		return err
	}

	event.LogTaskStarted(t.Id)

	// ensure the appropriate build is marked as started if necessary
	if err = build.TryMarkStarted(t.BuildId, startTime); err != nil {
		return err
	}

	// ensure the appropriate version is marked as started if necessary
	if err = MarkVersionStarted(t.Version, startTime); err != nil {
		return err
	}

	// if it's a patch, mark the patch as started if necessary
	if t.Requester == evergreen.PatchVersionRequester {
		if err = patch.TryMarkStarted(t.Version, startTime); err != nil {
			return err
		}
	}

	// update the cached version of the task, in its build document
	return build.SetCachedTaskStarted(t.BuildId, t.Id, startTime)
}