-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix error propagation in (*K8sWatcher).addK8sPodV1 #14864
Fix error propagation in (*K8sWatcher).addK8sPodV1 #14864
Conversation
It is no longer returned anywhere since commit f6300d9 ("node: Update ipcache entries independent of node update source"). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
test-me-please |
retest-net-next known flake #12511 https://jenkins.cilium.io/job/Cilium-PR-K8s-1.13-net-next/681/ |
0b4ebce
to
556a148
Compare
…rror In (*K8sWatcher).addK8sPodV1, the error return value of (*K8sWatcher).updatePodHostData is ignored due to the fact that the bool return value is always true if there was an error. This leads to a debug message being printed rather than a warning. Also the error is not propagated to callers of (*K8sWatcher).addK8sPodV1, which in one case in (*K8sWatcher).createPodController leads to metrics not being updated appropriately. The bool return value of (*K8sWatcher).createPodController is anyway redundant, so remove it. Instead, check the error explicitly at the call site and log and propagate it accordingly. Also move the host network check out of updatePodHostData as it is not considered a warning and can be skipped. This avoids the unnecessary podIPs lookup in that case. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
556a148
to
c666e18
Compare
test-me-please |
retest-4.19 hit known flake #12511 https://jenkins.cilium.io/job/Cilium-PR-Ginkgo-Tests-Kernel/4650/ |
@@ -217,12 +217,15 @@ func (k *K8sWatcher) addK8sPodV1(pod *slim_corev1.Pod) error { | |||
return k.deleteK8sPodV1(pod) | |||
} | |||
|
|||
skipped := false | |||
if pod.Spec.HostNetwork { | |||
logger.Debug("pod is using host networking") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this is a log msg, maybe we can elaborate a bit more on it? I think we should at the least conform to other log msgs so capitalize the first word
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tklauser if you get a chance, pls follow-up if needed once back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@christarazi as far as I can see, the logger
already include necessary additional information as fields:
cilium/pkg/k8s/watchers/pod.go
Lines 202 to 208 in b875c1d
logger := log.WithFields(logrus.Fields{ | |
logfields.K8sPodName: pod.ObjectMeta.Name, | |
logfields.K8sNamespace: pod.ObjectMeta.Namespace, | |
"podIP": pod.Status.PodIP, | |
"podIPs": pod.Status.PodIPs, | |
"hostIP": pod.Status.PodIP, | |
}) |
Or do you have any other info in mind that would be relevant for this case? Otherwise I'd just change the capitalization of the log message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization is what I had in mind. If that's the only change you're going to make, then it's not worth making a PR for it; only if you have other changes already planned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I have some other changes for the same package, so I can fold in the capitalization change.
Follow-up for cilium#14864 (review) Suggested-by: Chris Tarazi <chris@isovalent.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Follow-up for #14864 (review) Suggested-by: Chris Tarazi <chris@isovalent.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Follow-up for cilium#14864 (review) Suggested-by: Chris Tarazi <chris@isovalent.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
The first commit is a preparatory cleanup of an unused sentinel error var.
The second commit fixes the error propagation issue (as per the commit message):
In
(*K8sWatcher).addK8sPodV1
, theerror
return value of(*K8sWatcher).updatePodHostData
is ignored due to the fact that thebool
return value is always
true
if there was an error. This leads toa debug message being printed rather than a warning. Also the
error is not propagated to callers of
(*K8sWatcher).addK8sPodV1
, whichin one case in
(*K8sWatcher).createPodController
leads to metrics notbeing updated appropriately.
The
bool
return value of(*K8sWatcher).createPodController
is anywayredundant, so remove it. Instead, check the error explicitly at the call
site and log and propagate it accordingly.