Skip to content

Commit 6447b7e

Browse files
authored
fix: add logging to K8sErrorHandler when error is nil (#1972)
# Description Add logging to K8sErrorHandler when error is nil closes #1951 ## Related Issue If this pull request is related to any issue, please mention it here. Additionally, make sure that the issue is assigned to you before submitting this pull request. ## Checklist - [ ] I have read the [contributing documentation](https://retina.sh/docs/Contributing/overview). - [ ] I signed and signed-off the commits (`git commit -S -s ...`). See [this documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) on signing commits. - [ ] I have correctly attributed the author(s) of the code. - [ ] I have tested the changes locally. - [ ] I have followed the project's style guidelines. - [ ] I have updated the documentation, if necessary. - [ ] I have added tests, if applicable. ## Screenshots (if applicable) or Testing Completed Please add any relevant screenshots or GIFs to showcase the changes made. ## Additional Notes Add any additional notes or context about the pull request here. --- Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more information on how to contribute to this project. Signed-off-by: Alex Castilio dos Santos <[email protected]>
1 parent e938751 commit 6447b7e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/k8s/watcher_linux.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ func Start(ctx context.Context, k *watchers.K8sWatcher) {
4343
// retinaK8sErrorHandler is a custom error handler for the watcher
4444
// that logs the error and tags the error to easily identify
4545
func k8sWatcherErrorHandler(c context.Context, e error, s string, i ...interface{}) {
46+
if e == nil {
47+
// TODO: handle key/values pairs in a better way
48+
// current example output: time="2009-11-10T23:00:00Z" level=error msg="msg: Some error message -- key/values: [int 1 str world]"
49+
logger.WithContext(c).Errorf("msg: %s -- key/values: %+v", s, i)
50+
return
51+
}
52+
4653
errStr := e.Error()
54+
4755
logError := func(er, r string) {
4856
logger.WithFields(logrus.Fields{
4957
"underlyingError": er,

0 commit comments

Comments
 (0)