Skip to content

Commit

Permalink
Adds taskName and taskGroupName to actions at job level
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Oct 10, 2023
1 parent 0bd4d56 commit ae8f15e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion command/agent/job_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (s *HTTPServer) jobActions(resp http.ResponseWriter, req *http.Request, job

var out structs.ActionListResponse
if err := s.agent.RPC("Job.GetActions", &args, &out); err != nil {
return nil, fmt.Errorf("Oh dang: %w", err)
return nil, err
}

setMeta(resp, &structs.QueryMeta{})
Expand Down
15 changes: 11 additions & 4 deletions nomad/job_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -1758,14 +1758,21 @@ func (j *Job) GetActions(args *structs.JobSpecificRequest, reply *structs.Action
}

// Get its task groups' tasks' actions
actions := make([]*structs.Action, 0)
jobActions := make([]*structs.JobAction, 0)
for _, tg := range job.TaskGroups {
for _, task := range tg.Tasks {
actions = append(actions, task.Actions...)
for _, action := range task.Actions {
jobAction := &structs.JobAction{
Action: *action,
TaskName: task.Name,
TaskGroupName: tg.Name,
}
jobActions = append(jobActions, jobAction)
}
}
}
// set it on reply
reply.Actions = actions

reply.Actions = jobActions

// set meta
j.srv.setQueryMeta(&reply.QueryMeta)
Expand Down
5 changes: 2 additions & 3 deletions nomad/structs/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ type Action struct {
}

type JobAction struct {
Action Action
Action
TaskName string
TaskGroupName string
}

// DeploymentListResponse is used for a list request
type ActionListResponse struct {
Actions []*Action
Actions []*JobAction
QueryMeta
}

Expand Down

0 comments on commit ae8f15e

Please sign in to comment.