From 11fd7a7abbe6968d8210f54254f95de87f70d2ad Mon Sep 17 00:00:00 2001 From: Mikita Iwanowski Date: Mon, 16 Dec 2024 14:18:35 +0100 Subject: [PATCH] cleanup --- .../os/connection/device/device_connection.go | 29 +------------------ providers/os/fs/fs.go | 2 -- providers/os/id/sshhostkey/sshhostkey.go | 3 -- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/providers/os/connection/device/device_connection.go b/providers/os/connection/device/device_connection.go index 5047820807..8d7627217f 100644 --- a/providers/os/connection/device/device_connection.go +++ b/providers/os/connection/device/device_connection.go @@ -5,7 +5,6 @@ package device import ( "errors" - "os" "path" "runtime" "strings" @@ -197,26 +196,6 @@ func tryDetectAsset(connId uint32, partition *snapshot.PartitionInfo, conf *inve fsPath = path.Join(fsPath, partition.Bind) } - // debug - etc, err := os.ReadDir(path.Join(fsPath, "etc")) - etcs := make([]string, 0) - for _, e := range etc { - etcs = append(etcs, e.Name()) - } - log.Debug().Any("etc", etcs).Err(err).Msg("device connection> etc dir") - - // debug - ssh, err := os.ReadDir(path.Join(fsPath, "etc", "ssh")) - sshs := make([]string, 0) - for _, s := range ssh { - sshs = append(sshs, s.Name()) - } - log.Debug().Any("ssh", sshs).Err(err).Msg("device connection> etc/ssh dir") - - // debug - _, err = os.Stat(path.Join(fsPath, "etc", "machine-id")) - log.Debug().Err(err).Msg("device connection> machine-id existance check") - // create and initialize fs provider log.Debug().Str("path", fsPath).Msg("device connection> trying to detect asset") conf.Options["path"] = fsPath @@ -240,9 +219,6 @@ func tryDetectAsset(connId uint32, partition *snapshot.PartitionInfo, conf *inve } log.Debug().Err(err). - Str("partition", partition.Name). // debug - Str("path", fsPath). // debug - Strs("id-detectors", asset.IdDetector). // debug Msg("device connection> detecting platform from device") asset.IdDetector = append(asset.IdDetector, ids.IdDetector_MachineID) @@ -250,15 +226,12 @@ func tryDetectAsset(connId uint32, partition *snapshot.PartitionInfo, conf *inve if err != nil { if len(asset.PlatformIds) == 0 { log.Debug().Err(err). - Str("partition", partition.Name). // debug - Str("path", fsPath). // debug - Strs("id-detectors", asset.IdDetector). // debug Msg("device connection> failed to identify platform from device") return nil, err } log.Warn().Err(err). - Msg("device connection> failed to identify platform from device") + Msg("device connection> failed to identify platform from device, using existing platform ids") } if p == nil { log.Debug().Msg("device connection> no platform detected") diff --git a/providers/os/fs/fs.go b/providers/os/fs/fs.go index c3d7944ad7..e9dd5891f2 100644 --- a/providers/os/fs/fs.go +++ b/providers/os/fs/fs.go @@ -10,7 +10,6 @@ import ( "regexp" "time" - "github.com/rs/zerolog/log" "github.com/spf13/afero" ) @@ -54,7 +53,6 @@ func (t *MountedFs) MkdirAll(path string, perm os.FileMode) error { func (t *MountedFs) Open(name string) (afero.File, error) { mountedPath := t.getPath(name) - log.Debug().Str("mountedPath", mountedPath).Str("requestedPath", name).Msg("opening file") // debug f, e := os.Open(mountedPath) if f == nil { // while this looks strange, we need to return a bare nil (of type nil) not diff --git a/providers/os/id/sshhostkey/sshhostkey.go b/providers/os/id/sshhostkey/sshhostkey.go index c0cb29f882..1e8e3aec1f 100644 --- a/providers/os/id/sshhostkey/sshhostkey.go +++ b/providers/os/id/sshhostkey/sshhostkey.go @@ -36,9 +36,6 @@ func Detect(t shared.Connection, p *inventory.Platform) ([]string, error) { if os.IsPermission(err) { log.Warn().Err(err).Str("hostkey", hostKeyFilePath).Msg("no permission to access ssh hostkey") continue - } else if os.IsNotExist(err) { - log.Debug().Str("hostkey", hostKeyFilePath).Msg("ssh hostkey not found") // debug - continue } else if err != nil { return nil, errors.Wrap(err, "could not read file:"+hostKeyFilePath) }