-
Notifications
You must be signed in to change notification settings - Fork 68
Implement STATUS #121
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
base: main
Are you sure you want to change the base?
Implement STATUS #121
Changes from 1 commit
a45b44a
7afa42f
a7839ab
1d06125
b110ac0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,8 @@ type CNI interface { | |
| Status() error | ||
| // GetConfig returns a copy of the CNI plugin configurations as parsed by CNI | ||
| GetConfig() *ConfigResult | ||
| // Status executes the status verb of the cni plugin | ||
| StatusDetail(context.Context) ([]*NetworkStatus, error) | ||
| } | ||
|
|
||
| type ConfigResult struct { | ||
|
|
@@ -310,3 +312,27 @@ func (c *libcni) GetConfig() *ConfigResult { | |
| func (c *libcni) reset() { | ||
| c.networks = nil | ||
| } | ||
|
|
||
| // StatusDetail returns a slice of network statuses | ||
| func (c *libcni) StatusDetail(ctx context.Context) ([]*NetworkStatus, error) { | ||
| err := c.Status() | ||
|
|
||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
architkulkarni marked this conversation as resolved.
Outdated
|
||
|
|
||
| var networks []*NetworkStatus | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: rename to networkStatus ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, renamed to networkStatuses because it's a list: 03fbaaf |
||
|
|
||
| for _, network := range c.Networks() { | ||
| if network.config.Name == "cni-loopback" { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this specific magic name? Can we move it out to a constant with a comment explaining?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are deprecating the cni-loopback and the return will always be the same regardless.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, added a comment and moved it to a constant: be034ef |
||
| continue | ||
| } | ||
|
|
||
| networks = append(networks, &NetworkStatus{ | ||
| Network: network, | ||
| Status: network.Status(ctx), | ||
| }) | ||
| } | ||
|
|
||
| return networks, nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -60,3 +60,8 @@ type DNS struct { | |||||||||||
| // List of DNS options. | ||||||||||||
| Options []string | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| type NetworkStatus struct { | ||||||||||||
| Network *Network | ||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to expose anything else here? Right now all the fields of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it enough to make Lines 26 to 30 in a45b44a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @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 What about type NetworkConfigList struct {
Name string
CNIVersion string
DisableCheck bool
DisableGC bool
LoadOnlyInlinedPlugins bool
Plugins []*PluginConfig
Bytes []byte
} |
||||||||||||
| Status error | ||||||||||||
| } | ||||||||||||
Uh oh!
There was an error while loading. Please reload this page.