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

[cni]: dualstack overlay hostIP issue hotfix #2290

Merged
merged 16 commits into from
Oct 27, 2023
Merged

[cni]: dualstack overlay hostIP issue hotfix #2290

merged 16 commits into from
Oct 27, 2023

Conversation

paulyufan2
Copy link
Contributor

@paulyufan2 paulyufan2 commented Oct 12, 2023

Reason for Change:

This PR is to fix this issue: https://dev.azure.com/msazure/One/_workitems/edit/25403093/

If no hostIP is provided, then we assume to use ipv4 flag, if hostIP is provided and it's ipv6 address, then we set flag to ipv6 HNS flag.

Issue Fixed:

Requirements:

Notes:

@paulyufan2 paulyufan2 requested review from a team as code owners October 12, 2023 22:03
@paulyufan2 paulyufan2 added the cni Related to CNI. label Oct 12, 2023
@paulyufan2 paulyufan2 force-pushed the hostIPIssue branch 2 times, most recently from 09996d5 to e0d830f Compare October 13, 2023 13:23
@@ -264,59 +263,55 @@ func getPoliciesFromRuntimeCfg(nwCfg *cni.NetworkConfig, isIPv6Enabled bool) []p
protocol = policy.ProtocolUdp
}

hostIP, err := netip.ParseAddr(mapping.HostIp)
if err != nil {
return nil, errors.Wrap(err, "failed to parse hostIP")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we pass the incorrect hostIP as well in the error ?

rawPolicy, _ := json.Marshal(&hnsv2.PortMappingPolicySetting{
// To support hostport policy mapping for ipv6 in dualstack overlay mode
// uint32 NatFlagsIPv6 = 2
var flag hnsv2.NatFlags
Copy link
Contributor

Choose a reason for hiding this comment

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

So earlier we were adding ipv6 policies based on cniTypesCurr.Result (which is from IPAM i suppose), but now we are directly reading the hostIP address type(v4 or v6) and based on that adding the flags ?
What if the hostip is not provided ?(is that a valid case ?)

epPolicies, err := getPoliciesFromRuntimeCfg(opt.nwCfg)
if err != nil {
logger.Error("failed to get policies from runtime configurations", zap.Error(err))
return epInfo, err
Copy link
Contributor

Choose a reason for hiding this comment

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

im surprised the linter doesn't complain about not wrapping the error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is using zap logger here

Copy link
Contributor

Choose a reason for hiding this comment

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

it's not about logging, it's about the error returned, unless that linter is not enabled for checking that errors are wrapped? @rbtr

Copy link
Member

@tamilmani1989 tamilmani1989 Oct 17, 2023

Choose a reason for hiding this comment

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

@paulyufan2 can you wrap this error before returning?

ramiro-gamarra
ramiro-gamarra previously approved these changes Oct 13, 2023
@paulyufan2 paulyufan2 force-pushed the hostIPIssue branch 3 times, most recently from e1ebd65 to 1258288 Compare October 23, 2023 22:37
ramiro-gamarra
ramiro-gamarra previously approved these changes Oct 27, 2023
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add more test cases involving ipv6 hostip as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added an ipv6 UT test

@paulyufan2 paulyufan2 merged commit b65b051 into master Oct 27, 2023
@paulyufan2 paulyufan2 deleted the hostIPIssue branch October 27, 2023 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cni Related to CNI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants