Skip to content
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

fix: Fix log formatting on startup logs #297

Merged

Conversation

jonathan-innis
Copy link
Member

@jonathan-innis jonathan-innis commented Apr 19, 2023

Fixes aws/karpenter-provider-aws#3560

Description

  • Fix log formatting on startup logs so that all logs are structured using the *zap.SugaredLogger

How was this change tested?

make presubmit

Old Logs

2023-04-19T05:55:38.652Z        DEBUG   Successfully created the logger.
2023-04-19T05:55:38.652Z        DEBUG   Logging level set to: debug
{"level":"info","ts":1681883738.6558979,"logger":"fallback","caller":"injection/injection.go:63","msg":"Starting informers..."}
2023-04-19T05:55:38.756Z        DEBUG   controller      waiting for configmaps  {"commit": "7131be2-dirty"}
2023-04-19T05:55:39.269Z        DEBUG   controller      waiting for configmaps  {"commit": "7131be2-dirty"}
2023-04-19T05:55:39.770Z        DEBUG   controller      waiting for configmaps  {"commit": "7131be2-dirty"}
2023-04-19T05:55:40.270Z        DEBUG   controller      waiting for configmaps  {"commit": "7131be2-dirty"}
2023-04-19T05:55:40.771Z        DEBUG   controller      waiting for configmaps  {"commit": "7131be2-dirty"}
2023-04-19T05:55:41.330Z        DEBUG   controller.aws  discovered region       {"commit": "7131be2-dirty", "region": "us-west-2"}
2023-04-19T05:55:41.330Z        DEBUG   controller.aws  discovered cluster endpoint     {"commit": "7131be2-dirty", "cluster-endpoint": "https://2B3A0347E5BF8D9935288F4311843065.gr7.us-west-2.eks.amazonaws.com"}
2023-04-19T05:55:41.336Z        DEBUG   controller.aws  discovered kube dns     {"commit": "7131be2-dirty", "kube-dns-ip": "10.100.0.10"}
2023-04-19T05:55:41.336Z        DEBUG   controller.aws  discovered version      {"commit": "7131be2-dirty", "version": "v0.27.1"}
2023/04/19 05:55:41 Registering 2 clients
2023/04/19 05:55:41 Registering 2 informer factories
2023/04/19 05:55:41 Registering 3 informers
2023/04/19 05:55:41 Registering 5 controllers
2023-04-19T05:55:41.337Z        INFO    controller      Starting server {"commit": "7131be2-dirty", "path": "/metrics", "kind": "metrics", "addr": "[::]:8080"}
2023-04-19T05:55:41.337Z        INFO    controller      Starting server {"commit": "7131be2-dirty", "kind": "health probe", "addr": "[::]:8081"}
I0419 05:55:41.438781       1 leaderelection.go:248] attempting to acquire leader lease karpenter/karpenter-leader-election...
2023-04-19T05:55:41.469Z        INFO    controller      Starting informers...   {"commit": "7131be2-dirty"}
2023-04-19T05:55:41.669Z        INFO    controller.aws.pricing  updated spot pricing with instance types and offerings  {"commit": "7131be2-dirty", "instance-type-count": 631, "offering-count": 2178}

New Logs

2023-04-19T06:00:00.905Z        DEBUG   Successfully created the logger.
2023-04-19T06:00:00.905Z        DEBUG   Logging level set to: debug
2023-04-19T06:00:06.233Z        DEBUG   controller      discovered region       {"commit": "6bdd213-dirty", "region": "us-west-2"}
2023-04-19T06:00:06.233Z        DEBUG   controller      discovered cluster endpoint     {"commit": "6bdd213-dirty", "cluster-endpoint": "https://2B3A0347E5BF8D9935288F4311843065.gr7.us-west-2.eks.amazonaws.com"}
2023-04-19T06:00:06.246Z        DEBUG   controller      discovered kube dns     {"commit": "6bdd213-dirty", "kube-dns-ip": "10.100.0.10"}
2023-04-19T06:00:06.246Z        DEBUG   controller      discovered version      {"commit": "6bdd213-dirty", "version": "v0.27.1-55-g6bdd2138"}
2023-04-19T06:00:06.246Z        DEBUG   controller      Registering 2 clients   {"commit": "6bdd213-dirty"}
2023-04-19T06:00:06.246Z        DEBUG   controller      Registering 2 informer factories        {"commit": "6bdd213-dirty"}
2023-04-19T06:00:06.246Z        DEBUG   controller      Registering 3 informers {"commit": "6bdd213-dirty"}
2023-04-19T06:00:06.246Z        DEBUG   controller      Registering 5 controllers       {"commit": "6bdd213-dirty"}
2023-04-19T06:00:06.247Z        INFO    controller      Starting server {"commit": "6bdd213-dirty", "path": "/metrics", "kind": "metrics", "addr": "[::]:8080"}
2023-04-19T06:00:06.247Z        INFO    controller      Starting server {"commit": "6bdd213-dirty", "kind": "health probe", "addr": "[::]:8081"}
2023-04-19T06:00:06.348Z        INFO    controller      attempting to acquire leader lease karpenter/karpenter-leader-election...
        {"commit": "6bdd213-dirty"}
2023-04-19T06:00:06.382Z        INFO    controller      Starting informers...   {"commit": "6bdd213-dirty"}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jonathan-innis jonathan-innis requested a review from a team as a code owner April 19, 2023 05:42
@jonathan-innis jonathan-innis enabled auto-merge (squash) April 19, 2023 05:43
@jonathan-innis jonathan-innis force-pushed the fix-log-formatting branch 3 times, most recently from bca7d98 to 35954e4 Compare April 19, 2023 05:58
@coveralls
Copy link

coveralls commented Apr 19, 2023

Pull Request Test Coverage Report for Build 4746404727

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 19 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.08%) to 81.397%

Files with Coverage Reduction New Missed Lines %
pkg/controllers/deprovisioning/controller.go 3 84.39%
pkg/controllers/provisioning/scheduling/preferences.go 7 86.67%
pkg/controllers/deprovisioning/events/events.go 9 85.25%
Totals Coverage Status
Change from base Build 4726719442: 0.08%
Covered Lines: 6760
Relevant Lines: 8305

💛 - Coveralls

Copy link
Contributor

@ellistarn ellistarn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong logging format on startup
3 participants