-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sdk): add ctx on WorkerList() #3405
Conversation
Signed-off-by: Yvonnick Esnault <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Yvonnick Esnault <[email protected]>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Yvonnick Esnault <[email protected]>
Signed-off-by: Yvonnick Esnault <[email protected]>
@@ -19,7 +19,9 @@ import ( | |||
// If Take is not possible (as Job already booked for example) | |||
// it will return true (-> can work on another job), false, otherwise | |||
func (w *currentWorker) takeWorkflowJob(ctx context.Context, job sdk.WorkflowNodeJobRun) (bool, error) { | |||
info, err := w.client.QueueTakeJob(job, w.bookedWJobID == job.ID) | |||
ctxt, cancel := context.WithTimeout(ctx, 5*time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctx
sdk/hatchery/starter.go
Outdated
@@ -189,11 +194,13 @@ func spawnWorkerForJob(h Interface, j workerStarterRequest) (bool, error) { | |||
}, | |||
}) | |||
|
|||
ctxt2, cancel2 := context.WithTimeout(ctx, 10*time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would prefer to name the ctx and the cancel with a real name
//This goroutine try to get the pipeline build job every 5 seconds, if it fails, it cancel the build. | ||
ctx, cancel := context.WithCancel(ctx) | ||
//This goroutine try to get the job every 5 seconds, if it fails, it cancel the build. | ||
ctx, cancel2 := context.WithCancel(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would prefer to name the cancel with a real name
@@ -57,11 +59,13 @@ func (w *currentWorker) takeWorkflowJob(ctx context.Context, job sdk.WorkflowNod | |||
return | |||
} | |||
j := &sdk.WorkflowNodeJobRun{} | |||
code, err := w.client.(cdsclient.Raw).GetJSON(fmt.Sprintf("/queue/workflows/%d/infos", jobID), j) | |||
ctxT, cancel3 := context.WithTimeout(ctx, 5*time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would prefer to name the ctx and the cancel with a real name
sdk/hatchery/hatchery.go
Outdated
if int64(len(startWorkerRes.request.spawnAttempts)) < hCount { | ||
if _, errQ := h.CDSClient().QueueJobIncAttempts(startWorkerRes.request.id); errQ != nil { | ||
ctxt2, cancel2 := context.WithTimeout(ctx, 10*time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would prefer to name the ctx and the cancel with a real name
Signed-off-by: Yvonnick Esnault <[email protected]>
sdk/cdsclient/http.go
Outdated
req = req.WithContext(ctx) | ||
|
||
if c.config.Verbose { | ||
log.Println("Stream > context> %s", tracingutils.DumpContext(ctx)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Println call has possible formatting directive %s
sdk/cdsclient/http.go
Outdated
} | ||
spanCtx, ok := tracingutils.ContextToSpanContext(ctx) | ||
if c.config.Verbose { | ||
log.Println("setup tracing = %v (%v) on request to %s", ok, spanCtx, req.URL.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Println call has possible formatting directive %v
CDS Report ut-engine#6379.0 ✘
|
Signed-off-by: Yvonnick Esnault <[email protected]>
Signed-off-by: Yvonnick Esnault [email protected]