Skip to content
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

Merged
merged 6 commits into from
Oct 8, 2018
Merged

feat(sdk): add ctx on WorkerList() #3405

merged 6 commits into from
Oct 8, 2018

Conversation

yesnault
Copy link
Member

@yesnault yesnault commented Oct 5, 2018

Signed-off-by: Yvonnick Esnault yvonnick.esnault@corp.ovh.com

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
@yesnault yesnault changed the title feat(sdk): add ctx on WorkerList() (step 1) feat(sdk): add ctx on WorkerList() Oct 5, 2018
@ovh-cds

This comment has been minimized.

@ovh-cds

This comment has been minimized.

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
@ovh-cds

This comment has been minimized.

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx

engine/worker/take_workflow_node_run_job.go Show resolved Hide resolved
sdk/cdsclient/http.go Show resolved Hide resolved
@@ -189,11 +194,13 @@ func spawnWorkerForJob(h Interface, j workerStarterRequest) (bool, error) {
},
})

ctxt2, cancel2 := context.WithTimeout(ctx, 10*time.Second)
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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

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)
Copy link
Member

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 <yvonnick.esnault@corp.ovh.com>
req = req.WithContext(ctx)

if c.config.Verbose {
log.Println("Stream > context> %s", tracingutils.DumpContext(ctx))

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

}
spanCtx, ok := tracingutils.ContextToSpanContext(ctx)
if c.config.Verbose {
log.Println("setup tracing = %v (%v) on request to %s", ok, spanCtx, req.URL.String())

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

@ovh-cds
Copy link
Collaborator

ovh-cds commented Oct 8, 2018

CDS Report ut-engine#6379.0 ✘

  • Stage 1
    • Engine Test with DB ✘

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
@yesnault yesnault merged commit cd8441b into master Oct 8, 2018
@yesnault yesnault deleted the ye-http-withcontext branch October 16, 2018 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants