Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Open() before asking installStatus #108

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
15 changes: 3 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion internal/fixtures/bmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
1 change: 1 addition & 0 deletions internal/outofband/action_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 7 additions & 5 deletions internal/outofband/bmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"

bmclibv2 "github.com/bmc-toolbox/bmclib/v2"

Check failure on line 13 in internal/outofband/bmc.go

View workflow job for this annotation

GitHub Actions / lint-test

github.com/bmc-toolbox/bmclib/[email protected]: replacement directory ../bmclib does not exist

Check failure on line 13 in internal/outofband/bmc.go

View workflow job for this annotation

GitHub Actions / lint-test

github.com/bmc-toolbox/bmclib/[email protected]: replacement directory ../bmclib does not exist

Check failure on line 13 in internal/outofband/bmc.go

View workflow job for this annotation

GitHub Actions / lint-test

github.com/bmc-toolbox/bmclib/[email protected]: replacement directory ../bmclib does not exist
bmclibv2consts "github.com/bmc-toolbox/bmclib/v2/constants"

Check failure on line 14 in internal/outofband/bmc.go

View workflow job for this annotation

GitHub Actions / lint-test

github.com/bmc-toolbox/bmclib/[email protected]: replacement directory ../bmclib does not exist

Check failure on line 14 in internal/outofband/bmc.go

View workflow job for this annotation

GitHub Actions / lint-test

github.com/bmc-toolbox/bmclib/[email protected]: replacement directory ../bmclib does not exist

Check failure on line 14 in internal/outofband/bmc.go

View workflow job for this annotation

GitHub Actions / lint-test

github.com/bmc-toolbox/bmclib/[email protected]: replacement directory ../bmclib does not exist
bmclibv2errs "github.com/bmc-toolbox/bmclib/v2/errors"

Check failure on line 15 in internal/outofband/bmc.go

View workflow job for this annotation

GitHub Actions / lint-test

github.com/bmc-toolbox/bmclib/[email protected]: replacement directory ../bmclib does not exist

Check failure on line 15 in internal/outofband/bmc.go

View workflow job for this annotation

GitHub Actions / lint-test

github.com/bmc-toolbox/bmclib/[email protected]: replacement directory ../bmclib does not exist

Check failure on line 15 in internal/outofband/bmc.go

View workflow job for this annotation

GitHub Actions / lint-test

github.com/bmc-toolbox/bmclib/[email protected]: replacement directory ../bmclib does not exist

"github.com/bmc-toolbox/common"
"github.com/metal-toolbox/flasher/internal/model"
Expand Down Expand Up @@ -205,18 +205,20 @@
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
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()

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)
Expand All @@ -232,7 +234,7 @@
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
Expand Down
Loading