-
Notifications
You must be signed in to change notification settings - Fork 261
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
🌱 Migrating /pkg/cloud/services/loadbalancer/loadbalancer.go and /controllers/openstackmachine_controller.go to structured logging #1621
Conversation
✅ Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi @anastaruno. 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 |
@@ -48,7 +48,7 @@ const loadBalancerProvisioningStatusActive = "ACTIVE" | |||
|
|||
func (s *Service) ReconcileLoadBalancer(openStackCluster *infrav1.OpenStackCluster, clusterName string, apiServerPort int) (bool, error) { | |||
loadBalancerName := getLoadBalancerName(clusterName) | |||
s.scope.Logger().Info("Reconciling load balancer", "name", loadBalancerName) | |||
s.scope.Logger().Info("Reconciling load balancer", "loadBalancerName", loadBalancerName) |
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.
Lets hold off on this change until we have agreement in #1617 (comment)
I suspect that we may decide we're going to stick with name
here.
@@ -169,7 +169,7 @@ func (s *Service) getOrCreateLoadBalancer(openStackCluster *infrav1.OpenStackClu | |||
return lb, nil | |||
} | |||
|
|||
s.scope.Logger().Info("Creating load balancer in subnet", "subnetID", subnetID, "loadBalancerName", loadBalancerName) | |||
s.scope.Logger().Info("Creating load balancer in subnet", "id", subnetID, "name", loadBalancerName) |
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 is tricky! I think we have to prefix at least one of id
and name
here, as they refer to different objects. Which one is honestly debatable, but I might argue that the 'subject' of the log message is the load balancer, therefore name
and subnetID
.
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.
Agree! Subnet is a secondary resource here.
@@ -199,7 +199,7 @@ func (s *Service) getOrCreateListener(openStackCluster *infrav1.OpenStackCluster | |||
return listener, nil | |||
} | |||
|
|||
s.scope.Logger().Info("Creating load balancer listener", "listenerName", listenerName, "loadBalancerID", lbID) | |||
s.scope.Logger().Info("Creating load balancer listener", "name", listenerName, "id", lbID) |
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.
2 objects again. I'm thinking name
and loadBalancerID
.
@@ -267,7 +267,7 @@ func (s *Service) getOrUpdateAllowedCIDRS(openStackCluster *infrav1.OpenStackClu | |||
listener.AllowedCIDRs = capostrings.Unique(listener.AllowedCIDRs) | |||
|
|||
if !reflect.DeepEqual(allowedCIDRs, listener.AllowedCIDRs) { | |||
s.scope.Logger().Info("CIDRs do not match, start to update listener", "expected CIDRs", allowedCIDRs, "load balancer existing CIDR", listener.AllowedCIDRs) | |||
s.scope.Logger().Info("CIDRs do not match, start to update listener", "expected CIDRs", allowedCIDRs, "existing CIDR", listener.AllowedCIDRs) |
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 is basically a trace level log message. When we get around to it, I'm pretty sure we'll put this at V(5)
. However...
I'm not 100% sure, but I don't think we want spaces in parameter names. Perhaps expected
and current
?
We also probably want ..., updating listener
.
And lastly: are you able to find out how allowedCIDRs
renders in this log message in practise? I wonder if we should explicitly format it somehow. However, don't spend much time on this given that it's most likely a trace level log.
@@ -316,7 +316,7 @@ func (s *Service) getOrCreatePool(openStackCluster *infrav1.OpenStackCluster, po | |||
return pool, nil | |||
} | |||
|
|||
s.scope.Logger().Info("Creating load balancer pool for listener", "listenerID", listenerID, "poolName", poolName, "loadBalancerID", lbID) | |||
s.scope.Logger().Info("Creating load balancer pool for listener", "id", lbID, "listenerID", listenerID, "name", poolName) |
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 'pool' is the subject here, so loadBalancerID
, listenerID
, name
?
@@ -356,7 +356,7 @@ func (s *Service) getOrCreateMonitor(openStackCluster *infrav1.OpenStackCluster, | |||
return nil | |||
} | |||
|
|||
s.scope.Logger().Info("Creating load balancer monitor for pool", "poolID", poolID, "monitorName", monitorName, "loadBalancerID", lbID) | |||
s.scope.Logger().Info("Creating load balancer monitor for pool", "id", lbID, "name", monitorName, "poolID", poolID) |
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.
Ditto, but for 'monitor' instead of 'pool'.
@@ -400,7 +400,7 @@ func (s *Service) ReconcileLoadBalancerMember(openStackCluster *infrav1.OpenStac | |||
} | |||
|
|||
loadBalancerName := getLoadBalancerName(clusterName) | |||
s.scope.Logger().Info("Reconciling load balancer member", "loadBalancerName", loadBalancerName) | |||
s.scope.Logger().Info("Reconciling load balancer member", "name", loadBalancerName) |
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.
Tricky. The only parameter doesn't refer to the subject of the log message. i.e. We're creating a 'member', but name
refers to the load balancer, not the member. I'd probably use loadBalancerName
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.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: anastaruno, mdbooth 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:
It fixes the format of the log messages and log parameters. Following the guidelines here and here. Part of the process to fix issue #1314.