From b9d311c095a3f1348b845f31b70cf07364295394 Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Tue, 9 Jul 2024 09:03:44 -0400 Subject: [PATCH 1/3] =?UTF-8?q?Change=20debug=20message=20Info=20=E2=86=92?= =?UTF-8?q?=20Debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are all just low level debug info so should have been Debug from the beginning. --- actions/inventory.go | 4 ++-- examples/diskwipe/main.go | 2 +- examples/nvme-ns-wipe/main.go | 2 +- providers/asrockrack/asrockrack.go | 2 +- providers/dell/dell.go | 10 +++++----- providers/dell/helpers.go | 6 +++--- providers/generic/generic.go | 2 +- providers/supermicro/supermicro.go | 2 +- utils/blkdiscard.go | 2 +- utils/fill_zero.go | 8 ++++---- utils/hdparm.go | 6 +++--- utils/nvme.go | 8 ++++---- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/actions/inventory.go b/actions/inventory.go index f2ad9fd66..bfec88444 100644 --- a/actions/inventory.go +++ b/actions/inventory.go @@ -689,7 +689,7 @@ func (a *InventoryCollectorAction) CollectFirmwareChecksums(ctx context.Context) }() if a.collectors.FirmwareChecksumCollector == nil { - a.log.Info("nil firmware checksum collector") + a.log.Debug("nil firmware checksum collector") return nil } @@ -698,7 +698,7 @@ func (a *InventoryCollectorAction) CollectFirmwareChecksums(ctx context.Context) if slices.Contains(a.disabledCollectorUtilities, collectorKind) || slices.Contains(a.disabledCollectorUtilities, firmware.FirmwareDumpUtility) || slices.Contains(a.disabledCollectorUtilities, firmware.UEFIParserUtility) { - a.log.Info("firmware checksum disabled") + a.log.Debug("firmware checksum disabled") return nil } diff --git a/examples/diskwipe/main.go b/examples/diskwipe/main.go index 9bbf959fe..2d54b9a99 100644 --- a/examples/diskwipe/main.go +++ b/examples/diskwipe/main.go @@ -95,7 +95,7 @@ func main() { // If the user supplied a non-default timeout then we'll honor it, otherwise we just go with a huge timeout. // If this were *real* code and not an example some work could be done to guesstimate a timeout based on disk size. if timeout == defaultTimeout { - l.WithField("timeout", timeout.String()).Info("increasing timeout") + l.WithField("timeout", timeout.String()).Debug("increasing timeout") timeout = 24 * time.Hour ctx, cancel = context.WithTimeout(context.WithoutCancel(ctx), timeout) defer cancel() diff --git a/examples/nvme-ns-wipe/main.go b/examples/nvme-ns-wipe/main.go index 8e52edf96..607d2356b 100644 --- a/examples/nvme-ns-wipe/main.go +++ b/examples/nvme-ns-wipe/main.go @@ -34,7 +34,7 @@ func main() { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() - logger.Info("resetting namespaces") + logger.Debug("resetting namespaces") err = nvme.ResetNS(ctx, *logicalName) if err != nil { logger.WithError(err).Fatal("exiting") diff --git a/providers/asrockrack/asrockrack.go b/providers/asrockrack/asrockrack.go index 357611061..bfb55a389 100644 --- a/providers/asrockrack/asrockrack.go +++ b/providers/asrockrack/asrockrack.go @@ -52,7 +52,7 @@ func New(dmidecode *utils.Dmidecode, l *logrus.Logger) (actions.DeviceManager, e // Returns hardware inventory for the device func (a *asrockrack) GetInventory(ctx context.Context, options ...actions.Option) (*common.Device, error) { // Collect device inventory - a.logger.Info("Collecting inventory") + a.logger.Debug("Collecting inventory") deviceObj := common.NewDevice() a.hw.Device = &deviceObj diff --git a/providers/dell/dell.go b/providers/dell/dell.go index 9f25321a9..d898003cd 100644 --- a/providers/dell/dell.go +++ b/providers/dell/dell.go @@ -114,7 +114,7 @@ func (d *dell) UpdatesApplied() bool { // GetInventory collects hardware inventory along with the firmware installed and returns a Device object func (d *dell) GetInventory(ctx context.Context, options ...actions.Option) (*common.Device, error) { // Collect device inventory - d.logger.Info("Collecting hardware inventory") + d.logger.Debug("Collecting hardware inventory") collector := actions.NewInventoryCollectorAction(d.logger, options...) if err := collector.Collect(ctx, d.hw.Device); err != nil { @@ -142,7 +142,7 @@ func (d *dell) GetInventoryOEM(ctx context.Context, _ *common.Device, options *m // ListAvailableUpdates runs the vendor tooling (dsu) to identify updates available func (d *dell) ListAvailableUpdates(ctx context.Context, options *model.UpdateOptions) (*common.Device, error) { // collect firmware updates available for components - d.logger.Info("Identifying component firmware updates...") + d.logger.Debug("Identifying component firmware updates...") d.setUpdateOptions(options) @@ -153,11 +153,11 @@ func (d *dell) ListAvailableUpdates(ctx context.Context, options *model.UpdateOp count := len(oemUpdates) if count == 0 { - d.logger.Info("no available dell Oem updates") + d.logger.Debug("no available dell Oem updates") return nil, nil } - d.logger.WithField("count", count).Info("component updates identified..") + d.logger.WithField("count", count).Debug("component updates identified..") d.hw.OEMComponents = append(d.hw.OEMComponents, oemUpdates...) @@ -225,7 +225,7 @@ func (d *dell) setUpdateOptions(options *model.UpdateOptions) { "dsu repo": d.dsuReleaseVersion, "base url": d.updateBaseURL, }, - ).Info("update parameters") + ).Debug("update parameters") } // ApplyUpdate is here to satisfy the actions.Updater interface diff --git a/providers/dell/helpers.go b/providers/dell/helpers.go index 92f13b316..c0c2f4a2b 100644 --- a/providers/dell/helpers.go +++ b/providers/dell/helpers.go @@ -79,7 +79,7 @@ func (d *dell) installUpdate(ctx context.Context, updateFile string, downgrade b d.logger.WithFields( logrus.Fields{"file": updateFile}, - ).Info("Installing dell Update Bin file") + ).Debug("Installing dell Update Bin file") result, err := e.Exec(ctx) if err != nil { @@ -88,7 +88,7 @@ func (d *dell) installUpdate(ctx context.Context, updateFile string, downgrade b d.logger.WithFields( logrus.Fields{"file": updateFile}, - ).Info("Installed") + ).Debug("Installed") d.hw.PendingReboot = true @@ -140,7 +140,7 @@ func (d *dell) pre(ctx context.Context) (err error) { } } - d.logger.Info("Dell DSU prerequisites setup complete") + d.logger.Debug("Dell DSU prerequisites setup complete") d.DsuPrequisitesInstalled = true return nil diff --git a/providers/generic/generic.go b/providers/generic/generic.go index 1f41c6542..2d8bb2b24 100644 --- a/providers/generic/generic.go +++ b/providers/generic/generic.go @@ -53,7 +53,7 @@ func New(dmidecode *utils.Dmidecode, l *logrus.Logger) (actions.DeviceManager, e // Returns hardware inventory for the device func (a *Generic) GetInventory(ctx context.Context, options ...actions.Option) (*common.Device, error) { // Collect device inventory - a.logger.Info("Collecting inventory") + a.logger.Debug("Collecting inventory") collector := actions.NewInventoryCollectorAction(a.logger, options...) if err := collector.Collect(ctx, a.hw.Device); err != nil { diff --git a/providers/supermicro/supermicro.go b/providers/supermicro/supermicro.go index 37ab9d8f9..f56c7fd14 100644 --- a/providers/supermicro/supermicro.go +++ b/providers/supermicro/supermicro.go @@ -70,7 +70,7 @@ func (s *supermicro) UpdatesApplied() bool { // GetInventory collects hardware inventory along with the firmware installed and returns a Device object func (s *supermicro) GetInventory(ctx context.Context, options ...actions.Option) (*common.Device, error) { // Collect device inventory - s.logger.Info("Collecting hardware inventory") + s.logger.Debug("Collecting hardware inventory") // define collectors for supermicro hardware collectors := &actions.Collectors{ diff --git a/utils/blkdiscard.go b/utils/blkdiscard.go index 0c74e2565..43ef2283f 100644 --- a/utils/blkdiscard.go +++ b/utils/blkdiscard.go @@ -51,7 +51,7 @@ func (b *Blkdiscard) Discard(ctx context.Context, drive *common.Drive) error { // WipeDrive implements DriveWipe by calling Discard func (b *Blkdiscard) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *common.Drive) error { - logger.WithField("drive", drive.LogicalName).WithField("method", "blkdiscard").Info("wiping") + logger.WithField("drive", drive.LogicalName).WithField("method", "blkdiscard").Debug("wiping") return b.Discard(ctx, drive) } diff --git a/utils/fill_zero.go b/utils/fill_zero.go index 2a8fd8929..72ba8ae5b 100644 --- a/utils/fill_zero.go +++ b/utils/fill_zero.go @@ -26,7 +26,7 @@ func NewFillZeroCmd(trace bool) *FillZero { func (z *FillZero) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *common.Drive) error { log := logger.WithField("drive", drive.LogicalName).WithField("method", "zero-fill") - log.Info("wiping") + log.Debug("wiping") verify, err := ApplyWatermarks(drive) if err != nil { @@ -46,7 +46,7 @@ func (z *FillZero) WipeDrive(ctx context.Context, logger *logrus.Logger, drive * return err } - log.WithField("size", fmt.Sprintf("%dB", partitionSize)).Info("disk info detected") + log.WithField("size", fmt.Sprintf("%dB", partitionSize)).Debug("disk info detected") _, err = file.Seek(0, io.SeekStart) if err != nil { return err @@ -60,7 +60,7 @@ func (z *FillZero) WipeDrive(ctx context.Context, logger *logrus.Logger, drive * // Check if the context has been canceled select { case <-ctx.Done(): - log.Info("stopping") + log.Debug("stopping") return ctx.Err() default: l := min(int64(len(buffer)), bytesRemaining) @@ -100,7 +100,7 @@ func printProgress(log *logrus.Entry, totalBytesWritten, partitionSize int64, st "progress": fmt.Sprintf("%.2f%%", progress), "speed": fmt.Sprintf("%.2f MB/s", mbPerSecond), "remaining": fmt.Sprintf("%.2f hour(s)", remainingHours), - }).Info("") + }).Debug("") } // SetQuiet lowers the verbosity diff --git a/utils/hdparm.go b/utils/hdparm.go index 4a465bd27..c060fbb5d 100644 --- a/utils/hdparm.go +++ b/utils/hdparm.go @@ -240,7 +240,7 @@ func (h *Hdparm) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *co if sanitize && cse { // nolint:govet l := l.WithField("method", "sanitize").WithField("action", "sanitize-crypto-scramble") - l.Info("wiping") + l.Debug("wiping") err := h.Sanitize(ctx, drive, CryptoErase) if err == nil { return nil @@ -250,7 +250,7 @@ func (h *Hdparm) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *co if sanitize && bee { // nolint:govet l := l.WithField("method", "sanitize").WithField("action", "sanitize-block-erase") - l.Info("wiping") + l.Debug("wiping") err := h.Sanitize(ctx, drive, BlockErase) if err == nil { return nil @@ -260,7 +260,7 @@ func (h *Hdparm) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *co if esee && eseu { // nolint:govet l := l.WithField("method", "security-erase-enhanced") - l.Info("wiping") + l.Debug("wiping") err := h.Erase(ctx, drive, CryptographicErase) if err == nil { return nil diff --git a/utils/nvme.go b/utils/nvme.go index ec12847b6..b139e150f 100644 --- a/utils/nvme.go +++ b/utils/nvme.go @@ -310,7 +310,7 @@ func (n *Nvme) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *comm if cer { // nolint:govet l := l.WithField("method", "sanitize").WithField("action", CryptoErase) - l.Info("wiping") + l.Debug("wiping") err := n.Sanitize(ctx, drive, CryptoErase) if err == nil { return nil @@ -320,7 +320,7 @@ func (n *Nvme) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *comm if ber { // nolint:govet l := l.WithField("method", "sanitize").WithField("action", BlockErase) - l.Info("wiping") + l.Debug("wiping") err := n.Sanitize(ctx, drive, BlockErase) if err == nil { return nil @@ -330,7 +330,7 @@ func (n *Nvme) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *comm if cese { // nolint:govet l := l.WithField("method", "format").WithField("setting", CryptographicErase) - l.Info("wiping") + l.Debug("wiping") err := n.Format(ctx, drive, CryptographicErase) if err == nil { return nil @@ -339,7 +339,7 @@ func (n *Nvme) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *comm } l = l.WithField("method", "format").WithField("setting", UserDataErase) - l.Info("wiping") + l.Debug("wiping") err := n.Format(ctx, drive, UserDataErase) if err == nil { return nil From 3da43b64c29ff3b52fd22df0d12f7659f600ebaa Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Tue, 9 Jul 2024 09:03:44 -0400 Subject: [PATCH 2/3] =?UTF-8?q?Change=20error=20message=20Info=20=E2=86=92?= =?UTF-8?q?=20Error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are errors that should be logged since callers would otherwise not know what is going on. Should go away when/if we add `func DriveWipers() []DriveWiper` to ironlib. --- utils/hdparm.go | 6 +++--- utils/nvme.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/utils/hdparm.go b/utils/hdparm.go index c060fbb5d..5c48d8754 100644 --- a/utils/hdparm.go +++ b/utils/hdparm.go @@ -245,7 +245,7 @@ func (h *Hdparm) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *co if err == nil { return nil } - l.WithError(err).Info("failed") + l.WithError(err).Error("failed") } if sanitize && bee { // nolint:govet @@ -255,7 +255,7 @@ func (h *Hdparm) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *co if err == nil { return nil } - l.WithError(err).Info("failed") + l.WithError(err).Error("failed") } if esee && eseu { // nolint:govet @@ -265,7 +265,7 @@ func (h *Hdparm) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *co if err == nil { return nil } - l.WithError(err).Info("failed") + l.WithError(err).Error("failed") } return ErrIneffectiveWipe } diff --git a/utils/nvme.go b/utils/nvme.go index b139e150f..2f9e9f07c 100644 --- a/utils/nvme.go +++ b/utils/nvme.go @@ -315,7 +315,7 @@ func (n *Nvme) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *comm if err == nil { return nil } - l.WithError(err).Info("failed") + l.WithError(err).Error("failed") } if ber { // nolint:govet @@ -325,7 +325,7 @@ func (n *Nvme) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *comm if err == nil { return nil } - l.WithError(err).Info("failed") + l.WithError(err).Error("failed") } if cese { // nolint:govet @@ -335,7 +335,7 @@ func (n *Nvme) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *comm if err == nil { return nil } - l.WithError(err).Info("failed") + l.WithError(err).Error("failed") } l = l.WithField("method", "format").WithField("setting", UserDataErase) @@ -344,7 +344,7 @@ func (n *Nvme) WipeDrive(ctx context.Context, logger *logrus.Logger, drive *comm if err == nil { return nil } - l.WithError(err).Info("failed") + l.WithError(err).Error("failed") return ErrIneffectiveWipe } From ffce05c3520c98ae4155e2f54ed9752588044aef Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Tue, 9 Jul 2024 09:13:40 -0400 Subject: [PATCH 3/3] Change examples/diskwipe WipeDrive logger to Debug level So we always show the wipe messages. --- examples/diskwipe/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/diskwipe/main.go b/examples/diskwipe/main.go index 2d54b9a99..2a8075fab 100644 --- a/examples/diskwipe/main.go +++ b/examples/diskwipe/main.go @@ -107,7 +107,9 @@ func main() { l.Fatal("failed find appropriate wiper drive") } - err = wiper.WipeDrive(ctx, logger, drive) + ll := logger + ll.SetLevel(logrus.DebugLevel) + err = wiper.WipeDrive(ctx, ll, drive) if err != nil { l.Fatal("failed to wipe drive") }