8000 feat(hatchery): timeout of 10 minutes to start a worker (#3161) · ovh/cds@0a8e85b · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 0a8e85b

Browse files
fsaminyesnault
authored andcommitted
feat(hatchery): timeout of 10 minutes to start a worker (#3161)
1 parent 301a394 commit 0a8e85b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

sdk/hatchery/hatchery.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ func Create(h Interface) error {
214214
continue
215215
}
216216

217-
currentCtx := context.WithValue(ctx, tracing.TagWorkflowNodeJobRun, j.ID)
217+
var traceEnded *struct{}
218+
currentCtx, currentCancel := context.WithTimeout(ctx, 10*time.Minute)
218219
if val, has := j.Header.Get(tracingutils.SampledHeader); has && val == "1" {
219220
currentCtx, _ = tracing.New(currentCtx, h.ServiceName(), "hatchery.JobReceive", trace.AlwaysSample(), trace.SpanKindServer)
220221

@@ -236,8 +237,16 @@ func Create(h Interface) error {
236237
)
237238
}
238239
tracing.End(currentCtx, nil, nil) // nolint
240+
var T struct{}
241+
traceEnded = &T
242+
currentCancel()
239243
}
240-
244+
go func() {
245+
<-currentCtx.Done()
246+
if traceEnded == nil {
247+
endTrace(currentCtx.Err().Error())
248+
}
249+
}()
241250
//Check if the jobs is concerned by a pending worker creation
242251
if _, exist := spawnIDs.Get(strconv.FormatInt(j.ID, 10)); exist {
243252
log.Debug("job %d already spawned in previous routine", j.ID)
@@ -297,7 +306,7 @@ func Create(h Interface) error {
297306
isRun: false,
298307
temptToSpawn: true,
299308
}
300-
endTrace("no model")
309+
endTrace("no model or service ratio reached")
301310

302311
continue
303312
}

0 commit comments

Comments
 (0)
0