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

Use OVS port external_ids to save Antrea interface type #3027

Merged
merged 1 commit into from
Dec 7, 2021

Conversation

wenyingd
Copy link
Contributor

@wenyingd wenyingd commented Nov 15, 2021

Introduce Antrea interface yype to map the OVS port to Antrea created
interfaces, and use OVS port external_ids field to save the
configuration. This is helpful for Antrea to define more interface types.

Signed-off-by: wenyingd [email protected]

@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2021

Codecov Report

Merging #3027 (58c399d) into main (9a52de9) will decrease coverage by 1.19%.
The diff coverage is 40.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3027      +/-   ##
==========================================
- Coverage   60.94%   59.75%   -1.20%     
==========================================
  Files         292      292              
  Lines       24742    24801      +59     
==========================================
- Hits        15079    14819     -260     
- Misses       8012     8374     +362     
+ Partials     1651     1608      -43     
Flag Coverage Δ
kind-e2e-tests 46.40% <27.65%> (-1.69%) ⬇️
unit-tests 40.07% <19.14%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/agent/agent_linux.go 3.62% <0.00%> (-0.06%) ⬇️
pkg/agent/interfacestore/types.go 72.72% <ø> (ø)
pkg/ovs/ovsconfig/ovs_client.go 46.13% <0.00%> (-1.22%) ⬇️
pkg/agent/agent.go 50.90% <48.68%> (-0.96%) ⬇️
pkg/agent/cniserver/pod_configuration.go 53.51% <100.00%> (+0.18%) ⬆️
...g/agent/apiserver/handlers/featuregates/handler.go 0.00% <0.00%> (-82.36%) ⬇️
...kg/apiserver/registry/system/supportbundle/rest.go 19.54% <0.00%> (-55.18%) ⬇️
pkg/support/dump_others.go 0.00% <0.00%> (-51.73%) ⬇️
pkg/support/dump.go 8.13% <0.00%> (-49.60%) ⬇️
...g/agent/apiserver/handlers/addressgroup/handler.go 0.00% <0.00%> (-40.00%) ⬇️
... and 17 more

@wenyingd
Copy link
Contributor Author

/test-all
/test-ipv6-all
/test-windows-all
/test-ipv6-only-all

case ovsconfig.AntreaHostIF:
// Not load the host interface.
intf = nil
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we do not have a type for container interface here?

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 originally thought the default case was the container Interface like the old way. Added.

pkg/agent/agent.go Outdated Show resolved Hide resolved
@wenyingd wenyingd force-pushed the antrea_if_type branch 2 times, most recently from aa13484 to f594a81 Compare November 18, 2021 09:37
intf = nil
case ovsconfig.AntreaContainer:
// The port should be for a container interface.
intf = cniserver.ParseOVSPortInterfaceConfig(port, ovsPort, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to have other unknown type string here, or we already checked earlier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean we need another type like "AntreaUnknown" except for "AntreaUnSet" (https://github.com/antrea-io/antrea/pull/3027/files/f594a81c0f13f1c2e784c07f9e3d2a04ef2499dd#). From the existing code, all above types are what we have used, and we use "AntreaUnSet" if we didn't find key "AntreaIFType" from the external_ids.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant what happens if the value of AntreaIFType is not any of our predefined one? Do we check earlier or we should check here.

Copy link
Contributor Author

@wenyingd wenyingd Nov 19, 2021

Choose a reason for hiding this comment

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

No, I didn't check it earlier. If the value is not by use defined, the intf is nil, and we have a precheck on "intf != nil" before adding the intf to interfaceStore. So here I would add one case for unknown (maybe default) and add log. I don't think we need a specific type string for "AntreaUnknown", because it is only one string value and can match all unpredefined values.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me.

@wenyingd
Copy link
Contributor Author

/test-all
/test-ipv6-all
/test-windows-all
/test-ipv6-only-all

pkg/agent/agent.go Outdated Show resolved Hide resolved
jianjuns
jianjuns previously approved these changes Nov 23, 2021
@wenyingd wenyingd requested a review from tnqn November 23, 2021 08:58
@@ -226,50 +226,94 @@ func (i *Initializer) initInterfaceStore() error {
return err
}

parseGatewayIFFunc := func(port *ovsconfig.OVSPortData, ovsPort *interfacestore.OVSPortConfig) *interfacestore.InterfaceConfig {
Copy link
Member

Choose a reason for hiding this comment

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

Could we write shorthand of single word in camel case to be differentiated from acronyms?
For example, we use svc instead of SVC for service, use ch instead of CH for channel, use cfg instead CFG for configration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change to "parseGatewayInterfaceFunc"

InterfaceName: port.Name,
OVSPortConfig: ovsPort,
} else {
// Antrea Interface type is not saved in OVS Interface external_ids in earlier Antrea versions, so we use
Copy link
Member

Choose a reason for hiding this comment

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

Since this change will affect the existing storage and introduces upgrade complexity, I'd like to understand why we need these types explicitly stored. Doesn't the "type" of OVS interface already differentiate internal port, tunnel port, and attached port (including container port and uplink port)? What do we want to differentiate further?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The existing code is actually using the predefined ofport number to parse some kinds of the interfaces, e.g. gw0, uplink, this has two weaks: 1) If the OF port number is taken before creating the OVS port, the actual port number allocated by OVS is different from ofport_request, then we might fail in restart case when using these predefined numbers; 2) It is difficult to expand to multiple interfaces with such types, like supporting multiple uplink interfaces. Using a fixed type value can resolve the above issues.

pkg/ovs/ovsconfig/ovs_client.go Outdated Show resolved Hide resolved
pkg/ovs/ovsconfig/ovs_client.go Outdated Show resolved Hide resolved
pkg/agent/openflow/fields.go Outdated Show resolved Hide resolved
pkg/ovs/ovsconfig/interfaces.go Outdated Show resolved Hide resolved
pkg/ovs/ovsconfig/ovs_client.go Outdated Show resolved Hide resolved
@wenyingd
Copy link
Contributor Author

/test-all
/test-ipv6-all
/test-windows-all
/test-ipv6-only-all

@wenyingd wenyingd changed the title Use OVS Interface external_ids to save Antrea Interface type Use OVS port external_ids to save Antrea interface type Nov 29, 2021
@wenyingd
Copy link
Contributor Author

/test-all
/test-ipv6-all
/test-windows-all
/test-ipv6-only-all

@wenyingd
Copy link
Contributor Author

/test-conformance
/test-ipv6-all
/test-windows-all

pkg/ovs/ovsconfig/interfaces.go Outdated Show resolved Hide resolved
pkg/agent/agent_test.go Outdated Show resolved Hide resolved
@@ -208,7 +211,7 @@ func (i *Initializer) BridgeUplinkToOVSBridge() error {
return err
}
// Create uplink port.
uplinkPortUUId, err := i.ovsBridgeClient.CreateUplinkPort(uplink, config.UplinkOFPort, map[string]interface{}{"antrea-uplink": "true"})
uplinkPortUUId, err := i.ovsBridgeClient.CreateUplinkPort(uplink, config.UplinkOFPort, map[string]interface{}{"antrea-uplink": "true", interfacestore.AntreaInterfaceTypeKey: interfacestore.AntreaUplink})
Copy link
Member

Choose a reason for hiding this comment

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

Should we deprecate "antrea-uplink"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gran-vmv is it possible to use the Antrea interface type instead of the "antrea-uplink"? May I know where is "antrea-uplink" used in the existing code?

Copy link
Member

Choose a reason for hiding this comment

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

It's used in start_ovs for ensuring the uplink is removed before stopping ovs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it is used to check the existence of uplink when OVS shutdown, you can refactor here if you want to remove existing key-value.

while [ "`ovsdb-client dump Port|grep \"{antrea-uplink=\\\"true\\\"}\"`" != "" ]; do

pkg/agent/agent.go Outdated Show resolved Hide resolved
Introduce Antrea interface type to map the OVS port to Antrea created
interfaces, and use OVS port external_ids field to save the
configuration. This is helpful for Antrea to define more interface
types.

Signed-off-by: wenyingd <[email protected]>
@wenyingd
Copy link
Contributor Author

wenyingd commented Dec 1, 2021

/test-integration
/test-all
/test-ipv6-all
/test-windows-all
/test-ipv6-only-all

@wenyingd
Copy link
Contributor Author

wenyingd commented Dec 1, 2021

/test-windows-all
/test-windows-proxyall-e2e

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn
Copy link
Member

tnqn commented Dec 2, 2021

/test-flexible-ipam-e2e

@wenyingd
Copy link
Contributor Author

wenyingd commented Dec 3, 2021

/test-windows-all

@tnqn
Copy link
Member

tnqn commented Dec 6, 2021

/test-flexible-ipam-e2e

1 similar comment
@wenyingd
Copy link
Contributor Author

wenyingd commented Dec 7, 2021

/test-flexible-ipam-e2e

@tnqn tnqn merged commit 3fed840 into antrea-io:main Dec 7, 2021
@wenyingd wenyingd deleted the antrea_if_type branch August 15, 2022 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants