-
Couldn't load subscription status.
- Fork 59
🐛 Only set at most one IP address in the SubnetPort Spec #1266
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: main
Are you sure you want to change the base?
🐛 Only set at most one IP address in the SubnetPort Spec #1266
Conversation
For addresses that set in our interface spec, only set the first valid one in the SubnetPort since despite being list, that is all VPC currently supports. Handle the case where IP address our set in our interface spec but the gateway is not. In that case, use the gateway that was provided by the network provider. I modeled our IPConfig results after what the network interface CR Status have, but that is getting cumbersome for our needs here. It is kind of confusing to see multiple gateways set. We should hoist out the gateways and just separate out the IPv4 and IPv6 addresses.
| } | ||
| }) | ||
|
|
||
| It("creates SubnetPort with only MAC address when all IPs are invalid", func() { |
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 think this was a duplicate test (kept the one below)
Minimum allowed line rate is |
| continue | ||
| } | ||
|
|
||
| if interfaceSpec.Gateway4 == "" { //nolint:gocritic |
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 something like this help get rid of the //nolint:gocritic?
for _, ipConfig := range result.IPConfigs {
if ipConfig.Gateway == "" {
continue
}
if ipConfig.IsIPv4 && interfaceSpec.Gateway4 == "" {
interfaceSpec.Gateway4 = ipConfig.Gateway
}
if !ipConfig.IsIPv4 && interfaceSpec.Gateway6 == "" {
interfaceSpec.Gateway6 = ipConfig.Gateway
}
if interfaceSpec.Gateway4 != "" && interfaceSpec.Gateway6 != "" {
break
}
}
| // here. Otherwise, even for NoIPAM still honor the interface spec addresses. | ||
| if !isVPC && len(interfaceSpec.Addresses) > 0 { | ||
| if len(interfaceSpec.Addresses) > 0 { | ||
| if interfaceSpec.Gateway4 == "" || interfaceSpec.Gateway6 == "" { |
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.
nit: I do not think this is needed since the same check is done in the for loop to break early.
| Expect(subnetPort.Spec.AddressBindings[1].MACAddress).To(Equal(macAddress)) | ||
| Expect(subnetPort.Spec.AddressBindings[2].IPAddress).To(Equal(ipAddr3)) | ||
| Expect(subnetPort.Spec.AddressBindings[2].MACAddress).To(Equal(macAddress)) | ||
| /* |
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 remove those and add them back if needed in the future?
What does this PR do, and why is it needed?
For addresses that set in our interface spec, only set the first valid one in the SubnetPort since despite being list, that is all VPC currently supports.
Handle the case where IP address our set in our interface spec but the gateway is not. In that case, use the gateway that was provided by the network provider.
I modeled our IPConfig results after what the network interface CR Status have, but that is getting cumbersome for our needs here. It is kind of confusing to see multiple gateways set. We should hoist out the gateways and just separate out the IPv4 and IPv6 addresses.
Which issue(s) is/are addressed by this PR? (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Are there any special notes for your reviewer:
Please add a release note if necessary: