container: fix deserialize HNS response in GetHNSEndpointStats (#2379) (#2380)

Co-authored-by: Stefan L. <116070569+slab-msft@users.noreply.github.com>
This commit is contained in:
Jan-Otto Kröpke
2026-04-01 16:39:59 +02:00
committed by GitHub
parent 23397701ff
commit 20762588b3

View File

@@ -75,13 +75,21 @@ func GetHNSEndpointStats(endpointID string) (EndpointStats, error) {
return EndpointStats{}, err return EndpointStats{}, err
} }
var stats EndpointStats var response struct {
Success bool `json:"Success"`
Error string `json:"Error"`
Output EndpointStats `json:"Output"`
}
if err := json.Unmarshal([]byte(result), &stats); err != nil { if err := json.Unmarshal([]byte(result), &response); err != nil {
return EndpointStats{}, fmt.Errorf("failed to unmarshal JSON %s: %w", result, err) return EndpointStats{}, fmt.Errorf("failed to unmarshal JSON %s: %w", result, err)
} }
return stats, nil if !response.Success {
return EndpointStats{}, fmt.Errorf("HNSCall failed: %s", response.Error)
}
return response.Output, nil
} }
func hnsCall(method, path, body *uint16) (string, error) { func hnsCall(method, path, body *uint16) (string, error) {