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

Added debug to apparent stop channel called early. #687

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cheftako
Copy link
Contributor

No description provided.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheftako

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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 10, 2025
@cheftako
Copy link
Contributor Author

/test pull-apiserver-network-proxy-test-master

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 14, 2025
@cheftako
Copy link
Contributor Author

/assign @tallclair

Comment on lines +541 to +547
select {
case <-a.stopCh:
return
default:
}
timeout := time.Now().Add(15 * time.Second)
eConn.conn.SetReadDeadline(timeout)
Copy link
Contributor

@tallclair tallclair Jan 14, 2025

Choose a reason for hiding this comment

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

I think what we want to do here is close the connection if stopch is closed. Something like this?

go func() {
  <-a.stopCh
  eConn.conn.Close()
}

The documentation on Close says it terminates any blocking read or write operations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function has a defer cleanup() call on line 533. When we return it should get called. That cleanup makes a protected call to

eConn.cleanFunc = func() {
. That will then close() the connection.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a problem to call close() multiple times? I wasn't suggesting that we were leaving the connection open, but rather calling close should be a way to quickly react to the stop channel, rather than polling for it every 15 seconds, which is what I understood your change to be doing?

Copy link
Contributor Author

@cheftako cheftako Jan 14, 2025

Choose a reason for hiding this comment

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

I don't believe close in golang is re-entrant. In fact I think the reason we had to protect the clean up with callOnce() in that code path is specifically because close causes a panic if called twice.

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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants