k8snetworkplumbingwg / multus-cni

A CNI meta-plugin for multi-homed pods in Kubernetes
Apache License 2.0
2.36k stars 585 forks source link

Improve k8s event output when the annotation contains an error #1195

Closed dougbtv closed 6 months ago

dougbtv commented 10 months ago

What would you like to be added: Better error output when the annotation contains a (parseable) user error.

Why is this needed: When users make a simple mistake, it can sometimes be hard to diagnose. For example, say you have a */networks: foo,bar,quux, annotation, we should have clear output

Secondarily, is having a trailing comma a bug? I think that should be valid user input. We can totally handle that.

dougbtv commented 10 months ago

Example:

b63593600d9170f3f9e95b74fbe8a950e1690b23b7303277a9e89c8): error adding pod default_samplepod-bridge to CNI network "multus-cni-network": plugin type="multus" name="multus-cni-network" failed (add): Multus: [default/samplepod-bridge/772c8b51-d36f-413d-aa66-efea9b618e35]: error loading k8s delegates k8s args: TryLoadPodDelegates: error in getting k8s network for pod: GetNetworkDelegates: failed getting the delegate: getKubernetesDelegate: cannot find a network-attachment-definition () in namespace (default): resource name may not be empty

It's there with:

 cannot find a network-attachment-definition () in namespace (default): resource name may not be empty

But I'd prefer something that's actionable by the user. Like "you have a mistake in the format of your */networks annotation"

With the annotation:

  annotations:
    k8s.v1.cni.cncf.io/networks: "bridge-conf-1,bridge-conf-2,bridge-conf-3,bridge-conf-4,"
mrbojangles3 commented 10 months ago

The error message is:


[error] getKubernetesDelegate: cannot find a network-attachment-definition () in namespace (default): resource name may not be empty
[error] GetNetworkDelegates: failed getting the delegate: getKubernetesDelegate: cannot find a network-attachment-definition () in namespace (default): resource name may not be empty
[error] TryLoadPodDelegates: error in getting k8s network for pod: GetNetworkDelegates: failed getting the delegate: getKubernetesDelegate: cannot find a network-attachment-definition () in namespace (default): resource name may not be empty```
github-actions[bot] commented 7 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.