Adding a task event for setup

This commit is contained in:
Diptanu Choudhury
2017-02-09 17:40:13 -08:00
committed by Alex Dadgar
parent 5f8e0bca6b
commit c80bdd9f5f
4 changed files with 18 additions and 0 deletions

View File

@@ -409,6 +409,7 @@ type TaskState struct {
}
const (
TaskSetup = "Task Setup"
TaskSetupFailure = "Setup Failure"
TaskDriverFailure = "Driver Failure"
TaskDriverMessage = "Driver"

View File

@@ -422,6 +422,8 @@ func (r *TaskRunner) Run() {
// Build base task directory structure regardless of FS isolation abilities.
// This needs to happen before we start the Vault manager and call prestart
// as both those can write to the task directories
r.setState(structs.TaskStatePending, structs.NewTaskEvent(structs.TaskSetup).
SetMessage(structs.TaskBuildingTaskDir))
if err := r.buildTaskDir(drv.FSIsolation()); err != nil {
e := fmt.Errorf("failed to build task directory for %q: %v", r.task.Name, err)
r.setState(

View File

@@ -280,6 +280,8 @@ func (c *AllocStatusCommand) outputTaskStatus(state *api.TaskState) {
// Build up the description based on the event type.
var desc string
switch event.Type {
case api.TaskSetup:
desc = event.Message
case api.TaskStarted:
desc = "Task started by client"
case api.TaskReceived:

View File

@@ -2853,6 +2853,13 @@ const (
// failed.
TaskArtifactDownloadFailed = "Failed Artifact Download"
// TaskBuildingTaskDir indicates that the task direcotry/chroot is being
// built.
TaskBuildingTaskDir = "Building Task Directory"
// TaskSetup indicates the task runner is setting up the task environment
TaskSetup = "Task Setup"
// TaskDiskExceeded indicates that one of the tasks in a taskgroup has
// exceeded the requested disk resources.
TaskDiskExceeded = "Disk Resources Exceeded"
@@ -2935,6 +2942,12 @@ func (te *TaskEvent) GoString() string {
return fmt.Sprintf("%v at %v", te.Type, te.Time)
}
// SetMessage sets the message of TaskEvent
func (te *TaskEvent) SetMessage(msg string) *TaskEvent {
te.Message = msg
return te
}
func (te *TaskEvent) Copy() *TaskEvent {
if te == nil {
return nil