From b7c5192e597f9a43e411535f967b363e09cfe419 Mon Sep 17 00:00:00 2001 From: Shireesh Anjal <355479+anjalshireesh@users.noreply.github.com> Date: Fri, 13 Oct 2023 21:39:27 +0530 Subject: [PATCH] Revert "Capture network info in health report" (#236) * Revert "Add HealthInfoVersion3 in list of supported versions (#235)" This reverts commit 53a0ee407087365360276b993ec8c5e794de4b11. * Revert "Add required methods to HealthInfoV3 (#234)" This reverts commit 59bc7611546e20c50280a754f4807a118a56544d. * Revert "Capture network info in health report (#233)" This reverts commit 4bedcdb4339131b3eeaebc52178d1356d86994f0. --- go.mod | 1 - go.sum | 3 --- health-old.go | 60 +------------------------------------------------- health.go | 54 ++++++++++++++------------------------------- net_linux.go | 52 ------------------------------------------- net_nolinux.go | 35 ----------------------------- 6 files changed, 18 insertions(+), 187 deletions(-) delete mode 100644 net_linux.go delete mode 100644 net_nolinux.go diff --git a/go.mod b/go.mod index 53d82bd..573c9b3 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/prometheus/client_model v0.4.0 github.com/prometheus/procfs v0.9.0 github.com/prometheus/prom2json v1.3.3 - github.com/safchain/ethtool v0.3.0 github.com/secure-io/sio-go v0.3.1 github.com/shirou/gopsutil/v3 v3.23.1 github.com/tinylib/msgp v1.1.8 diff --git a/go.sum b/go.sum index 3b86ae4..84c3e46 100644 --- a/go.sum +++ b/go.sum @@ -56,8 +56,6 @@ github.com/prometheus/prom2json v1.3.3 h1:IYfSMiZ7sSOfliBoo89PcufjWO4eAR0gznGcET github.com/prometheus/prom2json v1.3.3/go.mod h1:Pv4yIPktEkK7btWsrUTWDDDrnpUrAELaOCj+oFwlgmc= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/safchain/ethtool v0.3.0 h1:gimQJpsI6sc1yIqP/y8GYgiXn/NjgvpM0RNoWLVVmP0= -github.com/safchain/ethtool v0.3.0/go.mod h1:SA9BwrgyAqNo7M+uaL6IYbxpm5wk3L7Mm6ocLW+CJUs= github.com/secure-io/sio-go v0.3.1 h1:dNvY9awjabXTYGsTF1PiCySl9Ltofk9GA3VdWlo7rRc= github.com/secure-io/sio-go v0.3.1/go.mod h1:+xbkjDzPjwh4Axd07pRKSNriS9SCiYksWnZqdnfpQxs= github.com/shirou/gopsutil/v3 v3.23.1 h1:a9KKO+kGLKEvcPIs4W62v0nu3sciVDOOOPUD0Hz7z/4= @@ -111,7 +109,6 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/health-old.go b/health-old.go index ee4e072..eedcf73 100644 --- a/health-old.go +++ b/health-old.go @@ -46,7 +46,7 @@ type HealthInfoV2 struct { Error string `json:"error,omitempty"` TimeStamp time.Time `json:"timestamp,omitempty"` - Sys SysInfoV1 `json:"sys,omitempty"` + Sys SysInfo `json:"sys,omitempty"` Perf PerfInfo `json:"perf,omitempty"` Minio MinioHealthInfo `json:"minio,omitempty"` } @@ -86,51 +86,6 @@ func (info HealthInfoV2) GetTimestamp() time.Time { return info.TimeStamp } -// HealthInfoV3 - MinIO cluster's health Info version 3 -type HealthInfoV3 struct { - Version string `json:"version"` - Error string `json:"error,omitempty"` - - TimeStamp time.Time `json:"timestamp,omitempty"` - Sys SysInfoV1 `json:"sys,omitempty"` - Minio MinioHealthInfo `json:"minio,omitempty"` -} - -func (info HealthInfoV3) String() string { - data, err := json.Marshal(info) - if err != nil { - panic(err) // This never happens. - } - return string(data) -} - -// JSON returns this structure as JSON formatted string. -func (info HealthInfoV3) JSON() string { - data, err := json.MarshalIndent(info, " ", " ") - if err != nil { - panic(err) // This never happens. - } - return string(data) -} - -// GetError - returns error from the cluster health info -func (info HealthInfoV3) GetError() string { - return info.Error -} - -// GetStatus - returns status of the cluster health info -func (info HealthInfoV3) GetStatus() string { - if info.Error != "" { - return "error" - } - return "success" -} - -// GetTimestamp - returns timestamp from the cluster health info -func (info HealthInfoV3) GetTimestamp() time.Time { - return info.TimeStamp -} - // Latency contains write operation latency in seconds of a disk drive. type Latency struct { Avg float64 `json:"avg"` @@ -469,16 +424,3 @@ type NetPerfInfoV0 struct { Throughput NetThroughput `json:"throughput,omitempty"` Error string `json:"error,omitempty"` } - -// SysInfoV1 - Includes hardware and system information of the MinIO cluster V1 -type SysInfoV1 struct { - CPUInfo []CPUs `json:"cpus,omitempty"` - Partitions []Partitions `json:"partitions,omitempty"` - OSInfo []OSInfo `json:"osinfo,omitempty"` - MemInfo []MemInfo `json:"meminfo,omitempty"` - ProcInfo []ProcInfo `json:"procinfo,omitempty"` - SysErrs []SysErrors `json:"errors,omitempty"` - SysServices []SysServices `json:"services,omitempty"` - SysConfig []SysConfig `json:"config,omitempty"` - KubernetesInfo KubernetesInfo `json:"kubernetes"` -} diff --git a/health.go b/health.go index 34997ee..5e1d775 100644 --- a/health.go +++ b/health.go @@ -57,10 +57,8 @@ const ( HealthInfoVersion2 = "2" // HealthInfoVersion3 is version 3 HealthInfoVersion3 = "3" - // HealthInfoVersion4 is version 4 - HealthInfoVersion4 = "4" // HealthInfoVersion is current health info version. - HealthInfoVersion = HealthInfoVersion4 + HealthInfoVersion = HealthInfoVersion3 ) const ( @@ -234,7 +232,6 @@ type Partition struct { Device string `json:"device,omitempty"` Model string `json:"model,omitempty"` - Revision string `json:"revision,omitempty"` Mountpoint string `json:"mountpoint,omitempty"` FSType string `json:"fs_type,omitempty"` MountOptions string `json:"mount_options,omitempty"` @@ -245,14 +242,6 @@ type Partition struct { InodeFree uint64 `json:"inode_free,omitempty"` } -// NetInfo contains information about a network inerface -type NetInfo struct { - NodeCommon - Interface string `json:"interface,omitempty"` - Driver string `json:"driver,omitempty"` - FirmwareVersion string `json:"firmware_version,omitempty"` -} - // Partitions contains all disk partitions information of a node. type Partitions struct { NodeCommon @@ -260,48 +249,41 @@ type Partitions struct { Partitions []Partition `json:"partitions,omitempty"` } -func getDeviceInfo(partDevice string) (model string, revision string, err error) { +func getDeviceModel(partDevice string) (string, error) { + var model string + partDevName := strings.ReplaceAll(partDevice, devDir, "") devPath := path.Join(sysClassBlock, partDevName, "dev") - _, err = os.Stat(devPath) + _, err := os.Stat(devPath) if err != nil { - return + return model, err } - var data []byte - data, err = ioutil.ReadFile(devPath) + data, err := ioutil.ReadFile(devPath) if err != nil { - return + return model, err } majorMinor := strings.TrimSpace(string(data)) driveInfoPath := runDevDataPfx + majorMinor - var f *os.File - f, err = os.Open(driveInfoPath) + f, err := os.Open(driveInfoPath) if err != nil { - return + return model, err } defer f.Close() buf := bufio.NewScanner(f) for buf.Scan() { field := strings.SplitN(buf.Text(), "=", 2) - if len(field) == 2 { - if field[0] == "E:ID_MODEL" { - model = field[1] - } - if field[0] == "E:ID_REVISION" { - revision = field[1] - } - if len(model) > 0 && len(revision) > 0 { - break - } + if len(field) == 2 && field[0] == "E:ID_MODEL" { + model = field[1] + break } } - return + return model, err } // GetPartitions returns all disk partitions information of a node running linux only operating system. @@ -335,11 +317,11 @@ func GetPartitions(ctx context.Context, addr string) Partitions { Error: err.Error(), }) } else { - var model, revision string + var model string device := parts[i].Device if strings.HasPrefix(device, devDir) && !strings.HasPrefix(device, devLoopDir) { // ignore any error in finding device model - model, revision, _ = getDeviceInfo(device) + model, _ = getDeviceModel(device) } partitions = append(partitions, Partition{ @@ -353,7 +335,6 @@ func GetPartitions(ctx context.Context, addr string) Partitions { InodeTotal: usage.InodesTotal, InodeFree: usage.InodesFree, Model: model, - Revision: revision, }) } } @@ -904,7 +885,6 @@ type SysInfo struct { OSInfo []OSInfo `json:"osinfo,omitempty"` MemInfo []MemInfo `json:"meminfo,omitempty"` ProcInfo []ProcInfo `json:"procinfo,omitempty"` - NetInfo []NetInfo `json:"netinfo,omitempty"` SysErrs []SysErrors `json:"errors,omitempty"` SysServices []SysServices `json:"services,omitempty"` SysConfig []SysConfig `json:"config,omitempty"` @@ -1158,7 +1138,7 @@ func (adm *AdminClient) ServerHealthInfo(ctx context.Context, types []HealthData } switch version.Version { - case "", HealthInfoVersion3, HealthInfoVersion2, HealthInfoVersion: + case "", HealthInfoVersion2, HealthInfoVersion: default: closeResponse(resp) return nil, "", errors.New("Upgrade Minio Client to support health info version " + version.Version) diff --git a/net_linux.go b/net_linux.go deleted file mode 100644 index 97ea0ae..0000000 --- a/net_linux.go +++ /dev/null @@ -1,52 +0,0 @@ -//go:build linux -// +build linux - -// Copyright (c) 2015-2023 MinIO, Inc. -// -// This file is part of MinIO Object Storage stack -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package madmin - -import ( - "fmt" - - "github.com/safchain/ethtool" -) - -// GetNetInfo returns information of the given network interface -func GetNetInfo(addr string, iface string) (ni NetInfo) { - ni.Addr = addr - ni.Interface = iface - - ethHandle, err := ethtool.NewEthtool() - if err != nil { - ni.Error = err.Error() - return - } - defer ethHandle.Close() - - di, err := ethHandle.DriverInfo(ni.Interface) - if err != nil { - ni.Error = fmt.Sprintf("Error getting driver info for %s: %s", ni.Interface, err.Error()) - return - } - - ni.Driver = di.Driver - ni.FirmwareVersion = di.FwVersion - - return -} diff --git a/net_nolinux.go b/net_nolinux.go deleted file mode 100644 index ca5e2d3..0000000 --- a/net_nolinux.go +++ /dev/null @@ -1,35 +0,0 @@ -//go:build !linux -// +build !linux - -// -// Copyright (c) 2015-2023 MinIO, Inc. -// -// This file is part of MinIO Object Storage stack -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package madmin - -// GetNetInfo returns information of the given network interface -// Not implemented for non-linux platforms -func GetNetInfo(addr string, iface string) NetInfo { - return NetInfo{ - NodeCommon: NodeCommon{ - Addr: addr, - Error: "Not implemented for non-linux platforms", - }, - Interface: iface, - } -}