-
Notifications
You must be signed in to change notification settings - Fork 263
[feat] Prefix on NIC v6 windows support #4060
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
base: master
Are you sure you want to change the base?
Changes from all commits
01e4ea0
942e890
eed5080
ec4f359
5ca999b
23a756b
bc3cad8
4395f17
8e673c3
aef689e
d37a407
15e66d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,12 +229,12 @@ func (service *HTTPRestService) syncHostNCVersion(ctx context.Context, channelMo | |
| return len(programmedNCs), errors.Wrap(err, "failed to get nc version list from nmagent") | ||
| } | ||
|
|
||
| // Get IMDS NC versions for delegated NIC scenarios | ||
| imdsNCVersions, err := service.GetIMDSNCs(ctx) | ||
| if err != nil { | ||
| // If any of the NMA API check calls, imds calls fails assume that nma build doesn't have the latest changes and create empty map | ||
| imdsNCVersions = make(map[string]string) | ||
| } | ||
| // Get IMDS NC versions for delegated NIC scenarios. | ||
| imdsNCVersions, infraNicMacAddress := service.getIMDSNCs(ctx) | ||
|
|
||
| // Process Windows registry keys with the retrieved MAC address (empty if not found). It is required for HNS team to configure cilium routes sepcific to windows nodes. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: cilium routes "specific" to windows nodes and nit: isPrefixOnNicSwiftV2() (capital "O" for camel case or isPrefixOnNICSwiftV2() for capitalized acronyms) |
||
| isPrefixOnNic := service.isPrefixonNicSwiftV2() | ||
| service.processWindowsRegistryKeys(isPrefixOnNic, infraNicMacAddress) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you confirm that it's intentional that this runs even for non-prefix on nic scenarios? |
||
|
|
||
| nmaNCs := map[string]string{} | ||
| for _, nc := range ncVersionListResp.Containers { | ||
|
|
@@ -691,31 +691,31 @@ func (service *HTTPRestService) isNCDetailsAPIExists(ctx context.Context) bool { | |
| return false | ||
| } | ||
|
|
||
| // GetIMDSNCs gets NC versions from IMDS and returns them as a map | ||
| func (service *HTTPRestService) GetIMDSNCs(ctx context.Context) (map[string]string, error) { | ||
| // GetIMDSNCs gets NC versions from IMDS and returns them as a map along with the MAC address | ||
| func (service *HTTPRestService) getIMDSNCs(ctx context.Context) (ncs map[string]string, infraNicMacAddress string) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we're also getting the mac of the infra nic, maybe this should be something like getIMDSInfo now? |
||
| imdsClient := service.imdsClient | ||
| if imdsClient == nil { | ||
| //nolint:staticcheck // SA1019: suppress deprecated logger.Printf usage. Todo: legacy logger usage is consistent in cns repo. Migrates when all logger usage is migrated | ||
| logger.Errorf("IMDS client is not available") | ||
| return make(map[string]string), nil | ||
| return make(map[string]string), "" | ||
| } | ||
| // Check NC version support | ||
| if !service.isNCDetailsAPIExists(ctx) { | ||
| //nolint:staticcheck // SA1019: suppress deprecated logger.Printf usage. Todo: legacy logger usage is consistent in cns repo. Migrates when all logger usage is migrated | ||
| logger.Errorf("IMDS does not support NC details API") | ||
| return make(map[string]string), nil | ||
| return make(map[string]string), "" | ||
| } | ||
|
|
||
| // Get all network interfaces from IMDS | ||
| networkInterfaces, err := imdsClient.GetNetworkInterfaces(ctx) | ||
| if err != nil { | ||
| //nolint:staticcheck // SA1019: suppress deprecated logger.Printf usage. Todo: legacy logger usage is consistent in cns repo. Migrates when all logger usage is migrated | ||
| logger.Errorf("Failed to get network interfaces from IMDS: %v", err) | ||
| return make(map[string]string), nil | ||
| return make(map[string]string), "" | ||
| } | ||
|
|
||
| // Build ncs map from the network interfaces | ||
| ncs := make(map[string]string) | ||
| ncs = make(map[string]string) | ||
| for _, iface := range networkInterfaces { | ||
| //nolint:staticcheck // SA1019: suppress deprecated logger.Debugf usage. Todo: legacy logger usage is consistent in cns repo. Migrates when all logger usage is migrated | ||
| logger.Debugf("Nc id: %s and mac address: %s from IMDS call", iface.InterfaceCompartmentID, iface.MacAddress.String()) | ||
|
|
@@ -724,10 +724,24 @@ func (service *HTTPRestService) GetIMDSNCs(ctx context.Context) (map[string]stri | |
|
|
||
| if ncID != "" { | ||
| ncs[ncID] = PrefixOnNicNCVersion // for prefix on nic version scenario nc version is 1 | ||
| } else { | ||
| infraNicMacAddress = iface.MacAddress.String() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does having an empty ncID mean and when does this happen? can this be added as a comment for the function? can we also clarify in the comment what mac address we are getting? will the infra nic mac address ever be empty if all the network interfaces have nc ids? |
||
| } | ||
| } | ||
|
|
||
| return ncs, nil | ||
| return ncs, infraNicMacAddress | ||
| } | ||
|
|
||
| // Check whether NC is SwiftV2 NIC associated NC and prefix on nic is enabled | ||
| func (service *HTTPRestService) isPrefixonNicSwiftV2() bool { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the comment it seems more like "check whether any NC is a swiftv2 nic with prefix on nic enabled" rather than any particular NC-- when this is enabled is there typically only 1 NC (or is it multitenant?)? |
||
| for i := range service.state.ContainerStatus { | ||
| req := service.state.ContainerStatus[i].CreateNetworkContainerRequest | ||
|
|
||
| if req.SwiftV2PrefixOnNic { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| // IsCIDRSuperset returns true if newCIDR is a superset of oldCIDR (i.e., all IPs in oldCIDR are contained in newCIDR). | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,44 @@ func (c *iptablesLegacy) Delete(table, chain string, rulespec ...string) error { | |
| return errors.Wrap(exec.Command("iptables-legacy", cmd...).Run(), "iptables legacy failed delete") | ||
| } | ||
|
|
||
| // processWindowsRegistryKeys is a no-op on Linux. | ||
| func (service *HTTPRestService) processWindowsRegistryKeys(_ bool, _ string) { | ||
| // No-op on Linux | ||
| } | ||
|
|
||
| // linuxRegistryClient is a no-op implementation of windowsRegistryClient for Linux. | ||
| type linuxRegistryClient struct{} | ||
|
|
||
| // SetPrefixOnNicEnabled is a no-op on Linux. | ||
| func (*linuxRegistryClient) SetPrefixOnNicEnabled(_ bool) error { | ||
| return nil | ||
| } | ||
|
|
||
| // SetInfraNicMacAddress is a no-op on Linux. | ||
| func (*linuxRegistryClient) SetInfraNicMacAddress(_ string) error { | ||
| return nil | ||
| } | ||
|
|
||
| // SetInfraNicIfName is a no-op on Linux. | ||
| func (*linuxRegistryClient) SetInfraNicIfName(_ string) error { | ||
| return nil | ||
| } | ||
|
|
||
| // SetEnableSNAT is a no-op on Linux. | ||
| func (*linuxRegistryClient) SetEnableSNAT(_ bool) error { | ||
| return nil | ||
| } | ||
|
|
||
| // newLinuxRegistryClient creates a no-op registry client for Linux. | ||
| func newLinuxRegistryClient() windowsRegistryClient { | ||
| return &linuxRegistryClient{} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NihaNallappagari I don't think you have understood my earlier feedback on OS abstraction/separations. A func called If you need to make stubs like this, the place that you are calling these stubs is OS specific code already. THAT is what should be refactored in to Windows and Linux versions. |
||
| } | ||
|
|
||
| // newRegistryClient creates the OS-specific registry client (Linux implementation). | ||
| func newRegistryClient() windowsRegistryClient { | ||
| return newLinuxRegistryClient() | ||
| } | ||
|
|
||
| // nolint | ||
| func (service *HTTPRestService) programSNATRules(req *cns.CreateNetworkContainerRequest) (types.ResponseCode, string) { | ||
| service.Lock() | ||
|
|
||
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 you check conversion_test.go passes when OS=windows-- this request is the expected for one of the tests but in the test we set swiftv2 to false