Logging improvement (UID, net-attach-def)

This change adds pod UID and net-attach-def name in verbose log
and sends kubernetes event when net-attach-def is not found.
This commit is contained in:
Tomofumi Hayashi
2020-03-18 17:21:43 +09:00
committed by Tomofumi Hayashi
parent f885b38332
commit 055a7568ad
6 changed files with 51 additions and 19 deletions

View File

@@ -236,6 +236,9 @@ func getKubernetesDelegate(client *ClientInfo, net *types.NetworkSelectionElemen
logging.Debugf("getKubernetesDelegate: %v, %v, %s, %v, %v", client, net, confdir, pod, resourceMap)
customResource, err := client.NetClient.NetworkAttachmentDefinitions(net.Namespace).Get(net.Name, metav1.GetOptions{})
if err != nil {
if client != nil {
client.Eventf(pod, v1.EventTypeWarning, "NoNetworkFound", "cannot find get a network-attachment-definition (%s) in namespace (%s): %v", net.Name, net.Name, err)
}
return nil, resourceMap, logging.Errorf("getKubernetesDelegate: cannot find get a network-attachment-definition (%s) in namespace (%s): %v", net.Name, net.Namespace, err)
}