Skip to content

Commit

Permalink
Ensure a 120 second 'provider timeout' with each bmclib client
Browse files Browse the repository at this point in the history
  • Loading branch information
splaspood committed Oct 10, 2024
1 parent f40b9cd commit a3e34d1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions grpc/oob/bmc/bmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package bmc
import (
"context"
"fmt"
"time"

"github.com/bmc-toolbox/bmclib/v2"
"github.com/bmc-toolbox/bmclib/v2/bmc"
Expand Down Expand Up @@ -310,6 +311,9 @@ func (m Action) BMCReset(ctx context.Context, rType string) (err error) {
span.SetAttributes(attribute.String("bmc.host", host), attribute.String("bmc.username", user))
m.SendStatusMessage("working on bmc reset")

ctx, cancel := context.WithTimeout(ctx, 120*time.Second)
defer cancel()

opts := []bmclib.Option{
bmclib.WithLogger(m.Log),
bmclib.WithPerProviderTimeout(common.BMCTimeoutFromCtx(ctx)),
Expand Down Expand Up @@ -381,6 +385,9 @@ func (m Action) DeactivateSOL(ctx context.Context) error {
span.SetAttributes(attribute.String("bmc.host", host), attribute.String("bmc.username", user))
m.SendStatusMessage("working on SOL session deactivation")

ctx, cancel := context.WithTimeout(ctx, 120*time.Second)
defer cancel()

opts := []bmclib.Option{
bmclib.WithLogger(m.Log),
bmclib.WithPerProviderTimeout(common.BMCTimeoutFromCtx(ctx)),
Expand Down
4 changes: 4 additions & 0 deletions grpc/oob/bmc/users_bmclibv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package bmc
import (
"context"
"fmt"
"time"

"github.com/bmc-toolbox/bmclib/v2"
"github.com/go-logr/logr"
Expand Down Expand Up @@ -33,6 +34,9 @@ type bmclibv2UserManagement struct {
func (b *bmclibv2UserManagement) Connect(ctx context.Context) error {
var errMsg repository.Error

ctx, cancel := context.WithTimeout(ctx, 120*time.Second)
defer cancel()

opts := []bmclib.Option{
bmclib.WithLogger(b.log),
bmclib.WithPerProviderTimeout(common.BMCTimeoutFromCtx(ctx)),
Expand Down
4 changes: 4 additions & 0 deletions grpc/oob/diagnostic/clearsel.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package diagnostic
import (
"context"
"fmt"
"time"

"github.com/bmc-toolbox/bmclib/v2"
"github.com/bmc-toolbox/bmclib/v2/providers"
Expand Down Expand Up @@ -55,6 +56,9 @@ func (m Action) ClearSystemEventLog(ctx context.Context) (result string, err err
}
span.SetAttributes(attribute.String("bmc.host", host), attribute.String("bmc.username", user))

ctx, cancel := context.WithTimeout(ctx, 120*time.Second)
defer cancel()

opts := []bmclib.Option{
bmclib.WithLogger(m.Log),
bmclib.WithPerProviderTimeout(common.BMCTimeoutFromCtx(ctx)),
Expand Down
4 changes: 4 additions & 0 deletions grpc/oob/diagnostic/nmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package diagnostic
import (
"context"
"fmt"
"time"

"github.com/bmc-toolbox/bmclib/v2"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -50,6 +51,9 @@ func (m Action) SendNMI(ctx context.Context) error {
}
span.SetAttributes(attribute.String("bmc.host", host), attribute.String("bmc.username", user))

ctx, cancel := context.WithTimeout(ctx, 120*time.Second)
defer cancel()

opts := []bmclib.Option{
bmclib.WithLogger(m.Log),
bmclib.WithPerProviderTimeout(common.BMCTimeoutFromCtx(ctx)),
Expand Down
4 changes: 4 additions & 0 deletions grpc/oob/diagnostic/screenshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package diagnostic
import (
"context"
"fmt"
"time"

"github.com/bmc-toolbox/bmclib/v2"
"github.com/bmc-toolbox/bmclib/v2/bmc"
Expand Down Expand Up @@ -56,6 +57,9 @@ func (m Action) GetScreenshot(ctx context.Context) (image []byte, filetype strin
}
span.SetAttributes(attribute.String("bmc.host", host), attribute.String("bmc.username", user))

ctx, cancel := context.WithTimeout(ctx, 120*time.Second)
defer cancel()

opts := []bmclib.Option{
bmclib.WithLogger(m.Log),
bmclib.WithPerProviderTimeout(common.BMCTimeoutFromCtx(ctx)),
Expand Down
4 changes: 4 additions & 0 deletions grpc/oob/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"strings"
"time"

"github.com/bmc-toolbox/bmclib/v2"
"github.com/bmc-toolbox/bmclib/v2/bmc"
Expand Down Expand Up @@ -149,6 +150,9 @@ func (m Action) BootDeviceSet(ctx context.Context, device string, persistent, ef
msg := "working on " + base
m.SendStatusMessage(msg)

ctx, cancel := context.WithTimeout(ctx, 120*time.Second)
defer cancel()

opts := []bmclib.Option{
bmclib.WithLogger(m.Log),
bmclib.WithPerProviderTimeout(common.BMCTimeoutFromCtx(ctx)),
Expand Down

0 comments on commit a3e34d1

Please sign in to comment.