-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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: output the name of the worker to console when added #5120
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @BobVanB. 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-sigs/prow repository. |
6dc2aa0
to
63d3415
Compare
@@ -57,7 +57,11 @@ func NewNodeSource(ctx context.Context, kubeClient kubernetes.Interface, annotat | |||
nodeInformer.Informer().AddEventHandler( | |||
cache.ResourceEventHandlerFuncs{ | |||
AddFunc: func(obj interface{}) { | |||
log.Debug("node added") | |||
node, ok := obj.(*v1.Node) |
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.
should be something like, pseudo code
if loglevel == debug
do the stuff
source/node.go
Outdated
log.Debug("node added") | ||
node, ok := obj.(*v1.Node) | ||
if !ok { | ||
log.Debug("node added") |
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.
This construct is missing a return statement and should be an log.Error, otherwise we always going to have execution in if !ok
block and next statement log.Debugf("node added: %s", node.ObjectMeta.Name)
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.
Hi @ivankatliarchuk,
The code does not return anything, that is why i don't throw an error.
Otherwise i have to check all the code paths if its handled correctly.
log.Debug("node added")
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 an error case IF it's ever happens
log.Errorf("expected *v1.Node but got %T", obj)
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.
Is it always going to be of type v1.Node
?
If that is true, then i think you are right.
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 should be always v1.Node, if it's not, someone could catch an error and submit a fix
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.
but consider a simple case
- Type Mismatch: The value is a v1.Node (non-pointer) instead of *v1.Node (pointer).
@@ -57,7 +57,11 @@ func NewNodeSource(ctx context.Context, kubeClient kubernetes.Interface, annotat | |||
nodeInformer.Informer().AddEventHandler( | |||
cache.ResourceEventHandlerFuncs{ | |||
AddFunc: func(obj interface{}) { | |||
log.Debug("node added") | |||
node, ok := obj.(*v1.Node) |
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.
Could you add a test. There test helper for logs
external-dns/internal/testutils/log.go
Line 36 in be7f970
func LogsToBuffer(level log.Level, t *testing.T) *bytes.Buffer { |
/ok-to-test |
63d3415
to
3e21b25
Compare
/label tide/merge-method-squash |
Currently a little occupide, i will work on it when i have the time. |
Description
Change the output in the console for debugging purpose.
vs.
The output is rather fun if there are 400+ workers and you only see
node added
.Checklist