From 854cef8438f72b9e32128d5991653c43990c2a78 Mon Sep 17 00:00:00 2001 From: Ivanov Oleg Date: Thu, 24 May 2018 22:09:51 +0300 Subject: [PATCH 1/6] Fixed coreos osinfo issue #108 --- telemetry/telemetry_linux.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/telemetry/telemetry_linux.go b/telemetry/telemetry_linux.go index 09d2bd840d..6cf0ed5d75 100644 --- a/telemetry/telemetry_linux.go +++ b/telemetry/telemetry_linux.go @@ -88,14 +88,19 @@ func (report *Report) GetSystemDetails() { // This function creates a report with os details(ostype, version). func (report *Report) GetOSDetails() { - linesArr, err := ReadFileByLines("/etc/issue") + linesArr, err := ReadFileByLines("/etc/os-release") if err != nil || len(linesArr) <= 0 { report.OSDetails = &OSInfo{OSType: runtime.GOOS} - report.OSDetails.ErrorMessage = "reading /etc/issue failed with" + err.Error() + report.OSDetails.ErrorMessage = "reading /etc/os-release failed with" + err.Error() return } - osInfoArr := strings.Split(linesArr[0], " ") + osInfoArr := make(map[string]string) + + for i := range linesArr { + s := strings.Split(linesArr[i], "=") + osInfoArr[s[0]] = strings.TrimSuffix(s[1], "\n") + } out, err := exec.Command("uname", "-r").Output() if err != nil { @@ -109,8 +114,8 @@ func (report *Report) GetOSDetails() { report.OSDetails = &OSInfo{ OSType: runtime.GOOS, - OSVersion: osInfoArr[1], + OSVersion: osInfoArr["VERSION"], KernelVersion: kernelVersion, - OSDistribution: osInfoArr[0], + OSDistribution: osInfoArr["ID"], } } From 5bef15341e186b3ce2b9e1e62bf4d09e7d046194 Mon Sep 17 00:00:00 2001 From: Ivanov Oleg Date: Thu, 24 May 2018 23:50:57 +0300 Subject: [PATCH 2/6] Fixed indentation --- telemetry/telemetry_linux.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telemetry/telemetry_linux.go b/telemetry/telemetry_linux.go index 6cf0ed5d75..78323776a4 100644 --- a/telemetry/telemetry_linux.go +++ b/telemetry/telemetry_linux.go @@ -98,9 +98,9 @@ func (report *Report) GetOSDetails() { osInfoArr := make(map[string]string) for i := range linesArr { - s := strings.Split(linesArr[i], "=") - osInfoArr[s[0]] = strings.TrimSuffix(s[1], "\n") - } + s := strings.Split(linesArr[i], "=") + osInfoArr[s[0]] = strings.TrimSuffix(s[1], "\n") + } out, err := exec.Command("uname", "-r").Output() if err != nil { From bf02618f6e2677f79b82440320234724e7a3a24a Mon Sep 17 00:00:00 2001 From: Ivanov Oleg Date: Fri, 25 May 2018 18:22:19 +0300 Subject: [PATCH 3/6] Fix indents again --- telemetry/telemetry_linux.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telemetry/telemetry_linux.go b/telemetry/telemetry_linux.go index 78323776a4..19eae90514 100644 --- a/telemetry/telemetry_linux.go +++ b/telemetry/telemetry_linux.go @@ -98,9 +98,9 @@ func (report *Report) GetOSDetails() { osInfoArr := make(map[string]string) for i := range linesArr { - s := strings.Split(linesArr[i], "=") - osInfoArr[s[0]] = strings.TrimSuffix(s[1], "\n") - } + s := strings.Split(linesArr[i], "=") + osInfoArr[s[0]] = strings.TrimSuffix(s[1], "\n") + } out, err := exec.Command("uname", "-r").Output() if err != nil { From 6c001326ce5c8a3d53a26935fc24d05f4598c913 Mon Sep 17 00:00:00 2001 From: Ivanov Oleg Date: Fri, 25 May 2018 18:37:01 +0300 Subject: [PATCH 4/6] Fixex build issues #148 --- Dockerfile.build | 2 +- cni/cni.go | 2 ++ cni/ipam/ipam.go | 5 +++++ cni/network/network.go | 5 +++++ cni/plugin.go | 2 +- telemetry/telemetry_linux.go | 2 +- 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Dockerfile.build b/Dockerfile.build index 59836ec09f..881cb46a2f 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -1,4 +1,4 @@ -FROM golang:1.8.1 +FROM golang:1.9.4 RUN apt-get update && apt-get install -y zip diff --git a/cni/cni.go b/cni/cni.go index f9ab3bda98..3f87d06a01 100644 --- a/cni/cni.go +++ b/cni/cni.go @@ -11,6 +11,7 @@ const ( // CNI commands. Cmd = "CNI_COMMAND" CmdAdd = "ADD" + CmdAdd = "GET" CmdDel = "DEL" // CNI errors. @@ -26,5 +27,6 @@ var supportedVersions = []string{"0.1.0", "0.2.0", "0.3.0", "0.3.1"} // CNI contract. type PluginApi interface { Add(args *cniSkel.CmdArgs) error + Get(args *cniSkel.CmdArgs) error Delete(args *cniSkel.CmdArgs) error } diff --git a/cni/ipam/ipam.go b/cni/ipam/ipam.go index eac4bc5ffe..8ad2e507f0 100644 --- a/cni/ipam/ipam.go +++ b/cni/ipam/ipam.go @@ -250,6 +250,11 @@ func (plugin *ipamPlugin) Add(args *cniSkel.CmdArgs) error { return nil } +// Get handles CNI get commands. +func (plugin *ipamPlugin) Get(args *cniSkel.CmdArgs) error { + return nil +} + // Delete handles CNI delete commands. func (plugin *ipamPlugin) Delete(args *cniSkel.CmdArgs) error { var err error diff --git a/cni/network/network.go b/cni/network/network.go index 185e2d4def..54943d5075 100644 --- a/cni/network/network.go +++ b/cni/network/network.go @@ -362,6 +362,11 @@ func (plugin *netPlugin) Add(args *cniSkel.CmdArgs) error { return nil } +// Get handles CNI get commands. +func (plugin *netPlugin) Get(args *cniSkel.CmdArgs) error { + return nil +} + // Delete handles CNI delete commands. func (plugin *netPlugin) Delete(args *cniSkel.CmdArgs) error { var err error diff --git a/cni/plugin.go b/cni/plugin.go index af2127c609..dc761492f1 100644 --- a/cni/plugin.go +++ b/cni/plugin.go @@ -109,7 +109,7 @@ func (plugin *Plugin) Execute(api PluginApi) (err error) { pluginInfo := cniVers.PluginSupports(supportedVersions...) // Parse args and call the appropriate cmd handler. - cniErr := cniSkel.PluginMainWithError(api.Add, api.Delete, pluginInfo) + cniErr := cniSkel.PluginMainWithError(api.Add, api.Add, api.Delete, pluginInfo) if cniErr != nil { cniErr.Print() return cniErr diff --git a/telemetry/telemetry_linux.go b/telemetry/telemetry_linux.go index 19eae90514..a89743f240 100644 --- a/telemetry/telemetry_linux.go +++ b/telemetry/telemetry_linux.go @@ -96,7 +96,7 @@ func (report *Report) GetOSDetails() { } osInfoArr := make(map[string]string) - + for i := range linesArr { s := strings.Split(linesArr[i], "=") osInfoArr[s[0]] = strings.TrimSuffix(s[1], "\n") From ca40b8cc50f2cc4cc6e357f1edc312d7c1e03a97 Mon Sep 17 00:00:00 2001 From: IvanovOleg Date: Fri, 25 May 2018 18:47:00 +0300 Subject: [PATCH 5/6] Fixed typo --- cni/plugin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cni/plugin.go b/cni/plugin.go index dc761492f1..a614a0140f 100644 --- a/cni/plugin.go +++ b/cni/plugin.go @@ -109,7 +109,7 @@ func (plugin *Plugin) Execute(api PluginApi) (err error) { pluginInfo := cniVers.PluginSupports(supportedVersions...) // Parse args and call the appropriate cmd handler. - cniErr := cniSkel.PluginMainWithError(api.Add, api.Add, api.Delete, pluginInfo) + cniErr := cniSkel.PluginMainWithError(api.Add, api.Get, api.Delete, pluginInfo) if cniErr != nil { cniErr.Print() return cniErr From aba91b82735f07624ec430647fe34aee44a46761 Mon Sep 17 00:00:00 2001 From: IvanovOleg Date: Fri, 25 May 2018 18:51:57 +0300 Subject: [PATCH 6/6] Fixed another typo --- cni/cni.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cni/cni.go b/cni/cni.go index 3f87d06a01..712bd8dc92 100644 --- a/cni/cni.go +++ b/cni/cni.go @@ -11,7 +11,7 @@ const ( // CNI commands. Cmd = "CNI_COMMAND" CmdAdd = "ADD" - CmdAdd = "GET" + CmdGet = "GET" CmdDel = "DEL" // CNI errors.