-
Notifications
You must be signed in to change notification settings - Fork 253
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
🌱Structured logging migration of instance.go, service.go, floatingip.go, and securitygroups.go #1631
🌱Structured logging migration of instance.go, service.go, floatingip.go, and securitygroups.go #1631
Conversation
✅ Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi @skylerxhu. 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. |
/ok-to-test |
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.
/approve
I think it's good with or without a change of "err" to "error" (maybe), but if you could have a quick look for precedent I'd appreciate it. Thanks!
@@ -95,7 +95,7 @@ func (s *Service) normalizePortTarget(port *infrav1.PortOpts, openStackCluster * | |||
if err != nil { | |||
// Multiple matches might be ok later when we restrict matches to a single network | |||
if errors.Is(err, networking.ErrMultipleMatches) { | |||
s.scope.Logger().V(4).Info("Can't infer network from subnet %d: %s", i, err) | |||
s.scope.Logger().V(4).Info("Couldn't infer network from subnet", "subnet", i, "err", err) |
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.
Do we have any other instances where we're passing an error in a structured log? Do we have a standard name for them already?
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.
Also it doesn't seem like i
is the subnet here. It's the index of the Port
's FixedIPs
, we should rather use fixedIP.Subnet
here.
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 think we should use "err" instead of "error" according to "With the exception of acronyms like "IP" and the standard "err", don't shorten names. " from this structured logging migration guideline(https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md).
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.
There is another instance like this in this file. On line 261: s.scope.Logger().V(4).Error(err, "Failed to clean up ports after failure")
. I'm not sure if we already have a standard name for them.
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.
For the naming issue, I had a discussion with @mdbooth last week. We think subnetIndex
is a proper choice. Sorry for not updating it in this PR. FixedIPs is a weird naming thing from OpenStack which really means subnets.
@@ -95,7 +95,7 @@ func (s *Service) normalizePortTarget(port *infrav1.PortOpts, openStackCluster * | |||
if err != nil { | |||
// Multiple matches might be ok later when we restrict matches to a single network | |||
if errors.Is(err, networking.ErrMultipleMatches) { | |||
s.scope.Logger().V(4).Info("Can't infer network from subnet %d: %s", i, err) | |||
s.scope.Logger().V(4).Info("Couldn't infer network from subnet", "subnet", i, "err", err) |
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.
Also it doesn't seem like i
is the subnet here. It's the index of the Port
's FixedIPs
, we should rather use fixedIP.Subnet
here.
@@ -179,7 +179,7 @@ func (s *Service) DisassociateFloatingIP(eventObject runtime.Object, ip string) | |||
} | |||
|
|||
func (s *Service) waitForFloatingIP(id, target string) error { | |||
s.scope.Logger().Info("Waiting for floating IP", "id", id, "targetStatus", target) | |||
s.scope.Logger().Info("Waiting for floating IP", "ID", id, "status", target) |
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.
status
is vague here, it doesn't say if it's the current or expected status. How about expectedStatus
?
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.
The guideline(https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md) mentioned "Do not provide additional context for how value is used. Don't use podIP, do use IP." And "Context in name is acceptable to distinguish between values that normally go under same key. For example using both status and oldStatus in log that needs to show the change between statuses."
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 still disagree, status
here can be understood both ways.
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 could go in the log message: "Waiting for floating IP status", and then just "status" in the parameters. I think that would be more explicit. We're "Waiting for floating IP", but what are we waiting for it to do? We're waiting for it to reach a target status.
@@ -321,7 +321,7 @@ func (s *Service) createSecurityGroupIfNotExists(openStackCluster *infrav1.OpenS | |||
return err | |||
} | |||
if secGroup == nil || secGroup.ID == "" { | |||
s.scope.Logger().V(6).Info("Group doesn't exist, creating it.", "name", groupName) | |||
s.scope.Logger().V(6).Info("Group doesn't exist, creating it", "name", groupName) |
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.
Somewhat unrelated, but I assume there are no issues with using contractions (doesn't
rather than does not
) in logs?
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.
Yeah, the guideline didn't mention the contraction issue.
One question inline but it's more out of curiosity and not really related to this change. /lgtm |
@stephenfin: changing LGTM is restricted to collaborators In response to this:
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. |
d6d9023
to
a8f157a
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.
/approve
I'll leave @dulek to lgtm when he's happy as discussed in the comments.
/lgtm now that I have the appropriate powers |
373a76c
to
a8f157a
Compare
/lgtm |
Bah, needs a rebase. |
…ce.go, and floatingip.go (rebase)
5b78cc0
to
4e7e0fe
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.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mdbooth, skylerxhu 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 |
What this PR does / why we need it:
Fix up the string formatting log messages so that they use structured logging as documented here: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md