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

[release-0.58]: Bugfix: virt-handler socket leak #9002

Conversation

iholder101
Copy link
Contributor

@iholder101 iholder101 commented Jan 1, 2023

What this PR does / why we need it:
Manual backport for #8948.

Special notes for your reviewer:
The only interesting reason for a backport is the following commit: 49dd3c5. In the original PR I was using a matcher (matcher.HaveConditionTrue()) that doesn't exist in this branch. Therefore, I'm manually checking the condition instead.

Release note:

Bugfix: virt-handler socket leak

@kubevirt-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Jan 1, 2023
@iholder101 iholder101 force-pushed the backport-0.58/virt-handler-socket-leak branch from e9a5b33 to 0bcce59 Compare January 1, 2023 07:35
@iholder101 iholder101 marked this pull request as ready for review January 1, 2023 07:37
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 1, 2023
@iholder101
Copy link
Contributor Author

/cc @enp0s3 @Barakmor1

Would appreciate your review :)

@iholder101
Copy link
Contributor Author

/hold

Blocked by #9004.

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 1, 2023
@iholder101 iholder101 marked this pull request as draft January 1, 2023 08:44
@kubevirt-bot kubevirt-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 1, 2023
In other words: that the number of connections
does not grow when making multiple client calls

Signed-off-by: Itamar Holder <iholder@redhat.com>
matcher.HaveConditionTrue() is not supported in
release-0.53, therefore this commit fallbacks
to the old method of checking the condition.

Signed-off-by: Itamar Holder <iholder@redhat.com>
By default, virt-handler's HTTP server keeps connections
opened in order to reuse them whenever possible. But,
by default, the HTTP server doesn't define any timeout
for the keep-alive mechanism, hence keeping the connection
opened forever.

This commit sets a timeout of 60 seconds to the keep-alive
mechanism.

Signed-off-by: Itamar Holder <iholder@redhat.com>
Signed-off-by: Itamar Holder <iholder@redhat.com>
Now that an HTTP client is added to NewVirtHandlerClient()
as a new parameter, many tests have to use an empty client.
This function fetches the virt-handler pod with an empty
HTTP client.

Signed-off-by: Itamar Holder <iholder@redhat.com>
Signed-off-by: Itamar Holder <iholder@redhat.com>
Signed-off-by: Itamar Holder <iholder@redhat.com>
This is necesarry for connection re-use. As
client.Do()'s documentation says:

"If the returned error is nil, the Response will contain
a non-nil Body which the user is expected to close. If
the Body is not both read to EOF and closed, the
Client's underlying RoundTripper (typically Transport)
may not be able to re-use a persistent TCP connection
to the server for a subsequent "keep-alive" request."

Source: https://pkg.go.dev/net/http#Client.Do

Signed-off-by: Itamar Holder <iholder@redhat.com>
Same logic is used twice, now it's extracted
into a helper function. This is especially
important since this helper function makes
sure that the response is properly close which
can prevent future bugs.

Signed-off-by: Itamar Holder <iholder@redhat.com>
@iholder101 iholder101 force-pushed the backport-0.58/virt-handler-socket-leak branch from 12d9a09 to 5db003d Compare January 1, 2023 13:45
@iholder101 iholder101 marked this pull request as ready for review January 1, 2023 13:49
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 1, 2023
@Barakmor1
Copy link
Member

/lgtm Thank you!

@Barakmor1
Copy link
Member

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 1, 2023
Copy link
Contributor

@enp0s3 enp0s3 left a comment

Choose a reason for hiding this comment

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

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enp0s3

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 1, 2023
@iholder101
Copy link
Contributor Author

/retest

@kubevirt-bot
Copy link
Contributor

kubevirt-bot commented Jan 1, 2023

@iholder101: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubevirt-goveralls 5db003d link false /test pull-kubevirt-goveralls-0.58

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@iholder101
Copy link
Contributor Author

/hold cancel

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 1, 2023
@kubevirt-bot kubevirt-bot merged commit c35eb77 into kubevirt:release-0.58 Jan 1, 2023
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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/network size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants