Skip to content

Commit a80289c

Browse files
mateofloridogithub-actions[bot]
authored andcommitted
fix: Fix Invalid iproute2 JSON output in arm64 (#1820)
Fix Invalid `iproute2` JSON output in arm64 (cherry picked from commit adbd67e)
1 parent bd0f0ea commit a80289c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/k8s/pkg/utils/netlink.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package utils
22

33
import (
4-
"encoding/json"
54
"fmt"
65
"net"
76
"os/exec"
7+
8+
"gopkg.in/yaml.v2"
89
)
910

1011
type VXLANInterface struct {
@@ -13,12 +14,12 @@ type VXLANInterface struct {
1314
}
1415

1516
var ipLinks []struct {
16-
IfName string `json:"ifname"`
17+
IfName string `json:"ifname" yaml:"ifname"`
1718
LinkInfo struct {
1819
InfoData struct {
19-
Port *int `json:"port"`
20-
} `json:"info_data"`
21-
} `json:"linkinfo"`
20+
Port *int `json:"port" yaml:"port"`
21+
} `json:"info_data" yaml:"info_data"`
22+
} `json:"linkinfo" yaml:"linkinfo"`
2223
}
2324

2425
func ListVXLANInterfaces() ([]VXLANInterface, error) {
@@ -30,7 +31,12 @@ func ListVXLANInterfaces() ([]VXLANInterface, error) {
3031
return vxlanDevices, fmt.Errorf("running ip command failed: %s", string(out))
3132
}
3233

33-
if err := json.Unmarshal(out, &ipLinks); err != nil {
34+
// NOTE: (mateoflorido) Parsing as YAML cleans up invalid JSON output
35+
// produced by the iproute2 command in arm64. Currently, the Ubuntu package
36+
// combines the VXLAN VNI value with the fan-map extension, resulting in
37+
// invalid JSON, but a valid YAML.
38+
// https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2121908
39+
if err := yaml.Unmarshal(out, &ipLinks); err != nil {
3440
return vxlanDevices, fmt.Errorf("unmarshaling ip command output failed: %w", err)
3541
}
3642

0 commit comments

Comments
 (0)