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

Ensure a 120 second 'provider timeout' with each bmclib client #167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm - there is currently an option being passed in which sets a timeout for each of the providers, is this not working?
bmclib.WithPerProviderTimeout(common.BMCTimeoutFromCtx(ctx))

With the current change - if a provider takes too long on the connection it leaves no time for the others.

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
Loading