From 424d07c018b6bb091a84ecf52fa85c613ff2ad30 Mon Sep 17 00:00:00 2001 From: Olivier FAURAX Date: Fri, 17 Nov 2023 16:19:23 +0100 Subject: [PATCH 1/5] debug: use local bmclib + update go modules --- go.mod | 4 +++- go.sum | 15 +++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index f2f79eb5..a812de42 100644 --- a/go.mod +++ b/go.mod @@ -115,7 +115,7 @@ require ( github.com/spf13/afero v1.10.0 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/stmcginnis/gofish v0.14.1-0.20230920133920-77490fd98fa2 // indirect + github.com/stmcginnis/gofish v0.14.1-0.20231018151402-dddaff9168fb // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect @@ -153,3 +153,5 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace github.com/bmc-toolbox/bmclib/v2 => ../bmclib diff --git a/go.sum b/go.sum index 68ab5a0d..6e5141fd 100644 --- a/go.sum +++ b/go.sum @@ -99,12 +99,6 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bmc-toolbox/bmclib/v2 v2.1.0 h1:4zC8/ODEeO8uWiBJGUO8u2HgGJWtoDZfSEBFYrd5RHA= -github.com/bmc-toolbox/bmclib/v2 v2.1.0/go.mod h1:hRe0RhyHbyQDFULc6HQFBIwdBOFYnm+8rHeO9UBnxAU= -github.com/bmc-toolbox/bmclib/v2 v2.1.1-0.20231017114451-153e11d62a71 h1:Dd76cvKu9/bRl6MKFASf+UmqyqwTdApmvgCvdab078w= -github.com/bmc-toolbox/bmclib/v2 v2.1.1-0.20231017114451-153e11d62a71/go.mod h1:hRe0RhyHbyQDFULc6HQFBIwdBOFYnm+8rHeO9UBnxAU= -github.com/bmc-toolbox/bmclib/v2 v2.1.1-0.20231103151819-643a35b7f0cc h1:1rUCwHba1fmcudx+tdB2x5OEct0qd4LIwwFYKRoDOrI= -github.com/bmc-toolbox/bmclib/v2 v2.1.1-0.20231103151819-643a35b7f0cc/go.mod h1:6zmmt8sLmcBGdiKY/+YAfxXjmLCAoVNMjLurBO3uhYw= github.com/bmc-toolbox/common v0.0.0-20230717121556-5eb9915a8a5a h1:SjtoU9dE3bYfYnPXODCunMztjoDgnE3DVJCPLBqwz6Q= github.com/bmc-toolbox/common v0.0.0-20230717121556-5eb9915a8a5a/go.mod h1:SY//n1PJjZfbFbmAsB6GvEKbc7UXz3d30s3kWxfJQ/c= github.com/bombsimon/logrusr/v2 v2.0.1 h1:1VgxVNQMCvjirZIYaT9JYn6sAVGVEcNtRE0y4mvaOAM= @@ -216,11 +210,8 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.0.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -653,7 +644,7 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= -github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= +github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/crypt v0.6.0/go.mod h1:U8+INwJo3nBv1m6A/8OBXAq7Jnpspk5AxSgDyEQcea8= @@ -695,8 +686,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI= github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= -github.com/stmcginnis/gofish v0.14.1-0.20230920133920-77490fd98fa2 h1:R0N4G786trm1dHBwJftzaupRrwhY1T+rBrTBC8eqiRQ= -github.com/stmcginnis/gofish v0.14.1-0.20230920133920-77490fd98fa2/go.mod h1:BLDSFTp8pDlf/xDbLZa+F7f7eW0E/CHCboggsu8CznI= +github.com/stmcginnis/gofish v0.14.1-0.20231018151402-dddaff9168fb h1:+BpzUuFIEAs71bTshedsUHAAq21VZWvuokbN9ABEQeQ= +github.com/stmcginnis/gofish v0.14.1-0.20231018151402-dddaff9168fb/go.mod h1:BLDSFTp8pDlf/xDbLZa+F7f7eW0E/CHCboggsu8CznI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= From 90dda14892da4e0329ac1953574942a61e7eb90a Mon Sep 17 00:00:00 2001 From: Olivier FAURAX Date: Thu, 16 Nov 2023 19:15:30 +0100 Subject: [PATCH 2/5] make: Build linux in debug and statically --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8de60af9..7beac1d0 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ build-linux: ifeq ($(GO_VERSION), 0) $(error build requies go version 1.16.n or higher) endif - GOOS=linux GOARCH=amd64 go build -o flasher \ + GOOS=linux GOARCH=amd64 BMCLIB_DEBUG=true go build -o flasher -tags osusergo,netgo \ -ldflags \ "-X $(LDFLAG_LOCATION).GitCommit=$(GIT_COMMIT) \ -X $(LDFLAG_LOCATION).GitBranch=$(GIT_BRANCH) \ From 34be3fcbccdefcaa884617187489e8417e7948c6 Mon Sep 17 00:00:00 2001 From: Olivier FAURAX Date: Fri, 17 Nov 2023 08:45:27 +0100 Subject: [PATCH 3/5] internal: adapt to new constants (needs bmclib>=4666b8) --- internal/outofband/bmc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/outofband/bmc.go b/internal/outofband/bmc.go index ff2e0c4d..5eddeb8a 100644 --- a/internal/outofband/bmc.go +++ b/internal/outofband/bmc.go @@ -205,7 +205,7 @@ func (b *bmc) FirmwareInstall(ctx context.Context, componentSlug string, force b installCtx, cancel := context.WithTimeout(ctx, firmwareInstallTimeout) defer cancel() - return b.client.FirmwareInstall(installCtx, componentSlug, bmclibv2consts.FirmwareApplyOnReset, force, file) + return b.client.FirmwareInstall(installCtx, componentSlug, string(bmclibv2consts.OnReset), force, file) } // FirmwareInstallStatus looks up the firmware install status based on the given installVersion, componentSlug, bmcTaskID parameters @@ -232,7 +232,7 @@ func (b *bmc) FirmwareInstallStatus(ctx context.Context, installVersion, compone switch status { case bmclibv2consts.FirmwareInstallInitializing, bmclibv2consts.FirmwareInstallQueued, bmclibv2consts.FirmwareInstallRunning: return model.StatusInstallRunning, nil - case bmclibv2consts.FirmwareInstallPowerCyleHost: + case bmclibv2consts.FirmwareInstallPowerCycleHost: // if the host is under reset (this is the final state only for queueing updates) // if hostWasReset { // return false, nil From 80bc0c9853edc01a84b1a8b0d7cfe0ea56677027 Mon Sep 17 00:00:00 2001 From: Olivier FAURAX Date: Fri, 17 Nov 2023 16:20:34 +0100 Subject: [PATCH 4/5] internal: add support for tryOpen boolean --- internal/fixtures/bmc.go | 2 +- internal/model/model.go | 2 +- internal/outofband/action_handlers.go | 1 + internal/outofband/bmc.go | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/fixtures/bmc.go b/internal/fixtures/bmc.go index e7d0897d..093ac387 100644 --- a/internal/fixtures/bmc.go +++ b/internal/fixtures/bmc.go @@ -71,7 +71,7 @@ func (b *mockBMC) FirmwareInstall(ctx context.Context, componentSlug string, for } // FirmwareInstallStatus looks up the firmware install status based on the given installVersion, componentSlug, bmcTaskID parameteres -func (b *mockBMC) FirmwareInstallStatus(ctx context.Context, installVersion, componentSlug, bmcTaskID string) (model.ComponentFirmwareInstallStatus, error) { +func (b *mockBMC) FirmwareInstallStatus(ctx context.Context, installVersion, componentSlug, bmcTaskID string, tryOpen bool) (model.ComponentFirmwareInstallStatus, error) { status := os.Getenv(EnvMockBMCFirmwareInstallStatus) if status == "" { diff --git a/internal/model/model.go b/internal/model/model.go index 48a09ce5..a3a70880 100644 --- a/internal/model/model.go +++ b/internal/model/model.go @@ -119,5 +119,5 @@ type DeviceQueryor interface { // FirmwareInstall initiates the firmware install process returning a taskID for the install if any. FirmwareInstall(ctx context.Context, componentSlug string, force bool, file *os.File) (taskID string, err error) - FirmwareInstallStatus(ctx context.Context, installVersion, componentSlug, bmcTaskID string) (ComponentFirmwareInstallStatus, error) + FirmwareInstallStatus(ctx context.Context, installVersion, componentSlug, bmcTaskID string, tryOpen bool) (ComponentFirmwareInstallStatus, error) } diff --git a/internal/outofband/action_handlers.go b/internal/outofband/action_handlers.go index eff8ca1a..3f4f8250 100644 --- a/internal/outofband/action_handlers.go +++ b/internal/outofband/action_handlers.go @@ -423,6 +423,7 @@ func (h *actionHandler) pollFirmwareInstallStatus(a sw.StateSwitch, c sw.Transit action.Firmware.Version, action.Firmware.Component, action.BMCTaskID, + false, // default for AsRockRack E3C256D4ID-NL ) tctx.Logger.WithFields( diff --git a/internal/outofband/bmc.go b/internal/outofband/bmc.go index 5eddeb8a..aafe9bbe 100644 --- a/internal/outofband/bmc.go +++ b/internal/outofband/bmc.go @@ -209,7 +209,7 @@ func (b *bmc) FirmwareInstall(ctx context.Context, componentSlug string, force b } // FirmwareInstallStatus looks up the firmware install status based on the given installVersion, componentSlug, bmcTaskID parameters -func (b *bmc) FirmwareInstallStatus(ctx context.Context, installVersion, componentSlug, bmcTaskID string) (model.ComponentFirmwareInstallStatus, error) { +func (b *bmc) FirmwareInstallStatus(ctx context.Context, installVersion, componentSlug, bmcTaskID string, tryOpen bool) (model.ComponentFirmwareInstallStatus, error) { ctx, span := otel.Tracer(pkgName).Start(ctx, "bmclib.FirmwareInstallStatus") defer span.End() From 84f6fd75de602685a2223aed341cd9e3f3903f32 Mon Sep 17 00:00:00 2001 From: Olivier FAURAX Date: Fri, 17 Nov 2023 16:29:12 +0100 Subject: [PATCH 5/5] bmc: only try to Open when tryOpen is true --- internal/outofband/bmc.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/outofband/bmc.go b/internal/outofband/bmc.go index aafe9bbe..4896f002 100644 --- a/internal/outofband/bmc.go +++ b/internal/outofband/bmc.go @@ -215,8 +215,10 @@ func (b *bmc) FirmwareInstallStatus(ctx context.Context, installVersion, compone span.SetAttributes(attribute.String("bmc-ip", b.client.Auth.Host)) - if err := b.Open(ctx); err != nil { - return model.StatusInstallUnknown, errors.Wrap(ErrBMCQuery, err.Error()) + if tryOpen { + if err := b.Open(ctx); err != nil { + return model.StatusInstallUnknown, errors.Wrap(ErrBMCQuery, err.Error()) + } } status, err := b.client.FirmwareInstallStatus(ctx, installVersion, componentSlug, bmcTaskID)