-
Notifications
You must be signed in to change notification settings - Fork 369
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
Conversation
8ab252f
to
5e69e3c
Compare
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
5e69e3c
to
648c4bc
Compare
/test-all |
pkg/agent/agent.go
Outdated
case ovsconfig.AntreaHostIF: | ||
// Not load the host interface. | ||
intf = nil | ||
default: |
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.
Why we do not have a type for container interface here?
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 originally thought the default case was the container Interface like the old way. Added.
aa13484
to
f594a81
Compare
intf = nil | ||
case ovsconfig.AntreaContainer: | ||
// The port should be for a container interface. | ||
intf = cniserver.ParseOVSPortInterfaceConfig(port, ovsPort, true) |
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.
Is it possible to have other unknown type string here, or we already checked earlier?
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.
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.
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 meant what happens if the value of AntreaIFType is not any of our predefined one? Do we check earlier or we should check here.
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.
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.
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.
Sounds good to me.
f594a81
to
faa7965
Compare
/test-all |
pkg/agent/agent.go
Outdated
@@ -226,50 +226,94 @@ func (i *Initializer) initInterfaceStore() error { | |||
return err | |||
} | |||
|
|||
parseGatewayIFFunc := func(port *ovsconfig.OVSPortData, ovsPort *interfacestore.OVSPortConfig) *interfacestore.InterfaceConfig { |
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.
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.
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.
change to "parseGatewayInterfaceFunc"
pkg/agent/agent.go
Outdated
InterfaceName: port.Name, | ||
OVSPortConfig: ovsPort, | ||
} else { | ||
// Antrea Interface type is not saved in OVS Interface external_ids in earlier Antrea versions, so we use |
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.
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?
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.
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.
55a2311
to
434ed24
Compare
/test-all |
434ed24
to
c6c6aa7
Compare
c6c6aa7
to
e503455
Compare
/test-all |
/test-conformance |
pkg/agent/agent_linux.go
Outdated
@@ -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}) |
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.
Should we deprecate "antrea-uplink"?
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.
@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?
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's used in start_ovs for ensuring the uplink is removed before stopping ovs.
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, it is used to check the existence of uplink when OVS shutdown, you can refactor here if you want to remove existing key-value.
antrea/build/images/scripts/start_ovs
Line 114 in eded51a
while [ "`ovsdb-client dump Port|grep \"{antrea-uplink=\\\"true\\\"}\"`" != "" ]; do |
e503455
to
2fd1027
Compare
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]>
2fd1027
to
58c399d
Compare
/test-integration |
/test-windows-all |
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.
LGTM
/test-flexible-ipam-e2e |
/test-windows-all |
/test-flexible-ipam-e2e |
1 similar comment
/test-flexible-ipam-e2e |
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]