cluster-api-provider-aws
cluster-api-provider-aws copied to clipboard
Unify the logger interface in CAPA
What type of PR is this?
/kind feature
What this PR does / why we need it:
Create a unified Logger interface which developers can use to log debug and trace information. It's just a soft wrapper around logr.Logger.
Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes https://github.com/kubernetes-sigs/cluster-api-provider-aws/issues/3152
Special notes for your reviewer:
Checklist:
- [x] squashed commits
- [ ] includes documentation
- [ ] adds unit tests
- [ ] adds or updates e2e tests
@richardcase When you review this, please take note of the Debug vs Trace messages. I wasn't sure which belonged to what category at times. :D so please take a look at them and see if they are at the correct level. :) Thanks! 👍
Some output with this logging interface:
Tags:map[]} {ID:subnet-01f36f8d65e926fd6 CidrBlock:10.0.64.0/18 IPv6CidrBlock: AvailabilityZone:eu-central-1a IsPublic:false IsIPv6:false RouteTableID:<nil> NatGatewayID:<nil> Tags:map[]} {ID:subnet-0711ca7fb292bc564 CidrBlock:10.0.16.0/20 IPv6CidrBlock: AvailabilityZone:eu-central-1b IsPublic:true IsIPv6:false RouteTableID:<nil> NatGatewayID:<nil> Tags:map[]} {ID:subnet-090dc1ec75941ec5b CidrBlock:10.0.128.0/18 IPv6CidrBlock: AvailabilityZone:eu-central-1b IsPublic:false IsIPv6:false RouteTableID:<nil> NatGatewayID:<nil> Tags:map[]} {ID:subnet-06560f282e7a2c07b CidrBlock:10.0.32.0/20 IPv6CidrBlock: AvailabilityZone:eu-central-1c IsPublic:true IsIPv6:false RouteTableID:<nil> NatGatewayID:<nil> Tags:map[]} {ID:subnet-0b65deb3c514aa670 CidrBlock:10.0.192.0/18 IPv6CidrBlock: AvailabilityZone:eu-central-1c IsPublic:false IsIPv6:false RouteTableID:<nil> NatGatewayID:<nil> Tags:map[]}]
I1016 07:58:15.420742 12 logger.go:56] "Reconciling internet gateways"
I1016 07:58:15.636314 12 logger.go:52] "Created Internet gateway for VPC" internet-gateway-id="igw-049f01e0f647b8455" vpc-id="vpc-0fcc6fc7ce974c4a0"
I1016 07:58:15.636453 12 recorder.go:103] "events: Normal" object={Kind:AWSManagedControlPlane Namespace:default Name:managed-cluster-control-plane UID:c6bc345c-a26b-4d5d-8dc4-fb4f5568e515 APIVersion:controlplane.cluster.x-k8s.io/v1beta2 ResourceVersion:1322 FieldPath:} reason="SuccessfulCreateInternetGateway" message="Created new managed Internet Gateway \"igw-049f01e0f647b8455\""
I1016 07:58:15.636796 12 recorder.go:103] "events: Normal" object={Kind:AWSManagedControlPlane Namespace:default Name:managed-cluster-control-plane UID:c6bc345c-a26b-4d5d-8dc4-fb4f5568e515 APIVersion:controlplane.cluster.x-k8s.io/v1beta2 ResourceVersion:1322 FieldPath:} reason="SuccessfulCreateInternetGateway" message="Created new managed Internet Gateway \"igw-049f01e0f647b8455\""
I1016 07:58:15.790775 12 logger.go:56] "attached internet gateway to VPC" internet-gateway-id="igw-049f01e0f647b8455" vpc-id="vpc-0fcc6fc7ce974c4a0"
I1016 07:58:15.790840 12 logger.go:56] "Reconciling NAT gateways"
I1016 07:58:15.791063 12 recorder.go:103] "events: Normal" object={Kind:AWSManagedControlPlane Namespace:default Name:managed-cluster-control-plane UID:c6bc345c-a26b-4d5d-8dc4-fb4f5568e515 APIVersion:controlplane.cluster.x-k8s.io/v1beta2 ResourceVersion:1322 FieldPath:} reason="SuccessfulAttachInternetGateway" message="Internet Gateway \"igw-049f01e0f647b8455\" attached to VPC \"vpc-0fcc6fc7ce974c4a0\""
I1016 07:58:15.791110 12 recorder.go:103] "events: Normal" object={Kind:AWSManagedControlPlane Namespace:default Name:managed-cluster-control-plane UID:c6bc345c-a26b-4d5d-8dc4-fb4f5568e515 APIVersion:controlplane.cluster.x-k8s.io/v1beta2 ResourceVersion:1322 FieldPath:} reason="SuccessfulAttachInternetGateway" message="Internet Gateway \"igw-049f01e0f647b8455\" attached to VPC \"vpc-0fcc6fc7ce974c4a0\""
I1016 07:58:15.915308 12 http.go:96] "controller-runtime/webhook/webhooks: received request" webhook="/mutate-controlplane-cluster-x-k8s-io-v1beta2-awsmanagedcontrolplane" UID=fd327d65-2309-4a55-b453-017184219a56 kind="controlplane.cluster.x-k8s.io/v1beta2, Kind=AWSManagedControlPlane" resource={Group:controlplane.cluster.x-k8s.io Version:v1beta2 Resource:awsmanagedcontrolplanes}
I1016 07:58:15.915686 12 logr.go:261] "awsmanagedcontrolplane-resource: AWSManagedControlPlane setting defaults" control-plane="default/managed-cluster-control-plane"
I1016 07:58:15.916635 12 http.go:143] "controller-runtime/webhook/webhooks: wrote response" webhook="/mutate-controlplane-cluster-x-k8s-io-v1beta2-awsmanagedcontrolplane" code=200 reason= UID=fd327d65-2309-4a55-b453-017184219a56 allowed=true
I1016 07:58:15.922013 12 http.go:96] "controller-runtime/webhook/webhooks: received request" webhook="/validate-controlplane-cluster-x-k8s-io-v1beta2-awsmanagedcontrolplane" UID=0459f7e1-83ef-44fe-9f82-979afb5947fb kind="controlplane.cluster.x-k8s.io/v1beta2, Kind=AWSManagedControlPlane" resource={Group:controlplane.cluster.x-k8s.io Version:v1beta2 Resource:awsmanagedcontrolplanes}
I1016 07:58:15.922540 12 logr.go:261] "awsmanagedcontrolplane-resource: AWSManagedControlPlane validate update" control-plane="default/managed-cluster-control-plane"
I1016 07:58:15.922703 12 http.go:143] "controller-runtime/webhook/webhooks: wrote response" webhook="/validate-controlplane-cluster-x-k8s-io-v1beta2-awsmanagedcontrolplane" code=200 reason= UID=0459f7e1-83ef-44fe-9f82-979afb5947fb allowed=true
I1016 07:58:17.366588 12 recorder.go:103] "events: Normal" object={Kind:AWSManagedControlPlane Namespace:default Name:managed-cluster-control-plane UID:c6bc345c-a26b-4d5d-8dc4-fb4f5568e515 APIVersion:controlplane.cluster.x-k8s.io/v1beta2 ResourceVersion:1322 FieldPath:} reason="SuccessfulCreateNATGateway" message="Created new NAT Gateway \"nat-0ccac7e239d4d3b01\""
I1016 07:58:17.366589 12 recorder.go:103] "events: Normal" object={Kind:AWSManagedControlPlane Namespace:default Name:managed-cluster-control-plane UID:c6bc345c-a26b-4d5d-8dc4-fb4f5568e515 APIVersion:controlplane.cluster.x-k8s.io/v1beta2 ResourceVersion:1322 FieldPath:} reason="SuccessfulCreateNATGateway" message="Created new NAT Gateway \"nat-0ccac7e239d4d3b01\""
I1016 07:58:17.470873 12 recorder.go:103] "events: Normal" object={Kind:AWSManagedControlPlane Namespace:default Name:managed-cluster-control-plane UID:c6bc345c-a26b-4d5d-8dc4-fb4f5568e515 APIVersion:controlplane.cluster.x-k8s.io/v1beta2 ResourceVersion:1322 FieldPath:} reason="SuccessfulCreateNATGateway" message="Created new NAT Gateway \"nat-0711abc19de6ef624\""
I1016 07:58:17.470893 12 recorder.go:103] "events: Normal" object={Kind:AWSManagedControlPlane Namespace:default Name:managed-cluster-control-plane UID:c6bc345c-a26b-4d5d-8dc4-fb4f5568e515 APIVersion:controlplane.cluster.x-k8s.io/v1beta2 ResourceVersion:1322 FieldPath:} reason="SuccessfulCreateNATGateway" message="Created new NAT Gateway \"nat-0711abc19de6ef624\""
I1016 07:58:17.550041 12 recorder.go:103] "events: Normal" object={Kind:AWSManagedControlPlane Namespace:default Name:managed-cluster-control-plane UID:c6bc345c-a26b-4d5d-8dc4-fb4f5568e515 APIVersion:controlplane.cluster.x-k8s.io/v1beta2 ResourceVersion:1322 FieldPath:} reason="SuccessfulCreateNATGateway" message="Created new NAT Gateway \"nat-0dab5ddae2b8a8e57\""
I1016 07:58:17.550132 12 recorder.go:103] "events: Normal" object={Kind:AWSManagedControlPlane Namespace:default Name:managed-cluster-control-plane UID:c6bc345c-a26b-4d5d-8dc4-fb4f5568e515 APIVersion:controlplane.cluster.x-k8s.io/v1beta2 ResourceVersion:1322 FieldPath:} reason="SuccessfulCreateNATGateway" message="Created new NAT Gateway \"nat-0dab5ddae2b8a8e57\""
Damn.......:D
@richardcase @Ankitasw 👋 If you have time, can I get a review on this, please? :D it touches a lot of files and had some major git conflicts.
@Skarlso I am on PTO today, will take a look sometime this week.
@Ankitasw Thank you! That's perfectly fine. :)
@Skarlso Did you run e2e tests to see if the logs look fine? I think log level in E2E is set to 4 by default if I am not wrong.
The overall changes looks much cleaner to me, so once i see the logs, it LGTM.
/test pull-cluster-api-provider-aws-e2e-blocking
@Skarlso Did you run e2e tests to see if the logs look fine? I think log level in E2E is set to 4 by default if I am not wrong.
Hello 👋 :) I pasted in the logs from a normal cluster create above. However, I agree it's a very good call to run the e2e tests! :)
Also, it is kind of a small sample too.
I adjusted the levels here and there as I was talking to Richard. It seemed like they were actually misnumbered.
The e2e logs have much refiner trace logs which is good for debugging. Hence, /lgtm /approve
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: Ankitasw
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [Ankitasw]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Thank you, Ankita! :)