containerd / go-cni

A generic CNI library to provide APIs for CNI plugin interactions
Apache License 2.0
146 stars 56 forks source link

Implement CNI STATUS #120

Closed architkulkarni closed 2 weeks ago

architkulkarni commented 1 month ago

Based on the earlier PR https://github.com/containerd/go-cni/pull/114.

This PR implements the STATUS CNI verb.

This is the summary of how Status is called:

  1. Kubelet calls the containerd Status() function via a CRI-API RPC: https://github.com/kubernetes/kubernetes/blob/3718932d9a3ea459217ca11efe1ae9ead6aa92c1/pkg/kubelet/kubelet.go#L2871 and checks if it’s ready. It calls this every 5 seconds .

  2. The containerd Status() function in turn calls the go-cni Status() function: https://github.com/containerd/containerd/blob/6333db77015764f7d45b407094a3bc2cc05c239b/internal/cri/server/status.go#L49

  3. Here is the go-cni Status() function. https://github.com/containerd/go-cni/blob/1c1be5e9ea864c9bc1651909ae13e1e555b4098d/cni.go#L137 Before this PR, it just checks if the required number of networks are "ready" where "ready" means the network config file exists.

In this PR, we update the go-cni Status() function to call STATUS on all of the plugins for each network (after doing the same "ready" check as before, which is now moved to a new function Ready()).

It returns without error only if all of the STATUS calls return without error. This is the main difference between this PR and the previous PR https://github.com/containerd/go-cni/pull/114 (i.e. in this PR we use the "AND" of all the network statuses instead of returning a list of statuses.)

The reason for this is to keep the signature of Status() the same to make the API backwards compatible, so that we don't have to synchronize this change with the containerd v2.0 release.

Related info:

architkulkarni commented 2 weeks ago

Closed in favor of https://github.com/containerd/go-cni/pull/121