adamantal commented on a change in pull request #125: [YUNIKORN-79] Internal 
metrics are unavailable through REST API
URL: 
https://github.com/apache/incubator-yunikorn-core/pull/125#discussion_r404605856
 
 

 ##########
 File path: pkg/webservice/handlers.go
 ##########
 @@ -245,7 +245,7 @@ func GetApplicationHistory(w http.ResponseWriter, r 
*http.Request) {
                records := imHistory.GetRecords()
                for _, record := range records {
                        if record == nil {
-                               break
+                               continue
 
 Review comment:
   No, actually not.
   
   Let's say we have `[<2,3>, <3,4>, nil, nil]` with `pointer=2` in its 
internal data structure. In the `GetRecords` function first the class copies 
its array between indexes pointer and the end (`[nil, nil]`), then appends the 
rest which is the array between 0 to the pointer index (`[<2,3>, <3,4>]`). This 
results in the following array: `[nil, nil, <2,3>, <3,4>]`. When in the 
`handler.go#GetApplicationHistory` 's for loop we detect the first nil item in 
the array (which is the item #0), we break the for loop immediately which is 
not desired, since we have non-nil entries after that, that we haven't 
serialized yet.
   
   My original suggestion was to filter the nils in `InternalMetricsCollector` 
level, because it's more straightforward what to do there. The simplest 
solution here though to just do this simple fix.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to