Skip to content

Commit

Permalink
Adding a task event for setup
Browse files Browse the repository at this point in the history
  • Loading branch information
diptanu committed Feb 10, 2017
1 parent a16709e commit 03dd54b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ type TaskState struct {
}

const (
TaskSetup = "Task Setup"
TaskSetupFailure = "Setup Failure"
TaskDriverFailure = "Driver Failure"
TaskDriverMessage = "Driver"
Expand Down
2 changes: 2 additions & 0 deletions client/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,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(
Expand Down
3 changes: 3 additions & 0 deletions command/alloc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -382,6 +384,7 @@ func (c *AllocStatusCommand) outputTaskStatus(state *api.TaskState) {
}
case api.TaskDriverMessage:
desc = event.DriverMessage

}

// Reverse order so we are sorted by time
Expand Down
13 changes: 13 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2769,6 +2769,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"
Expand Down Expand Up @@ -2848,6 +2855,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
Expand Down

0 comments on commit 03dd54b

Please sign in to comment.