-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
🐛 Missing error log for in-cluster config #2051
🐛 Missing error log for in-cluster config #2051
Conversation
|
Welcome @maciej-karas-form3! |
Hi @maciej-karas-form3. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
pkg/client/config/config.go
Outdated
@@ -125,6 +125,8 @@ func loadConfig(context string) (*rest.Config, error) { | |||
if len(kubeconfigPath) == 0 { | |||
if c, err := loadInClusterConfig(); err == nil { | |||
return c, nil | |||
} else { | |||
log.Error(err, "unable to load in-cluster config") |
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.
It's just a try, for example it may return ErrNotInCluster
if it is not running in a cluster, so we'd better not log it as an error.
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.
@FillZpp Your'e right. I don't know the conventions for logging warnings in this codebase. Are we using WARN or just [INFO,ERROR]? I can change it to info if that's the case. Will this work?
log.Info("unable to load in-cluster config: %s", err.String())
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.
I would probably use a defer
that logs this only if loadConfig
returns an error
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.
@alvaroaleman @FillZpp updated the PR accordingly. Now it only logs error when the loadConfig
method returns an error
51ec238
to
23be164
Compare
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!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, maciej-karas-form3 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
23be164
to
ebda1ad
Compare
@alvaroaleman The build failed with some lint errors. I've fixed them but the |
/lgtm |
Signed-off-by: Maciej Karaś [email protected]
closes #2053