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
✨ Improve startup logs #1687
✨ Improve startup logs #1687
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,7 +175,7 @@ func (c *Controller) Start(ctx context.Context) error { | |
// caches to sync so that they have a chance to register their intendeded | ||
// caches. | ||
for _, watch := range c.startWatches { | ||
c.Log.Info("Starting EventSource", "source", watch.src) | ||
c.Log.Info("Starting EventSource", "source", fmt.Sprintf("%s", watch.src)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Otherwise the String() func is not called and instead the watch.src is logged, which is again mostly an empty api struct (link). Which looks roughly like that: I1007 16:29:17.183304 1 controller.go:178] controller/machinehealthcheck "msg"="Starting EventSource" "reconciler group"="cluster.x-k8s.io" "reconciler kind"="MachineHealthCheck" "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{"clusterName":"","selector":{},"unhealthyConditions":null},"status":{"expectedMachines":0,"currentHealthy":0,"remediationsAllowed":0}}} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, I would have expected the logger to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was my first thought. But as |
||
|
||
if err := watch.src.Start(ctx, watch.handler, c.Queue, watch.predicates...); err != nil { | ||
return err | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,10 +142,10 @@ func (ks *Kind) Start(ctx context.Context, handler handler.EventHandler, queue w | |
} | ||
|
||
func (ks *Kind) String() string { | ||
if ks.Type != nil && ks.Type.GetObjectKind() != nil { | ||
return fmt.Sprintf("kind source: %v", ks.Type.GetObjectKind().GroupVersionKind().String()) | ||
if ks.Type != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming that So if we don't want to look up the gvk via the struct, the best we can do is simply log the Go type. |
||
return fmt.Sprintf("kind source: %T", ks.Type) | ||
} | ||
return "kind source: unknown GVK" | ||
return "kind source: unknown type" | ||
} | ||
|
||
// WaitForSync implements SyncingSource to allow controllers to wait with starting | ||
|
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.
apiType is usually just an empty API type (e.g. https://github.com/kubernetes-sigs/cluster-api/blob/f4380fc82fa2eef5119967d9bfea9d428e103e76/api/v1beta1/cluster_webhook.go#L34-L38)
So it's better to log gvk
We're also doing it already for the other webhooks, e.g. l.125