Skip to content

Commit

Permalink
1.1.2 Functional Test Fix (#108)
Browse files Browse the repository at this point in the history
- When reading all of the volumes or volume snapshots in there
  respective datasources. If the array is used heavly sometimes there
  are stale ids. For these cases we should ignore the error and return
  what we can.
  • Loading branch information
doriac11 authored Mar 22, 2024
1 parent 6b854b8 commit 0d4421d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions powerstore/datasource_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package powerstore

import (
"context"
"strings"
"terraform-provider-powerstore/client"
"terraform-provider-powerstore/models"

Expand Down Expand Up @@ -431,13 +432,25 @@ func updateVolumeState(volumes []gopowerstore.Volume, p *client.Client) (respons
size, unit := convertFromBytes(volumeValue.Size)
hostMapping, err := p.PStoreClient.GetHostVolumeMappingByVolumeID(context.Background(), volumeValue.ID)
if err != nil {
// Ignore the error if the volume cannot be found by id. Instead just continue.
// This could be a failure that happens with alot of volumes and stale ids are in the cache.
// In this case we should still return all volumes that are valid to the user
if strings.Contains(err.Error(), "was not found.") {
continue
}
return nil, err
}
if len(hostMapping) > 0 {
hostID, hostGroupID, logicalUnit = hostMapping[0].HostID, hostMapping[0].HostGroupID, hostMapping[0].LogicalUnitNumber
}
volGroupMapping, err := p.PStoreClient.GetVolumeGroupsByVolumeID(context.Background(), volumeValue.ID)
if err != nil {
// Ignore the error if the volume cannot be found by id. Instead just continue.
// This could be a failure that happens with alot of volumes and stale ids are in the cache.
// In this case we should still return all volumes that are valid to the user
if strings.Contains(err.Error(), "was not found.") {
continue
}
return nil, err
}
if len(volGroupMapping.VolumeGroup) > 0 {
Expand Down

0 comments on commit 0d4421d

Please sign in to comment.