-
Notifications
You must be signed in to change notification settings - Fork 347
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
Use libovsdb bindings for collecting ovs metrics #4637
Open
crnithya
wants to merge
2
commits into
ovn-org:master
Choose a base branch
from
crnithya:libovsdb_metrics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ fi | |
|
||
go generate ./pkg/nbdb | ||
go generate ./pkg/sbdb | ||
go generate ./pkg/vswitchd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ovs | ||
|
||
import ( | ||
"context" | ||
libovsdbclient "github.com/ovn-org/libovsdb/client" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/vswitchd" | ||
) | ||
|
||
// ListBridges looks up all ovs bridges from the cache | ||
func ListBridges(ovsClient libovsdbclient.Client) ([]*vswitchd.Bridge, error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) | ||
defer cancel() | ||
searchedBridges := []*vswitchd.Bridge{} | ||
err := ovsClient.List(ctx, &searchedBridges) | ||
return searchedBridges, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ovs | ||
|
||
import ( | ||
"context" | ||
libovsdbclient "github.com/ovn-org/libovsdb/client" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/vswitchd" | ||
) | ||
|
||
type interfacePredicate func(*vswitchd.Interface) bool | ||
|
||
// ListInterfaces looks up all ovs interfaces from the cache | ||
func ListInterfaces(ovsClient libovsdbclient.Client) ([]*vswitchd.Interface, error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) | ||
defer cancel() | ||
searchedInterfaces := []*vswitchd.Interface{} | ||
err := ovsClient.List(ctx, &searchedInterfaces) | ||
return searchedInterfaces, err | ||
} | ||
|
||
// FindInterfacesWithPredicate returns all the ovs interfaces in the cache | ||
// that matches the lookup function | ||
func FindInterfacesWithPredicate(ovsClient libovsdbclient.Client, p interfacePredicate) ([]*vswitchd.Interface, error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) | ||
defer cancel() | ||
searchedInterfaces := []*vswitchd.Interface{} | ||
|
||
err := ovsClient.WhereCache(p).List(ctx, &searchedInterfaces) | ||
return searchedInterfaces, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ovs | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
libovsdbclient "github.com/ovn-org/libovsdb/client" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/vswitchd" | ||
) | ||
|
||
// Get OpenvSwitch entry from the cache | ||
func GetOpenvSwitch(ovsClient libovsdbclient.Client) (*vswitchd.OpenvSwitch, error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) | ||
defer cancel() | ||
openvSwitchList := []*vswitchd.OpenvSwitch{} | ||
err := ovsClient.List(ctx, &openvSwitchList) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(openvSwitchList) == 0 { | ||
return nil, fmt.Errorf("no openvSwitch entry found") | ||
} | ||
|
||
return openvSwitchList[0], err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that metrics is not the best amortization of the extra memory consumption this brings. But I also guess as we further migrate things to libovsdb it would make more sense. What are the plans for further pieces? This is marked as WIP, do you plan to merge this before the other pieces come? Trying to get a sense of a timeline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I am planning to start the migration to libovsdb with metrics first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to have and merge all at once? Each bit could be a different commit here, and I would do a staggered review of each without waiting for the full set. The only problem would be rebases, but we don't expect a lot of changes on the OVS calls that we make.
It is more convenient for our downstream but I understand it might be too much to ask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be difficult to address all at once. I have added another commit to this though, to address those OVN metrics using vsctl.