Skip to content

Commit

Permalink
Fix session leak in Dell provider:
Browse files Browse the repository at this point in the history
This was leaving open sessions in non Dell
machines. Closed sessions when the Dell
Open function returns error after successfully
opening.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed Oct 16, 2023
1 parent b6af042 commit 422edc2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions providers/dell/idrac.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,16 @@ func (c *Conn) Open(ctx context.Context) (err error) {
// is available across various BMC vendors, we verify the device we're connected to is dell.
manufacturer, err := c.deviceManufacturer(ctx)
if err != nil {
if er := c.redfishwrapper.Close(ctx); er != nil {
return fmt.Errorf("%v: %w", err, er)

Check warning on line 132 in providers/dell/idrac.go

View check run for this annotation

Codecov / codecov/patch

providers/dell/idrac.go#L131-L132

Added lines #L131 - L132 were not covered by tests
}
return err
}

if !strings.Contains(strings.ToLower(manufacturer), common.VendorDell) {
if er := c.redfishwrapper.Close(ctx); er != nil {
return fmt.Errorf("%v: %w", err, er)

Check warning on line 139 in providers/dell/idrac.go

View check run for this annotation

Codecov / codecov/patch

providers/dell/idrac.go#L138-L139

Added lines #L138 - L139 were not covered by tests
}
return bmclibErrs.ErrIncompatibleProvider
}

Expand Down

0 comments on commit 422edc2

Please sign in to comment.