Skip to content

Commit 6dcada4

Browse files
authored
Merge pull request #10784 from hashicorp/b-dlskf
e2e: fix a couple recent e2e bugs
2 parents 2520d83 + 15d39f0 commit 6dcada4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

command/agent/job_endpoint.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ func ApiTgToStructsTG(job *structs.Job, taskGroup *api.TaskGroup, tg *structs.Ta
874874
tg.Constraints = ApiConstraintsToStructs(taskGroup.Constraints)
875875
tg.Affinities = ApiAffinitiesToStructs(taskGroup.Affinities)
876876
tg.Networks = ApiNetworkResourceToStructs(taskGroup.Networks)
877-
tg.Services = ApiServicesToStructs(taskGroup.Services)
877+
tg.Services = ApiServicesToStructs(taskGroup.Services, true)
878878
tg.Consul = apiConsulToStructs(taskGroup.Consul)
879879

880880
tg.RestartPolicy = &structs.RestartPolicy{
@@ -1044,7 +1044,7 @@ func ApiTaskToStructsTask(job *structs.Job, group *structs.TaskGroup,
10441044
}
10451045
}
10461046

1047-
structsTask.Services = ApiServicesToStructs(apiTask.Services)
1047+
structsTask.Services = ApiServicesToStructs(apiTask.Services, false)
10481048

10491049
structsTask.Resources = ApiResourcesToStructs(apiTask.Resources)
10501050

@@ -1212,7 +1212,7 @@ func ApiPortToStructs(in api.Port) structs.Port {
12121212
}
12131213
}
12141214

1215-
func ApiServicesToStructs(in []*api.Service) []*structs.Service {
1215+
func ApiServicesToStructs(in []*api.Service, group bool) []*structs.Service {
12161216
if len(in) == 0 {
12171217
return nil
12181218
}
@@ -1258,11 +1258,16 @@ func ApiServicesToStructs(in []*api.Service) []*structs.Service {
12581258
Body: check.Body,
12591259
GRPCService: check.GRPCService,
12601260
GRPCUseTLS: check.GRPCUseTLS,
1261-
TaskName: check.TaskName,
12621261
SuccessBeforePassing: check.SuccessBeforePassing,
12631262
FailuresBeforeCritical: check.FailuresBeforeCritical,
12641263
OnUpdate: onUpdate,
12651264
}
1265+
1266+
if group {
1267+
// only copy over task name for group level checks
1268+
out[i].Checks[j].TaskName = check.TaskName
1269+
}
1270+
12661271
if check.CheckRestart != nil {
12671272
out[i].Checks[j].CheckRestart = &structs.CheckRestart{
12681273
Limit: check.CheckRestart.Limit,

e2e/e2eutil/job.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// Register registers a jobspec from a file but with a unique ID.
1313
// The caller is responsible for recording that ID for later cleanup.
1414
func Register(jobID, jobFilePath string) error {
15-
cmd := exec.Command("nomad", "job", "run", "-")
15+
cmd := exec.Command("nomad", "job", "run", "-detach", "-")
1616
stdin, err := cmd.StdinPipe()
1717
if err != nil {
1818
return fmt.Errorf("could not open stdin?: %w", err)

0 commit comments

Comments
 (0)