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

Mount multus socket and invoke delegate #24

Merged
merged 4 commits into from
Oct 5, 2022

Conversation

maiqueb
Copy link
Collaborator

@maiqueb maiqueb commented Sep 29, 2022

This PR mounts the multus-cni server socket into the dynamic network's controller pods (they run as a daemonset).

It introduces a new package - multuscni - where the multus REST client will be located: it currently invokes a single endpoint - /delegate - and is used to trigger adding / removing interfaces from a running pod.

It currently does not have a way to pass runtime config information to the multus server, thus use cases like static IPAM with IP / GW defined in the pod are not possible.

Fixes: #8

@maiqueb maiqueb force-pushed the mount-multus-socket-and-invoke-delegate branch 2 times, most recently from 5d0b9bb to 0e518ba Compare September 30, 2022 15:43
@maiqueb maiqueb marked this pull request as ready for review September 30, 2022 15:43
@maiqueb maiqueb force-pushed the mount-multus-socket-and-invoke-delegate branch 6 times, most recently from a323b42 to 62860a5 Compare October 4, 2022 08:12
@maiqueb maiqueb mentioned this pull request Oct 4, 2022
@maiqueb maiqueb force-pushed the mount-multus-socket-and-invoke-delegate branch from 62860a5 to cc9f5f2 Compare October 4, 2022 08:36
Copy link
Member

@qinqon qinqon left a comment

Choose a reason for hiding this comment

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

Pretty neat in general

pkg/multuscni/client.go Outdated Show resolved Hide resolved
pkg/multuscni/client.go Outdated Show resolved Hide resolved

var _ = Describe("multuscni REST client", func() {
const (
cniVersion = "0.4.0"
Copy link
Member

Choose a reason for hiding this comment

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

This cniVersion has nothing to do with the multus-cni.v3 right ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right. It's the CNI spec version used.

pkg/multuscni/fake/client.go Show resolved Hide resolved
pkg/annotations/dynamic-network-status.go Outdated Show resolved Hide resolved
return string(newIfaceString), nil
}

func DeleteDynamicIfaceFromStatus(currentPod *corev1.Pod, netName string, ifaceName string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Why we don't pass the netName as NetworkSelectionElement like at the Add counterpart then we use

We have the namespacedName(networkSelectionElement.Namespace, networkSelectionElement.Name) function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I mean changet that function to have the same time for netName as "AddDyn..."

pkg/annotations/dynamic-network-status.go Show resolved Hide resolved
return fmt.Errorf("failed to compute the updated network status: %v", err)
}

if err := pnc.updatePodNetworkStatus(pod, newIfaceStatus); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

We should reconstruct and retry on update conflict error so we are sure we take whatever others are updating.

https://pkg.go.dev/k8s.io/client-go/util/retry#RetryOnConflict

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we fail, we re-queue the request on the controller queue, and the whole thing will be re-tried.

@@ -307,12 +318,38 @@ func (pnc *PodNetworksController) removeNetworks(dynamicAttachmentRequest *Dynam
}
klog.Infof("response: %v", *response)

newIfaceStatus, err := annotations.DeleteDynamicIfaceFromStatus(
pod,
namespacedName(netToRemove.Namespace, netToRemove.Name),
Copy link
Member

Choose a reason for hiding this comment

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

Let's just pass netToRemove and do the namespacedName inside it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why ? It doesn't need anything else.

Copy link
Member

Choose a reason for hiding this comment

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

to make "AddDy" and "DeleteDyn" more symmetric is weird that Add use a proper struct while Delete use a string.

@maiqueb maiqueb force-pushed the mount-multus-socket-and-invoke-delegate branch from cc9f5f2 to 5336b90 Compare October 5, 2022 10:57
Add a pkg to contact the multus RESTful API listening to a UNIX socket.

This multus client is not invoked; this will happen in follow-up commits.

Signed-off-by: Miguel Duarte Barroso <[email protected]>
@maiqueb maiqueb force-pushed the mount-multus-socket-and-invoke-delegate branch from 5336b90 to 8c608bf Compare October 5, 2022 11:10
@maiqueb
Copy link
Collaborator Author

maiqueb commented Oct 5, 2022

Squashed some vendoring changes commits in this forced push.

This commit updates the pods network-status annotation whenever an
interface is hot-plugged to the pod (or removed from it ...).

Signed-off-by: Miguel Duarte Barroso <[email protected]>
@maiqueb maiqueb force-pushed the mount-multus-socket-and-invoke-delegate branch from 8c608bf to f8b1577 Compare October 5, 2022 11:33
@maiqueb maiqueb merged commit ac0511b into main Oct 5, 2022
@maiqueb maiqueb deleted the mount-multus-socket-and-invoke-delegate branch October 5, 2022 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CNI interaction
2 participants