-
Notifications
You must be signed in to change notification settings - Fork 240
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
don't dump raw bytes into log output? its hard to read #3249
base: master
Are you sure you want to change the base?
Conversation
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.
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 suggestions.
Comments skipped due to low confidence (1)
cns/logger/cnslogger.go:200
- If JSON marshaling fails, the original request object should be included in the log message for debugging purposes.
requestString = fmt.Sprintf("Failed to json marshal %s, %+v", err, request)
if bytes, err := json.Marshal(request); err != nil { | ||
requestString = string(bytes) | ||
} else { | ||
requestString = fmt.Sprintf("Failed to json marshal %s, %+v", err, request) |
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.
If JSON marshaling fails, the original request object should be included in the log message for debugging purposes.
requestString = fmt.Sprintf("Failed to json marshal %s, %+v", err, request) | |
requestString = fmt.Sprintf("%+v", request) |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
if bytes, err := json.Marshal(response); err != nil { | ||
responseString = string(bytes) | ||
} else { | ||
responseString = fmt.Sprintf("Failed to json marshal %s, %+v", err, responseString) |
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.
If JSON marshaling fails, the original response object should be included in the log message for debugging purposes.
responseString = fmt.Sprintf("Failed to json marshal %s, %+v", err, responseString) | |
responseString = fmt.Sprintf("Failed to json marshal %s, %+v", err, response) |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
if bytes, err := json.Marshal(response); err != nil { | ||
responseString = string(bytes) | ||
} else { | ||
responseString = fmt.Sprintf("Failed to json marshal %s, %+v", err, responseString) |
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.
If JSON marshaling fails, the original response object should be included in the log message for debugging purposes.
responseString = fmt.Sprintf("Failed to json marshal %s, %+v", err, responseString) | |
responseString = fmt.Sprintf("Failed to json marshal %s, %+v", err, response) |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
This pull request is stale because it has been open for 2 weeks with no activity. Remove stale label or comment or this will be closed in 7 days |
Pull request closed due to inactivity. |
This pull request is stale because it has been open for 2 weeks with no activity. Remove stale label or comment or this will be closed in 7 days |
Pull request closed due to inactivity. |
Reason for Change:
Request response logging in cns uses +v on structs with raw bytes which produces very hard to read nonsesne. Those bytes are really json.RawMessage which supports serializing to json so do that instead. Here's an example.
024/12/04 19:57:22 [1] [azure-cnsrequestIPConfigsHandler] Code:FailedToAllocateIpConfig, {DesiredIPAddre
sses:[] PodInterfaceID:c34a4c61-eth0 InfraContainerID:c34a4c61b6b2173f7cb62945a3e9f00ea33b99e4aa6b283e714
b095b7875a87b OrchestratorContext:[123 34 80 111 100 78 97 109 101 34 58 34 122 116 117 110 110 101 108 4
5 57 122 54 55 100 34 44 34 80 111 100 78 97 109 101 115 112 97 99 101 34 58 34 105 115 116 105 111 45 11
5 121 115 116 101 109 34 125] Ifname: SecondaryInterfacesExist:false}, &{PodIPInfo:[{PodIPConfig:{IPAddre
ss: PrefixLength:0} NetworkContainerPrimaryIPConfig:{IPSubnet:{IPAddress: PrefixLength:0} DNSServers:[] G
atewayIPAddress:} HostPrimaryIPInfo:{Gateway: PrimaryIP: Subnet:} NICType: InterfaceName: MacAddress: Ski
pDefaultRoutes:false Routes:[]}] Response:{ReturnCode:FailedToAllocateIpConfig Message:AllocateIPConfig f
ailed: not enough IPs available for 6d10e7dd-184d-4595-b598-baeba084761f, waiting on Azure CNS to allocat
e more with NC Status: , IP config request is {[] c34a4c61-eth0 c34a4c61b6b2173f7cb62945a3e9f00ea33b99e4a
a6b283e714b095b7875a87b [123 34 80 111 100 78 97 109 101 34 58 34 122 116 117 110 110 101 108 45 57 122 5
4 55 100 34 44 34 80 111 100 78 97 109 101 115 112 97 99 101 34 58 34 105 115 116 105 111 45 115 121 115
116 101 109 34 125] false}}}.
Issue Fixed:
Requirements:
Notes: