From e044c9ca5545c065c741aeb3e0f34ff5a9a1bf90 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Thu, 28 Mar 2019 12:04:58 -0400 Subject: [PATCH] Update github.com/elastic/go-sysinfo (#11494) Fixes #11490 Fixes #9134 --- CHANGELOG.next.asciidoc | 1 + NOTICE.txt | 2 +- .../go-sysinfo/providers/linux/container.go | 5 +++ .../go-sysinfo/providers/linux/machineid.go | 32 +++++++++++++++++-- .../elastic/go-sysinfo/providers/linux/os.go | 5 +-- vendor/vendor.json | 30 ++++++++--------- 6 files changed, 54 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 24d9c6324d2..6be3fb0cfa4 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -153,6 +153,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Remove IP fields from default_field in Elasticsearch template. - Fix a typo in libbeat/outputs/transport/client.go by updating `c.conn.LocalAddr()` to `c.conn.RemoteAddr()`. {pull}11242[11242] - Management configuration backup file will now have a timestamps in their name. {pull}11034[11034] +- Fixed OS family classification in `add_host_metadata` for Amazon Linux, Raspbian, and RedHat Linux. {issue}9134[9134] {pull}11494[11494] *Auditbeat* diff --git a/NOTICE.txt b/NOTICE.txt index e61cbe1a20b..362e7671bd7 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -713,7 +713,7 @@ Apache License 2.0 -------------------------------------------------------------------- Dependency: github.com/elastic/go-sysinfo -Revision: 59ef8c0eae46c0929e3b219ac86368d4b5934f91 +Revision: ab4f04edfc3d6b3864f5f06a068ddab9ad79774f License type (autodetected): Apache-2.0 ./vendor/github.com/elastic/go-sysinfo/LICENSE.txt: -------------------------------------------------------------------- diff --git a/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go b/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go index 45a8e9b6f36..cfacf013d12 100644 --- a/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go +++ b/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go @@ -21,6 +21,7 @@ import ( "bufio" "bytes" "io/ioutil" + "os" "github.com/pkg/errors" ) @@ -31,6 +32,10 @@ const procOneCgroup = "/proc/1/cgroup" func IsContainerized() (bool, error) { data, err := ioutil.ReadFile(procOneCgroup) if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, errors.Wrap(err, "failed to read process cgroups") } diff --git a/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go b/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go index b5ff0538564..a84d085c9ea 100644 --- a/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go +++ b/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go @@ -27,11 +27,37 @@ import ( "github.com/elastic/go-sysinfo/types" ) +var ( + // Possible (current and historic) locations of the machine-id file. + // These will be searched in order. + machineIDFiles = []string{"/etc/machine-id", "/var/lib/dbus/machine-id", "/var/db/dbus/machine-id"} +) + func MachineID() (string, error) { - id, err := ioutil.ReadFile("/etc/machine-id") + var contents []byte + var err error + + for _, file := range machineIDFiles { + contents, err = ioutil.ReadFile(file) + if err != nil { + if os.IsNotExist(err) { + // Try next location + continue + } + + // Return with error on any other error + return "", errors.Wrapf(err, "failed to read %v", file) + } + + // Found it + break + } + if os.IsNotExist(err) { + // None of the locations existed return "", types.ErrNotImplemented } - id = bytes.TrimSpace(id) - return string(id), errors.Wrap(err, "failed to read machine-id") + + contents = bytes.TrimSpace(contents) + return string(contents), nil } diff --git a/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go b/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go index a54c1d3258a..d4daedd506f 100644 --- a/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go +++ b/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go @@ -47,9 +47,10 @@ var ( versionRegexp = regexp.MustCompile(versionGrok) ) +// familyMap contains a mapping of family -> []platforms. var familyMap = map[string][]string{ - "redhat": {"redhat", "fedora", "centos", "scientific", "oraclelinux", "amazon"}, - "debian": {"debian", "ubuntu"}, + "redhat": {"redhat", "fedora", "centos", "scientific", "oraclelinux", "amzn", "rhel"}, + "debian": {"debian", "ubuntu", "raspbian"}, "suse": {"suse", "sles", "opensuse"}, } diff --git a/vendor/vendor.json b/vendor/vendor.json index a259d36cee5..8099dea0aa4 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1026,44 +1026,44 @@ { "checksumSHA1": "QhFIpuHPaV6hKejKcc2wm6y4MSQ=", "path": "github.com/elastic/go-sysinfo", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "GiZCjX17K265TtamGZZw4R2Jwbk=", "path": "github.com/elastic/go-sysinfo/internal/registry", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "ovafihHzpBx9Y7+lZh9X5KwNCvE=", "path": "github.com/elastic/go-sysinfo/providers/darwin", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { - "checksumSHA1": "AK76ZxnuvK02Dfpmj7b2TD/aiSI=", + "checksumSHA1": "OyI+VwDiT4UZjncsDr1GYg1xcdw=", "path": "github.com/elastic/go-sysinfo/providers/linux", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "RWLvcP1w9ynKbuCqiW6prwd+EDU=", "path": "github.com/elastic/go-sysinfo/providers/shared", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "aF05MEkMjbRekzHlwFxmd5WBpeY=", "path": "github.com/elastic/go-sysinfo/providers/windows", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "MLQioPEjULYbNqqCjfB1/cux08E=", "path": "github.com/elastic/go-sysinfo/types", - "revision": "59ef8c0eae46c0929e3b219ac86368d4b5934f91", - "revisionTime": "2019-01-07T12:18:35Z" + "revision": "ab4f04edfc3d6b3864f5f06a068ddab9ad79774f", + "revisionTime": "2019-03-27T18:53:17Z" }, { "checksumSHA1": "bNf3GDGhZh86bfCIMM5c5AYfo3g=",