-
Notifications
You must be signed in to change notification settings - Fork 260
Fix log which let log to show more readable info. #803
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #803 +/- ##
==========================================
- Coverage 42.05% 41.91% -0.15%
==========================================
Files 144 152 +8
Lines 14051 14401 +350
==========================================
+ Hits 5909 6036 +127
- Misses 7427 7633 +206
- Partials 715 732 +17 |
neaggarwMS
left a comment
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.
🕐
releaseIPConfig already have it's log. Added log in setIPConfigAsAvailable |
Added. |
Moved. |
Added. |
pjohnst5
left a comment
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.
LGTM
cns/restserver/ipam.go
Outdated
| logger.Request(service.Name, &ipconfigRequest, err) | ||
| operationName := "requestIPConfigHandler" | ||
| desiredIPAddress := ipconfigRequest.DesiredIPAddress | ||
| orchestratorContest := string(ipconfigRequest.OrchestratorContext) |
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 test for why string can works
https://play.golang.org/p/rMJJrhnhCNP
From this test, we can see, if we don't use string but use unmarshall to change it to readable, the type of unmarshalled object is KubernetesPodInfo type instead of string. Then we can't add both string and KubernetesPodInfo into logger request.
import (
"encoding/json"
"fmt"
)
type IPConfigRequest struct {
DesiredIPAddress string
OrchestratorContext json.RawMessage
}
type KubernetesPodInfo struct {
PodName string
PodNamespace string
}
func main() {
testPod1Info := KubernetesPodInfo{
PodName: "testpod1",
PodNamespace: "testpod1namespace",
}
req := IPConfigRequest{}
b, _ := json.Marshal(testPod1Info)
req.OrchestratorContext = b
req.DesiredIPAddress = "1.1.1.1"
// string translate can work.
fmt.Println(req.DesiredIPAddress + string(b))
fmt.Println(b)
var podInfo KubernetesPodInfo
err := json.Unmarshal(b, &podInfo)
if err != nil {
panic(err)
}
fmt.Printf("%v\n", podInfo)
fmt.Printf("%+v\n", podInfo)
fmt.Printf("%v\n", b)
}
f694a1b to
add15bd
Compare
We are printing double logs that could lead to noise. Can you update logger.Response method to accept Request and Response interface and print it at one place In reply to: 786283821 [](ancestors = 786283821) Refers to: cns/restserver/ipam.go:53 in add15bd. [](commit_id = add15bd, deletion_comment = False) |
Also expose a string function to IPConfigResponse like we have exposed it for IpConfigRequest In reply to: 794273976 [](ancestors = 794273976,786283821) Refers to: cns/restserver/ipam.go:53 in add15bd. [](commit_id = add15bd, deletion_comment = False) |
cns/restserver/ipam.go
Outdated
| } | ||
|
|
||
| service.PodIPIDByOrchestratorContext[podInfo.GetOrchestratorContextKey()] = ipconfig.ID | ||
| logger.Printf("Set PodIPIDByOrchestratorContext item %s with ID %s and IP is %s", podInfo.GetOrchestratorContextKey(), ipconfig.ID, ipconfig.IPAddress) |
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.
Can you prefix it with [setIPConfigAsAllocated]
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 updateIPConfigState already logs, do we need to duplicate it here?
In reply to: 590618862 [](ancestors = 590618862)
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.
It's not a duplication if we want to ensure line 319 got executed.
neaggarwMS
left a comment
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.
🕐
cns/restserver/ipam.go
Outdated
| err = service.Listener.Decode(w, r, &ipconfigRequest) | ||
| logger.Request(service.Name, &ipconfigRequest, err) | ||
| operationName := "requestIPConfigHandler" | ||
| logger.Request(service.Name+operationName, ipconfigRequest.String(), err) |
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.
You dont have to add String()
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.
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.
Tested, no need to call .String specifically. Let me remove it.
| msg = fmt.Sprintf("[%s] Code:%s, %+v, %+v.", tag, returnStr, request, response) | ||
| } | ||
|
|
||
| sendTraceInternal(msg) |
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.
Why do we need this? Log.logger.ResponseEx will print to AI too, right?
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.
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.
After offline sync up, we'll keep it as it is for now. I'll make a separate PR to remove duplicate AI telemetry log populating issue.
cns/restserver/ipam.go
Outdated
|
|
||
| err = service.Listener.Encode(w, &resp) | ||
| logger.Response(service.Name, resp, resp.ReturnCode, ReturnCodeToString(resp.ReturnCode), err) | ||
| logger.ResponseEx(service.Name, req.String(), resp, resp.ReturnCode, ReturnCodeToString(resp.ReturnCode), err) |
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.
Again API accepts interface, you dont need to pass String()
Address feedback.
neaggarwMS
left a comment
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.
![]()


fix: repair 3 logs.
Reason for Change:
3 not-readable logs as following
Issue Fixed:
Non-readable log.
Requirements: