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

Trivial fix to do fewer allocations in OVS healthcheck #17313

Merged

Conversation

danwinship
Copy link
Contributor

Make ovsController.AlreadySetUp() scan the flows in reverse order; the flow we're looking for is in the highest-numbered table, and ovs-ofctl dump-flows returns the flows sorted by table number, so if we parse them in forward order, we'll end up unnecessarily parsing every single flow, while parsing them in reverse means we only parse one.

(Also stop parsing further flows once we found the one we were looking for, even if it has the wrong value.)

Fixes #17312

(We can also make improvements to ParseFlow itself later, but this just seemed like the simplest fix for the immediate problem.)

@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 14, 2017
@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 14, 2017
parsed, err := ovs.ParseFlow(ovs.ParseForDump, flow)
if err == nil && parsed.Table == ruleVersionTable && parsed.NoteHasPrefix(expectedVersionNote) {
return true
for i := len(flows)-1; i >= 0; i-- {

Choose a reason for hiding this comment

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

Adding a comment here will be helpful: Processing the flows in the reverse order will find the flow rule quicker as version table is on the highest numbered table

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if err == nil && parsed.Table == ruleVersionTable && parsed.NoteHasPrefix(expectedVersionNote) {
return true
for i := len(flows)-1; i >= 0; i-- {
parsed, err := ovs.ParseFlow(ovs.ParseForDump, flows[i])

Choose a reason for hiding this comment

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

Is there a go bindings for ovs that we can use instead of calling ovs CLI commands?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. There are bindings for the ovs-vsctl side of things, but not ovs-ofctl.

But this patch was mostly just a quick fix for 3.7.z. I have ideas on further improvements already.

@smarterclayton
Copy link
Contributor

Sgtm, algorithmic >> mechanical any day

@danwinship danwinship force-pushed the speed-up-ovs-healthcheck branch from 5250fc0 to add3c37 Compare November 15, 2017 14:30
@danwinship danwinship force-pushed the speed-up-ovs-healthcheck branch from add3c37 to 67a57a3 Compare November 15, 2017 14:53
@pravisankar
Copy link

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 15, 2017
@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danwinship, pravisankar

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@danwinship
Copy link
Contributor Author

/retest

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue.

@openshift-merge-robot openshift-merge-robot merged commit b9af846 into openshift:master Nov 15, 2017
@openshift-ci-robot
Copy link

@danwinship: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/extended_conformance_install_update 67a57a3 link /test extended_conformance_install_update

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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.

@smarterclayton
Copy link
Contributor

/cherrypick release-3.7

@openshift-cherrypick-robot

@smarterclayton: New pull request created: #17333

In response to this:

/cherrypick release-3.7

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.

openshift-merge-robot added a commit that referenced this pull request Nov 20, 2017
…-17313-to-release-3.7

Automatic merge from submit-queue.

Automated cherry-pick of #17313 on release-3.7

This is an automated cherry-pick of #17313

/assign smarterclayton
@danwinship danwinship deleted the speed-up-ovs-healthcheck branch November 28, 2017 20:51
openshift-merge-robot added a commit that referenced this pull request Jan 23, 2018
Automatic merge from submit-queue.

OVS parsing improvements

The more-complicated version of #17313. This takes advantage of the fact that "ovs-ofctl dump-flows" lets you pass a filter, so rather than getting back the whole list of flows and parsing each one, we can just ask for a much smaller set of flows to begin with.

In particular:
- in AlreadySetUp() we can `DumpFlows("table=%d", ruleVersionTable)` and get back only the single flow we're looking for
- in getPodDetailsBySandboxID(), we can `DumpFlows("table=20,arp")` and only get back the flows that *might* be the one we're looking for. (You can't match on the `actions` field, so there's no way to request only the flow that has the specific `note` that we're looking for. We *could* store the first 4 bytes of the sandbox ID in the cookie and then add that to the filter, I guess, but this code doesn't get run much anyway...)
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. component/networking lgtm Indicates that a PR is ready to be merged. sig/networking size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OVS parsing on busy nodes results in heavy node allocations, CPU use
6 participants