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

WIP virt-controller, ipam: Improve ipamclaim package isolation #11892

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

oshoval
Copy link
Contributor

@oshoval oshoval commented May 12, 2024

What this PR does

Improve isolation between network and ipamclaim packages by presenting a builder
for GenerateMultusCNIAnnotationFromNameScheme.
Drop ipamclaims types package, now that the cycling dependency is solved.

Fixes #

Why we need it and why it was done in this way

The following tradeoffs were made:

The following alternatives were considered:

Links to places where the discussion took place:

Special notes for your reviewer

Just last 4 commits are relevant, rest is cherry-pick of #11410

If desired, the original logic of GenerateMultusCNIAnnotationFromNameScheme can be split to more
builder methods.

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note

None

@kubevirt-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 12, 2024
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign stu-gott for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added size/XXL sig/buildsystem Denotes an issue or PR that relates to changes in the build system. sig/network release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 12, 2024
@oshoval oshoval mentioned this pull request May 12, 2024
8 tasks
@oshoval oshoval force-pushed the ipam2 branch 3 times, most recently from 4fe8610 to a997dea Compare May 12, 2024 12:32
@oshoval oshoval changed the title WIP virt-controller, ipam: Improve ipamclaim / network package isolation virt-controller, ipam: Improve ipamclaim / network package isolation May 12, 2024
@oshoval oshoval marked this pull request as ready for review May 12, 2024 12:32
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 12, 2024
@oshoval
Copy link
Contributor Author

oshoval commented May 12, 2024

/cc @qinqon @maiqueb
Please take a look
Thanks

(will rebase again soon, i don't think it should block review)

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 12, 2024
@oshoval oshoval changed the title virt-controller, ipam: Improve ipamclaim / network package isolation virt-controller, ipam: Improve ipamclaim package isolation May 12, 2024
@oshoval
Copy link
Contributor Author

oshoval commented May 13, 2024

Lets wait with the review please, because original PR can be changed, drafting

@oshoval oshoval marked this pull request as draft May 13, 2024 07:02
@kubevirt-bot kubevirt-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 13, 2024
@oshoval oshoval changed the title virt-controller, ipam: Improve ipamclaim package isolation WIP virt-controller, ipam: Improve ipamclaim package isolation May 13, 2024
oshoval added 16 commits May 29, 2024 14:38
Allows us to use the new IPAMClaimReference
which is required for the new secondary networks IPAM feature.

Signed-off-by: Or Shoval <oshoval@redhat.com>
Instead only checking if a VMI has an owner,
return it also in case it does.
Usable when we need to owner itself if exists.

The next commit will require it, because it needs the VMI
owner ref itself, in case it exists.
It adds the same owner ref to the IPAM Claim it creates.
This way we don't need to do seperate check if it has
an owner ref and then to fetch if it does.

Signed-off-by: Or Shoval <oshoval@redhat.com>
PersistentIPs FG should be enabled in order to consume
a NAD that uses allowPersistentIPs knob.

Signed-off-by: Or Shoval <oshoval@redhat.com>
Refactor GetNetworkToResourceMap logic to first get all the NADs,
and then extract the required info.

This in turn will allow extracing more required info from the NAD on following
commits, without reading them twice in the same context.

Signed-off-by: Or Shoval <oshoval@redhat.com>
Packname should be network_test, update it.
Remove non exported functions unit testing as we need to unit
test only the package API.

Export GetNamespaceAndNetworkName, so we can use it
as part of createNADs.

Signed-off-by: Or Shoval <oshoval@redhat.com>
This way we can use it in a more generic way,
i.e on packages which the network package itself imports,
without creating cycling dependency.

Signed-off-by: Or Shoval <oshoval@redhat.com>
Include the new required ipamclaims package.

Signed-off-by: Or Shoval <oshoval@redhat.com>
Signed-off-by: Or Shoval <oshoval@redhat.com>
The generated client-go of ipamclaims is already available at
https://github.com/k8snetworkplumbingwg/ipamclaims
so we don't need to generate it ourselves as done for other clients
(see hack/generate.sh).
It is exactly the client we need already.

Signed-off-by: Or Shoval <oshoval@redhat.com>
This pacakge allows supporting IPAM for virtualization workloads.
Allowing VMs to get the same IP addresses during:
1. VM restart
2. VM migration

Hot plug is not supported yet, more info in the relevant commit.

Signed-off-by: Or Shoval <oshoval@redhat.com>
Once a new pod is created, create the required ipam claims.
Note we don't support hotplug yet, so it the new method
can support only hashed interfaces naming scheme.

We are using a builder method WithIPAMClaimManager,
this way we don't affect the non relevant unit tests,
so we don't need to mock anything.

Signed-off-by: Or Shoval <oshoval@redhat.com>
Interfaces that requested persistent IPs, are annotated with
the corresponding ipam claim.
This way the CNI knows that the feature is enabled, and which
ipam claim is associated with each interface.

Signed-off-by: Or Shoval <oshoval@redhat.com>
… interfaces

Since we don't support yet persistent IPs hotplug / hotunplug,
block it on VM level, and log about the blocking.
This way the VMI will still reflect the right state as done for
interfaces with ordinal naming scheme.

On the other hand, we must pass the ipam claim parameters,
when recalculating the annotations upon hotplug / hotunplug,
so the ipam claim reference won't be stripped, once other
interface is hotplugged / hotunplugged.

Signed-off-by: Or Shoval <oshoval@redhat.com>
This is a pre reafactor that removes passing networkToIPAMClaimParams
when generating multus annotations.
The next commit will present an alternative that allows better isolation
between network and ipamclaims packages.

Signed-off-by: Or Shoval <oshoval@redhat.com>
Make GenerateMultusCNIAnnotationFromNameScheme as a builder.
This allows amending the annotations, using external go packages.

Signed-off-by: Or Shoval <oshoval@redhat.com>
WithIPAMClaimRef method finds a multus annotation according to the network name
(and a non-empty interface request), and adds the desired
ipam claim reference to it.

Signed-off-by: Or Shoval <oshoval@redhat.com>
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has DCO signed all their commits. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. sig/buildsystem Denotes an issue or PR that relates to changes in the build system. sig/network size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants