-
Notifications
You must be signed in to change notification settings - Fork 398
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
logging: stop using formatted strings for object identifiers #1730
logging: stop using formatted strings for object identifiers #1730
Conversation
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Before:
After:
|
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
65de975
to
04df6b3
Compare
list, err := c.apiExportLister.List(labels.Everything()) | ||
if err != nil { | ||
runtime.HandleError(err) | ||
return | ||
} | ||
|
||
logger := logging.WithReconciler(klog.Background(), controllerName).WithValues("ClusterWorkspacShard", clusterWorkspaceShardKey) | ||
logger := logging.WithObject(logging.WithReconciler(klog.Background(), controllerName), clusterWorkspaceShard.(*tenancyv1alpha1.ClusterWorkspaceShard)) |
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.
(no action required) I'd split this in 2 to make it easier to read
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.
Fairly pervasive at this point - perhaps I can try to make this a builder pattern in a follow-up and fix them all?
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.
SGTM
@@ -243,7 +236,7 @@ func (c *controller) enqueueSecret(obj interface{}) { | |||
return | |||
} | |||
|
|||
logger := logging.WithReconciler(klog.Background(), controllerName).WithValues("Secret", secretKey) | |||
logger := logging.WithObject(logging.WithReconciler(klog.Background(), controllerName), obj.(*corev1.Secret)) |
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.
(no action required) I'd split this in 2 to make it easier to read
ctx = klog.NewContext(ctx, logger) | ||
if _, err := c.getNamespace(clusterName, c.secretNamespace); errors.IsNotFound(err) { | ||
ns := &corev1.Namespace{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: c.secretNamespace, | ||
Name: c.secretNamespace, | ||
Annotations: map[string]string{logicalcluster.AnnotationKey: clusterName.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.
Just making sure: this is only needed for logging.WithObject
to include the cluster 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.
Yes. I'm open to better ideas :|
@@ -130,6 +131,7 @@ func (c *controller) createIdentitySecret(ctx context.Context, clusterName logic | |||
if err != nil { | |||
return err | |||
} | |||
secret.Annotations[logicalcluster.AnnotationKey] = clusterName.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.
Just making sure: this is only needed for logging.WithObject
to include the cluster 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.
Yes. I'm open to better ideas :|
list, err := c.clusterWorkspaceTypeLister.List(labels.Everything()) | ||
if err != nil { | ||
runtime.HandleError(err) | ||
return | ||
} | ||
|
||
logger := logging.WithObject(logging.WithReconciler(klog.Background(), controllerName), clusterWorkspaceShard.(*tenancyv1alpha1.ClusterWorkspaceShard)) |
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.
(no action required) I'd split this in 2 to make it easier to read
/approve @sttts WDYT about #1730 (comment) ? |
Happy to merge & iterate too (on the annotation bit) |
@ncdc sure thing - the obvious choice would be |
/retest |
1d45745
to
7f78634
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ncdc 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 |
/retest |
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
7f78634
to
7439a16
Compare
New changes are detected. LGTM label has been removed. |
logging: format Kind better when none is present
Signed-off-by: Steve Kuznetsov skuznets@redhat.com
logging: stop using formatted strings for object identifiers
Signed-off-by: Steve Kuznetsov skuznets@redhat.com
Part of #1694
/assign @sttts @ncdc