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: add host-side interface info to cni.Result #24901

Closed
wants to merge 2 commits into from
Closed

CNI: add host-side interface info to cni.Result #24901

wants to merge 2 commits into from

Conversation

nayihz
Copy link
Contributor

@nayihz nayihz commented Apr 14, 2023

Fixes: #24899

Add host-side interface info to cni.Result, which allows bandwidth CNI to work with Cilium

@nayihz nayihz requested a review from a team as a code owner April 14, 2023 13:38
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 14, 2023
@github-actions github-actions bot added the kind/community-contribution This was a contribution made by a community member. label Apr 14, 2023
@maintainer-s-little-helper
Copy link

Commit b1d47cba365c97754a87cf892552a0df27ce85fd does not contain "Signed-off-by".

Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin

@maintainer-s-little-helper maintainer-s-little-helper bot added dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. and removed dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. labels Apr 14, 2023
@tommyp1ckles
Copy link
Contributor

@czybjtu thanks for the PR 😄

One question, later on in the function IPs get their interface index added: https://github.com/cilium/cilium/blob/5b042476dd6f18c70bc7c0d7401cc596abf04b24/plugins/cilium-cni/main.go#L608

Would this still work if we add the host level interface first?

@nayihz
Copy link
Contributor Author

nayihz commented Apr 24, 2023

Would this still work if we add the host level interface first?

Thanks for catching this. Have fixed it. PTAL.

@@ -552,6 +557,9 @@ func cmdAdd(args *skel.CmdArgs) (err error) {
err = fmt.Errorf("unable to prepare IP addressing for '%s': %s", ep.Addressing.IPV6, err)
return
}
// Add to the result the Interface as index of Interfaces
ipConfig.Interface = cniTypesV1.Int(len(res.Interfaces))
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be:

Suggested change
ipConfig.Interface = cniTypesV1.Int(len(res.Interfaces))
ipConfig.Interface = cniTypesV1.Int(len(res.Interfaces)-1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You cannot do it this way because the index of an array starts from 0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I'm still confused,

On line: https://github.com/cilium/cilium/pull/24901/files#diff-87793c7d9c6d6a10f34d6a3efefed53dac8abd700cb05cfb2a77844ec990b744R523

So at this point res.Interfaces is either of length 0 or 1, if ip4 and ip6 are enabled then we're going to be referencing 2, which is out of bounds in the Interfaces array?

Does that make sense? This function is a bit confusing so I might be missing something 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.

On line L523, we add the host-side veth info to res.Interface which has no ip.
On line L561 and L577, ipConfig was refer to container-side veth info. ipConfig is the last element that will be added to res.Interface slice. So I think

// ipConfig.Interface represents its index in this slice.
ipConfig.Interface = cniTypesV1.Int(len(res.Interfaces))

is what we want.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does that still work if datapathmodeveth isn't enabled?

(Line 504)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. We add host side veth info to res.Interfaces only when datapathmodeveth enabled. Everything is the same as before if datapathmodeveth was not enabled.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok I see now, thanks for the clarification.

@joestringer joestringer added the release-note/minor This PR changes functionality that users may find relevant to operating Cilium. label May 5, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 5, 2023
@joestringer
Copy link
Member

/test

@joestringer
Copy link
Member

joestringer commented May 5, 2023

I've kicked off the tests to ensure there are no regressions introduced by this. Other than that I think we are just looking for @tommyp1ckles' feedback on the remaining open thread. Thanks for contributing :)

@tommyp1ckles
Copy link
Contributor

/test-1.25-4.19

@tommyp1ckles
Copy link
Contributor

/test-1.26-net-next

@tommyp1ckles
Copy link
Contributor

/test-1.16-4.19

@tommyp1ckles
Copy link
Contributor

/test-1.24-5.4

@tommyp1ckles
Copy link
Contributor

Changes LGTM 🙏 , just gonna make sure tests are passing

@nayihz nayihz requested a review from a team as a code owner May 9, 2023 09:36
@tommyp1ckles
Copy link
Contributor

tommyp1ckles commented May 9, 2023

/test

Job 'Cilium-PR-K8s-1.25-kernel-4.19' failed:

Click to show.

Test Name

K8sDatapathConfig Host firewall With native routing and endpoint routes

Failure Output

FAIL: Error deleting resource /home/jenkins/workspace/Cilium-PR-K8s-1.25-kernel-4.19/src/github.com/cilium/cilium/test/k8s/manifests/host-policies.yaml: Cannot retrieve "cilium-pwzd7"'s policy revision: cannot get policy revision: ""

Jenkins URL: https://jenkins.cilium.io/job/Cilium-PR-K8s-1.25-kernel-4.19/2065/

If it is a flake and a GitHub issue doesn't already exist to track it, comment /mlh new-flake Cilium-PR-K8s-1.25-kernel-4.19 so I can create one.

Then please upload the Jenkins artifacts to that issue.

@github-actions
Copy link

github-actions bot commented Jun 9, 2023

This pull request has been automatically marked as stale because it
has not had recent activity. It will be closed if no further activity
occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Jun 9, 2023
@tommyp1ckles
Copy link
Contributor

@czybjtu sorry, just getting back to this one, do you mind rebasing and we can make sure the tests pass.

@nayihz
Copy link
Contributor Author

nayihz commented Jun 15, 2023

@czybjtu sorry, just getting back to this one, do you mind rebasing and we can make sure the tests pass.

Done. PTAL.

@github-actions github-actions bot removed the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Jun 16, 2023
@tommyp1ckles
Copy link
Contributor

/test

Copy link
Contributor

@tommyp1ckles tommyp1ckles left a comment

Choose a reason for hiding this comment

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

Looks good, just going to make sure tests pass

@nayihz
Copy link
Contributor Author

nayihz commented Jun 16, 2023

❌ command "curl -w %{local_ip}:%{local_port} -> %{remote_ip}:%{remote_port} = %{response_code} --silent --fail --show-error --output /dev/null --connect-timeout 2 --max-time 10 --retry 3 --retry-all-errors --retry-delay 3 [http://google.com:80](http://google.com/)" failed: command failed: curl: (28) Resolving timed out after 2000 milliseconds

This doesn't seem to be related to this PR.

@ti-mo ti-mo added the dont-merge/wait-until-release Freeze window for current release is blocking non-bugfix PRs label Jun 20, 2023
@ti-mo
Copy link
Contributor

ti-mo commented Jun 20, 2023

I've approved the tests to run. Could you please add a commit description with some of the context you've outlined in the original issue? right now it's hard to tell what the intention is behind the change by just looking at the commit.

@ti-mo ti-mo added the kind/bug This is a bug in the Cilium logic. label Jun 20, 2023
This commit adds host-side interface name and
mac address to cni.Result according to CNI Specification
(https://www.cni.dev/docs/spec/#section-5-result-types)

Signed-off-by: czybjtu <smartczy@outlook.com>
@nayihz
Copy link
Contributor Author

nayihz commented Jun 23, 2023

Updated the commit message. PTAL.

@tommyp1ckles
Copy link
Contributor

not sure why tests failed, possible GH Actions issue 😕

/test

@ldelossa
Copy link
Contributor

@czybjtu GH actions is looking really off here. Can you rebase this PR and force push?

@maintainer-s-little-helper
Copy link

Commit 8445e2b does not contain "Signed-off-by".

Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin

1 similar comment
@maintainer-s-little-helper
Copy link

Commit 8445e2b does not contain "Signed-off-by".

Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. label Jun 28, 2023
@nayihz nayihz closed this by deleting the head repository Jun 28, 2023
@nayihz
Copy link
Contributor Author

nayihz commented Jun 28, 2023

I have some problems when rebase upstream because the branch name has changed(master -> main). I will open a new same pr for this.
Sorry for inconvenience.

@nayihz
Copy link
Contributor Author

nayihz commented Jun 28, 2023

#26518

New pr has been created. PTAL

@joestringer joestringer removed the dont-merge/wait-until-release Freeze window for current release is blocking non-bugfix PRs label Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dont-merge/needs-sign-off The author needs to add signoff to their commits before merge. kind/bug This is a bug in the Cilium logic. kind/community-contribution This was a contribution made by a community member. release-note/minor This PR changes functionality that users may find relevant to operating Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cilium CNI cannot be used in combination with bandwidth CNI
5 participants