Skip to content

Add context to long running operations #774

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

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

MartinForReal
Copy link
Contributor

Add context to long running operations
part of #771

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 30, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 30, 2023
@MartinForReal
Copy link
Contributor Author

/assign @mmiranda96

@MartinForReal
Copy link
Contributor Author

/assign @vteratipally

Copy link
Contributor

@mmiranda96 mmiranda96 left a comment

Choose a reason for hiding this comment

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

A couple of comments.


if err := npdMain(npdo, termCh); err != nil {
ctx, cancelFunc := context.WithCancel(context.Background())
cancelFunc()
Copy link
Contributor

Choose a reason for hiding this comment

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

If you call cancelHere, ctx will not be valid when it reaches npdMain(). Maybe you meant to write defer cancelFunc()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed the code. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It turned out that the original code will put error into channel to simulate timeout. And will cal cancel function to do the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vteratipally Could you please take a look?

@@ -25,7 +26,7 @@ import (
"k8s.io/node-problem-detector/pkg/types"
problemutil "k8s.io/node-problem-detector/pkg/util"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the change is reverted. Thanks!

@mmiranda96
Copy link
Contributor

Thanks for the change!
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 5, 2023
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 5, 2023
@MartinForReal
Copy link
Contributor Author

/retest

1 similar comment
@MartinForReal
Copy link
Contributor Author

/retest

@mmiranda96
Copy link
Contributor

Looks like pull-npd-e2e-node fails due to kubernetes/test-infra#29751. As for pull-npd-test, it seems that it's related to the change.

@mmiranda96
Copy link
Contributor

Same as pull-npd-e2e-test, it's also caused by the recent migration to EKS.

@@ -79,13 +79,11 @@ func (ne *nullExporter) ExportProblems(*types.Status) {

func TestNPDMain(t *testing.T) {
npdo, cleanup := setupNPD(t)
defer cleanup()
cleanup()
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing a defer here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.Thanks!

@MartinForReal
Copy link
Contributor Author

/retest

@mmiranda96
Copy link
Contributor

e2e-node and e2e-test jobs should pass now.

/retest

@MartinForReal
Copy link
Contributor Author

/retest

@MartinForReal
Copy link
Contributor Author

/retest

2 similar comments
@MartinForReal
Copy link
Contributor Author

/retest

@MartinForReal
Copy link
Contributor Author

/retest

@MartinForReal
Copy link
Contributor Author

/test pull-npd-e2e-node


@mmiranda96
Copy link
Contributor

Issue has been fixed, this should pass now.

/retest-required

@mmiranda96
Copy link
Contributor

@vteratipally could you help me approve this PR? Thanks!

@MartinForReal
Copy link
Contributor Author

@vteratipally Could you please take a look? Thanks!

@MartinForReal
Copy link
Contributor Author

@mmiranda96 @vteratipally Could you please take a look? Thanks!

@mmiranda96
Copy link
Contributor

Apologies for the delay.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 15, 2023
@MartinForReal
Copy link
Contributor Author

/assign @vteratipally

@vteratipally
Copy link
Collaborator

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MartinForReal, mmiranda96, vteratipally

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 16, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MartinForReal, mmiranda96, vteratipally

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vteratipally
Copy link
Collaborator

/test pull-npd-e2e-node

@k8s-ci-robot k8s-ci-robot merged commit c9da164 into kubernetes:master Aug 16, 2023
@MartinForReal MartinForReal deleted the shafan/context branch August 17, 2023 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants