Implement STATUS#121
Conversation
This commit implements the STATUS CNI verb. It adds a new function StatusDetail which returns a list with the status of each network. Signed-off-by: Michael Zappa <michael.zappa@gmail.com> Signed-off-by: Archit Kulkarni <architkulkarni@google.com> Co-authored-by: Michael Zappa <michael.zappa@gmail.com>
67c32dd to
a45b44a
Compare
| var networks []*NetworkStatus | ||
|
|
||
| for _, network := range c.Networks() { | ||
| if network.config.Name == "cni-loopback" { |
There was a problem hiding this comment.
Why this specific magic name? Can we move it out to a constant with a comment explaining?
There was a problem hiding this comment.
@MikeZappa87 do you know the answer?
Actually, would it make sense to just delete this special case entirely? Even if the status will always just be "ready" for cni-loopback, it might make the code cleaner and more futureproof.
There was a problem hiding this comment.
We are deprecating the cni-loopback and the return will always be the same regardless.
There was a problem hiding this comment.
Done, added a comment and moved it to a constant: be034ef
Signed-off-by: Archit Kulkarni <architkulkarni@google.com>
Co-authored-by: Samuel Karp <me@samuelkarp.com> Signed-off-by: Archit Kulkarni <arkulkar@gmail.com>
90ca69d to
a7839ab
Compare
| } | ||
|
|
||
| type NetworkStatus struct { | ||
| Network *Network |
There was a problem hiding this comment.
Do we need to expose anything else here? Right now all the fields of Network are private.
There was a problem hiding this comment.
Is it enough to make ifName public?
Lines 26 to 30 in a45b44a
There was a problem hiding this comment.
As a consumer of the Status API does making this private or public help? Exposing ifName might be useful especially if we ever begin to support multiple interfaces upstream.
There was a problem hiding this comment.
@MikeZappa87 The first use case that came to mind was just the error message, like if the kubelet sees that one of the entries of StatusDetail has an error, in the log it can report ifName along with the error. But there are probably other possible use cases I'm not aware of.
What about config, should we expose the whole config or just certain fields like Name, CNIVersion?
type NetworkConfigList struct {
Name string
CNIVersion string
DisableCheck bool
DisableGC bool
LoadOnlyInlinedPlugins bool
Plugins []*PluginConfig
Bytes []byte
}Signed-off-by: Archit Kulkarni <architkulkarni@google.com>
Signed-off-by: Archit Kulkarni <architkulkarni@google.com>
03fbaaf to
b110ac0
Compare
|
I don't understand the linter errors that appeared after the last two commits, they seem unrelated. Any ideas? |
Dunno.. the last commit success build here was in june.. you could try an empty commit (1line doc change) and see if our current version of stretcher 1.8.0 , golang, lint all still work .. noting that the core repo has moved up with stretcher 1.9 now the latest |
|
A bit weird because it passed two commits ago on this PR last week: https://github.com/containerd/go-cni/actions/runs/11351584389/job/31572471088 But let me try what you suggested |
ikr.. sure enough though even trivial non code no longer passes |
|
let's see on the working run you linked for the linter 1.21.8 test we have: on the failure here for the same 1.21.8 bucket we have |
| err = l.Remove(ctx, "container-id1", "/proc/12345/ns/net") | ||
| assert.NoError(t, err) | ||
|
|
||
| statuses, err := l.StatusDetail(ctx) |
There was a problem hiding this comment.
The fake configuration that is being generated, is that 1.1.0? Can you verify that I don't think the Status verb is actually being executed.
There was a problem hiding this comment.
@MikeZappa87 Thanks for the comment, just want to make sure I understand everything -- In the approach currently taken by this PR, StatusDetail isn't called anywhere yet (the proposal was to have containerd call it), so you're right that the Status verb isn't executed unless we explicitly call StatusDetail. Since we do call StatusDetail in the test here, I think this line https://github.com/containerd/go-cni/pull/121/files#diff-6cdf85f441267859d068399676e5f0ad8946811bd7e951b4e80db98d9fd2489cR318 asserts that the (mocked) status verb is being executed.
I don't see 1.1.0 specified anywhere in the fake config, but I think that doesn't affect the test because the version check happens inside cni.GetStatusNetworkList, and this function is mocked out. Is that right?
|
Closed in favor of #123 |
we could probably still use detail for each of the plugins vs fail first..? |
|
Sure, reopening |
Based on @MikeZappa87's earlier PR #114.
This commit implements the STATUS CNI verb. It adds a new function StatusDetail to return the result of STATUS for each network.
Related info: