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

api: add ovn bridge mappings to node network state #1237

Merged
merged 1 commit into from
May 6, 2024

Conversation

maiqueb
Copy link
Contributor

@maiqueb maiqueb commented Apr 29, 2024

Is this a BUG FIX or a FEATURE ?:

Uncomment only one, leave it on its own line:

/kind bug

/kind enhancement

What this PR does / why we need it:
This PR exposes the node's ovn bridge mappings (already provided on nmstatectl show) via the NNS object.

Special notes for your reviewer:

Release note:

Display OVN bridge mappings on the NodeNetworkState object

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Apr 29, 2024
@kubevirt-bot
Copy link
Collaborator

Hi @maiqueb. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@maiqueb
Copy link
Contributor Author

maiqueb commented Apr 29, 2024

/cc @qinqon

@maiqueb maiqueb force-pushed the expose-ovn-bridge-mappings-nns branch from c2c4714 to b99fcf4 Compare April 29, 2024 15:24
@maiqueb maiqueb marked this pull request as ready for review April 29, 2024 15:28
@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 Apr 29, 2024
Copy link
Member

@qinqon qinqon left a comment

Choose a reason for hiding this comment

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

Let's generalize this PR and add the missing top level field with a transparent data type json.RawMessage.

Comment on lines +106 to +115

type bridgeMappings struct {
PhysicalNetworkMappings []PhysicalNetworks `json:"bridge-mappings,omitempty" yaml:"bridge-mappings,omitempty"`
}

type PhysicalNetworks struct {
Name string `json:"localnet" yaml:"localnet"`
Bridge string `json:"bridge" yaml:"bridge"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
}
Copy link
Member

Choose a reason for hiding this comment

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

This is not really needed since we don't need to filter it out, we just need an "ovn" field at desiredState level of type json.RawMessage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not only filtering - it makes testing a lot easier, since I can use these structs to assert against.

I prefer to

Expect(nodeBridgeMappings(node)).To(
				ConsistOf(state.PhysicalNetworks{Name: networkName, Bridge: bridgeName}))

instead of comparing against a string.

But I won't insist.

Copy link
Member

Choose a reason for hiding this comment

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

We will consume a generated golang api in the furure so I am ok with this.

@@ -28,6 +28,7 @@ type rootState struct {
Interfaces []interfaceState `json:"interfaces" yaml:"interfaces"`
Routes *routes `json:"routes,omitempty" yaml:"routes,omitempty"`
DNSResolver *dnsResolver `json:"dns-resolver,omitempty" yaml:"dns-resolver,omitempty"`
Ovn *bridgeMappings `json:"ovn,omitempty" yaml:"ovn,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Ovn *bridgeMappings `json:"ovn,omitempty" yaml:"ovn,omitempty"`
Ovn json.RawMessage `json:"ovn,omitempty" yaml:"ovn,omitempty"`

Copy link
Member

Choose a reason for hiding this comment

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

Now that we are a it maybe we can add the missing ones looking at https://docs.rs/nmstate/latest/nmstate/struct.NetworkState.html

We are missing:

  • hostname
  • route-rules
  • ovs-db

So we can do the following

type rootState struct {
	Interfaces  []interfaceState `json:"interfaces"             yaml:"interfaces"`
	Routes      *routes          `json:"routes,omitempty"       yaml:"routes,omitempty"`
	DNSResolver *dnsResolver     `json:"dns-resolver,omitempty" yaml:"dns-resolver,omitempty"`
        Hostname         json.RawMessage  `json:"hostname,omitempty"          yaml:"ovn,omitempty"`
        RouteRules         json.RawMessage  `json:"route-rules,omitempty"          yaml:"ovn,omitempty"`
        OVSDb         json.RawMessage  `json:"ovs-db,omitempty"          yaml:"ovs-db,omitempty"`
        OVN         json.RawMessage  `json:"ovn,omitempty"          yaml:"ovn,omitempty"`
}

Copy link
Member

Choose a reason for hiding this comment

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

An alternative is a custom encoder that will just bypass whatever we don't need to filter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather focus exclusively on the attributes that I need to add. And test only those attributes.

@qinqon
Copy link
Member

qinqon commented Apr 30, 2024

/lgtm
/approve

@kubevirt-bot kubevirt-bot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 30, 2024
@maiqueb maiqueb force-pushed the expose-ovn-bridge-mappings-nns branch from b99fcf4 to 874deca Compare April 30, 2024 13:24
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 30, 2024
@qinqon
Copy link
Member

qinqon commented Apr 30, 2024

/lgtm
/ok-to-test

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 30, 2024
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
@maiqueb maiqueb force-pushed the expose-ovn-bridge-mappings-nns branch from 874deca to caf1f23 Compare April 30, 2024 14:33
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 30, 2024
Copy link
Member

@qinqon qinqon left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label May 6, 2024
@kubevirt-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qinqon

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

@maiqueb
Copy link
Contributor Author

maiqueb commented May 6, 2024

/test pull-kubernetes-nmstate-e2e-operator-k8s

@kubevirt-bot
Copy link
Collaborator

@maiqueb: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test pull-kubernetes-nmstate-e2e-operator-k8s

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.

@qinqon
Copy link
Member

qinqon commented May 6, 2024

/ok-to-test

@maiqueb
Copy link
Contributor Author

maiqueb commented May 6, 2024

/test pull-kubernetes-nmstate-e2e-operator-k8s

@kubevirt-bot
Copy link
Collaborator

@maiqueb: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test pull-kubernetes-nmstate-e2e-operator-k8s

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.

@qinqon qinqon added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label May 6, 2024
@maiqueb
Copy link
Contributor Author

maiqueb commented May 6, 2024

/test pull-kubernetes-nmstate-e2e-operator-k8s

@kubevirt-bot
Copy link
Collaborator

kubevirt-bot commented May 6, 2024

@maiqueb: 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-kubernetes-nmstate-e2e-handler-k8s-future caf1f23 link false /test pull-kubernetes-nmstate-e2e-handler-k8s-future

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.

@maiqueb
Copy link
Contributor Author

maiqueb commented May 6, 2024

hm, I'm checking this locally and it passes.

Could it be we need to somehow integrate OVS in CI for this to work ?

@maiqueb
Copy link
Contributor Author

maiqueb commented May 6, 2024

/test pull-kubernetes-nmstate-e2e-handler-k8s

@kubevirt-bot kubevirt-bot merged commit 84ca0cb into nmstate:main May 6, 2024
7 of 8 checks passed
@maiqueb maiqueb deleted the expose-ovn-bridge-mappings-nns branch May 6, 2024 15:52
@maiqueb
Copy link
Contributor Author

maiqueb commented May 6, 2024

@qinqon ok, so this got merged.

When / how will it become available downstream ? What's the flow here ? ... Will it be automatically cherry-picked downstream by some automation, or do I need to do something further ?

Thanks for your help and time.

@mkowalski
Copy link
Member

It will land in downstream automatically after a few days. Unless you have a critical case and need it in downstream immediately, there is nothing to do at all, just sit and watch

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. kind/bug lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants