-
Notifications
You must be signed in to change notification settings - Fork 300
Migrate error logging to contextual logging #9778
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
base: master
Are you sure you want to change the base?
Migrate error logging to contextual logging #9778
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: anndono The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @anndono. Thanks for your PR. I'm waiting for a github.com 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. DetailsInstructions 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-sigs/prow repository. |
|
please resolve linting errors. |
|
Please don't fix #1575 in this pr because we have other cherry-picks related to 1575. We can close the issue after all completions. |
pkg/provider/azure_zones.go
Outdated
| zones, innerErr = az.zoneRepo.ListZones(ctx) | ||
| if innerErr != nil { | ||
| klog.ErrorS(err, "Failed to list zones") | ||
| logger.Error(err, "Failed to list zones") |
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.
not related to your change, but we should change it to innerErr here instead of err. please check why the unit test doesn't cover this bug if you have time.
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 unit test doesn't cover this because it only verifies the returned error value instead of log messages.
|
/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.
Pull request overview
This PR migrates error logging from klog (plaintext and structured) to contextual logging using logger.Error for improved consistency and observability across the codebase.
Key Changes:
- Replaced
klog.Error,klog.Errorf,klog.ErrorSwithlogger.Error - Replaced
klog.Fatalfwithlogger.Errorfollowed byklog.FlushAndExit(klog.ExitFlushTimeout, 1)for consistent exit behavior - Renamed unused
_context parameters toctxwhere the context is now used for logging - Fixed spelling errors ("paring" → "parsing" in most places)
Reviewed changes
Copilot reviewed 51 out of 52 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/e2e_test.go | Migrated Fatalf to logger.Error + FlushAndExit; added error message to kusto ingest failure |
| pkg/util/controller/testutil/test_utils.go | Migrated all klog.Errorf calls to logger.Error with structured logging; added context parameter |
| pkg/util/controller/node/controller_utils.go | Migrated klog.Errorf to logger.Error in node delete handler |
| pkg/provider/subnet/subnet.go | Migrated subnet operation errors to logger.Error |
| pkg/provider/storage/azure_storageaccount.go | Migrated storage account errors to logger.Error |
| pkg/provider/securitygroup/azure_securitygroup_repo.go | Migrated security group cache creation errors to logger.Error |
| pkg/provider/azure_zones.go | Fixed error variable in zones list logging |
| pkg/provider/azure_vmssflex_cache.go | Migrated VMSS flex cache errors to logger.Error |
| pkg/provider/azure_vmssflex.go | Comprehensive migration of VMSS flex operations to logger.Error |
| pkg/provider/azure_vmss_repo.go | Migrated VMSS repository errors to logger.Error |
| pkg/provider/azure_vmss_cache.go | Migrated VMSS cache errors to logger.Error |
| pkg/provider/azure_vmss.go | Extensive migration of VMSS operations to logger.Error |
| pkg/provider/azure_vmsets_repo.go | Migrated VM sets repository errors to logger.Error |
| pkg/provider/azure_standard.go | Migrated availability set errors to logger.Error |
| pkg/provider/azure_routes.go | Migrated routing errors to logger.Error; changed warning to info |
| pkg/provider/azure_publicip_repo.go | Migrated public IP errors to logger.Error |
| pkg/provider/azure_privatelinkservice.go | Migrated private link service errors to logger.Error |
| pkg/provider/azure_local_services.go | Migrated endpoint slice conversion errors to logger.Error |
| pkg/provider/azure_loadbalancer_*.go | Comprehensive migration of load balancer operations to logger.Error |
| pkg/provider/azure_interface_repo.go | Migrated interface errors to logger.Error |
| pkg/provider/azure_instances_v2.go | Migrated instance operations to logger.Error |
| pkg/provider/azure_instance_metadata.go | Migrated IMDS errors to logger.Error |
| pkg/provider/azure_controller_*.go | Migrated controller errors to logger.Error |
| pkg/provider/azure.go | Migrated cloud provider initialization errors to logger.Error + FlushAndExit |
| pkg/nodemanager/nodemanager.go | Migrated node manager errors to logger.Error |
| pkg/nodeipam/*.go | Migrated IPAM errors to logger.Error; replaced Fatalf with FlushAndExit pattern |
| pkg/node/*.go | Migrated node provider initialization to logger.Error + FlushAndExit |
| pkg/credentialprovider/azure_credentials.go | Migrated ACR credential provider errors to logger.Error |
| cmd/**/*.go | Migrated command initialization and controller startup errors to logger.Error + FlushAndExit |
| health-probe-proxy/main.go | Migrated proxy errors to logger.Error |
| kubetest2-aks/**/*.go | Migrated test deployment errors to klog.ErrorS + FlushAndExit; updated klog import |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1d78445 to
db156ca
Compare
|
@anndono: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions 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-sigs/prow repository. I understand the commands that are listed here. |
|
PR needs rebase. DetailsInstructions 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-sigs/prow repository. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR standardizes error logging by migrating from a mix of plaintext and structured logging to contextual logging, improving consistency, clarity, and observability across the codebase.
Changes:
klog.Error,klog.Errorf,klog.ErrorSwithlogger.Errorklog.V(n).ErrorSwithlogger.V(n).Errorklog.Fatalfwithlogger.Errorfollowed byklog.FlushAndExit(klog.ExitFlushTimeout, 1)klog.Fatalfwithklog.ErrorSfollowed byklog.FlushAndExit(klog.ExitFlushTimeout, 1)_toctxbecause now that the context is actively used for logginglog.Backgroundto use existing logger for consistencyWhich issue(s) this PR fixes:
Fixes #
ref: #1575
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: