Skip to content

Commit b9af846

Browse files
Merge pull request #17313 from danwinship/speed-up-ovs-healthcheck
Automatic merge from submit-queue. Trivial fix to do fewer allocations in OVS healthcheck 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.)
2 parents 94489ce + 67a57a3 commit b9af846

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pkg/network/node/ovscontroller.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ func (oc *ovsController) AlreadySetUp() bool {
5858
return false
5959
}
6060
expectedVersionNote := oc.getVersionNote()
61-
for _, flow := range flows {
62-
parsed, err := ovs.ParseFlow(ovs.ParseForDump, flow)
63-
if err == nil && parsed.Table == ruleVersionTable && parsed.NoteHasPrefix(expectedVersionNote) {
64-
return true
61+
// The "version" flow should be the last one, so scan from the end
62+
for i := len(flows) - 1; i >= 0; i-- {
63+
parsed, err := ovs.ParseFlow(ovs.ParseForDump, flows[i])
64+
if err == nil && parsed.Table == ruleVersionTable {
65+
return parsed.NoteHasPrefix(expectedVersionNote)
6566
}
6667
}
6768
return false

0 commit comments

Comments
 (0)