Skip to content

Commit

Permalink
Added FSx personality to ontap-nas-flexgroup, ontap-san (iscsi and nv…
Browse files Browse the repository at this point in the history
…me), ontap-san-economy, ontap-nas-economy drivers

Signed-off-by: galrabiniovich <galr@netapp.com>
  • Loading branch information
galrabiniovich authored Nov 9, 2023
1 parent 06ac133 commit 6506551
Show file tree
Hide file tree
Showing 11 changed files with 435 additions and 98 deletions.
48 changes: 24 additions & 24 deletions storage_drivers/ontap/ontap_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
// }

func NewAPIResponse(
client, version, status, reason, errno string,
_, _, status, reason, errno string,
) *api.APIResponse {
return api.NewAPIResponse(status, reason, errno)
}
Expand Down Expand Up @@ -1183,7 +1183,7 @@ func TestValidateStoragePools_Valid_OntapNAS(t *testing.T) {
mockCtrl = gomock.NewController(t)
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)
mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")
storageDriverSAN := newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, true, mockAPI)
storageDriverSAN := newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, true, nil, mockAPI)
physicalPools = map[string]storage.Pool{}
virtualPools = map[string]storage.Pool{"test": getValidOntapSANPool()}
storageDriver.virtualPools = virtualPools
Expand All @@ -1200,7 +1200,7 @@ func TestValidateStoragePools_Valid_OntapNAS(t *testing.T) {
mockCtrl = gomock.NewController(t)
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)
mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")
storageDriverSAN = newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, true, mockAPI)
storageDriverSAN = newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, true, nil, mockAPI)
physicalPools = map[string]storage.Pool{}
virtualPools = map[string]storage.Pool{"test": getValidOntapSANPool()}
storageDriver.virtualPools = virtualPools
Expand All @@ -1217,7 +1217,7 @@ func TestValidateStoragePools_Valid_OntapNAS(t *testing.T) {
mockCtrl = gomock.NewController(t)
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)
mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")
storageDriverSAN = newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, true, mockAPI)
storageDriverSAN = newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, true, nil, mockAPI)
physicalPools = map[string]storage.Pool{}
virtualPools = map[string]storage.Pool{"test": getValidOntapSANPool()}
storageDriver.virtualPools = virtualPools
Expand All @@ -1233,7 +1233,7 @@ func TestValidateStoragePools_Valid_OntapNAS(t *testing.T) {
mockCtrl = gomock.NewController(t)
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)
mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")
storageDriverSAN = newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, true, mockAPI)
storageDriverSAN = newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, true, nil, mockAPI)
physicalPools = map[string]storage.Pool{}
virtualPools = map[string]storage.Pool{"test": getValidOntapSANPool()}
storageDriver.virtualPools = virtualPools
Expand All @@ -1255,7 +1255,7 @@ func TestValidateStoragePools_LUKS(t *testing.T) {
mockAPI := mockapi.NewMockOntapAPI(mockCtrl)

mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")
sanStorageDriver := newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, false, mockAPI)
sanStorageDriver := newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, false, nil, mockAPI)
pool := getValidOntapSANPool()
pool.InternalAttributes()[LUKSEncryption] = "true"
physicalPools := map[string]storage.Pool{}
Expand All @@ -1271,7 +1271,7 @@ func TestValidateStoragePools_LUKS(t *testing.T) {
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)

mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")
sanEcoStorageDriver := newTestOntapSanEcoDriver(vserverAdminHost, "443", vserverAggrName, false, mockAPI)
sanEcoStorageDriver := newTestOntapSanEcoDriver(vserverAdminHost, "443", vserverAggrName, false, nil, mockAPI)
pool = getValidOntapSANPool()
pool.InternalAttributes()[LUKSEncryption] = "true"
physicalPools = map[string]storage.Pool{}
Expand Down Expand Up @@ -1300,7 +1300,7 @@ func TestValidateStoragePools_LUKS(t *testing.T) {
mockAPI = mockapi.NewMockOntapAPI(mockCtrl)

mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")
sanStorageDriver = newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, false, mockAPI)
sanStorageDriver = newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName, false, nil, mockAPI)
pool = getValidOntapSANPool()
pool.InternalAttributes()[LUKSEncryption] = "invalid-not-a-bool"
physicalPools = map[string]storage.Pool{}
Expand Down Expand Up @@ -2657,11 +2657,11 @@ func TestIsDefaultAuthTypeDeny(t *testing.T) {
assert.False(t, actual)
}

func mockValidate(ctx context.Context) error {
func mockValidate(_ context.Context) error {
return nil
}

func mockValidate_Error(ctx context.Context) error {
func mockValidate_Error(_ context.Context) error {
return fmt.Errorf("Error while validating")
}

Expand Down Expand Up @@ -3539,27 +3539,27 @@ func TestGoString(t *testing.T) {
assert.Equal(t, expected, result)
}

func mockVolumeExists(ctx context.Context, name string) (bool, error) {
func mockVolumeExists(_ context.Context, _ string) (bool, error) {
return true, nil
}

func mockVolumeSize(ctx context.Context, name string) (uint64, error) {
func mockVolumeSize(_ context.Context, _ string) (uint64, error) {
return 1024, nil
}

func mockVolumeExistsError(ctx context.Context, name string) (bool, error) {
func mockVolumeExistsError(_ context.Context, _ string) (bool, error) {
return true, fmt.Errorf("VolumeExistsError")
}

func mockVolumeSizeError(ctx context.Context, name string) (uint64, error) {
func mockVolumeSizeError(_ context.Context, _ string) (uint64, error) {
return 1024, fmt.Errorf("VolumeSizeError")
}

func mockVolumeSizeLarger(ctx context.Context, name string) (uint64, error) {
func mockVolumeSizeLarger(_ context.Context, _ string) (uint64, error) {
return 10000, nil
}

func mockVolumeInfo(ctx context.Context, name string) (*api.Volume, error) {
func mockVolumeInfo(_ context.Context, name string) (*api.Volume, error) {
return &api.Volume{
Name: name,
SnapshotPolicy: "fakePolicy",
Expand Down Expand Up @@ -4643,7 +4643,7 @@ func TestDiscoverBackendAggrNamesCommon(t *testing.T) {
mockAPI.EXPECT().GetSVMAggregateNames(ctx).Return([]string{}, nil)
mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")
storageDriver := newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName,
false, mockAPI)
false, nil, mockAPI)

aggr, err := discoverBackendAggrNamesCommon(ctx, storageDriver)

Expand All @@ -4656,7 +4656,7 @@ func TestDiscoverBackendAggrNamesCommon(t *testing.T) {
nil)
mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")
storageDriver = newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName,
false, mockAPI)
false, nil, mockAPI)
expected := ONTAPTEST_VSERVER_AGGR_NAME

aggr, err = discoverBackendAggrNamesCommon(ctx, storageDriver)
Expand All @@ -4669,19 +4669,19 @@ func TestDiscoverBackendAggrNamesCommon(t *testing.T) {
mockAPI.EXPECT().GetSVMAggregateNames(ctx).Return([]string{}, nil).Return([]string{"aggr1"}, nil)
mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")
storageDriver = newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName,
false, mockAPI)
false, nil, mockAPI)

aggr, err = discoverBackendAggrNamesCommon(ctx, storageDriver)

assert.Nil(t, aggr, "Expected no aggregate")
assert.Error(t, err)
}

func mockCloneSplitStart(ctx context.Context, cloneName string) error {
func mockCloneSplitStart(_ context.Context, _ string) error {
return nil
}

func mockCloneSplitStart_error(ctx context.Context, cloneName string) error {
func mockCloneSplitStart_error(_ context.Context, _ string) error {
return fmt.Errorf("CloneSplitStart returned error")
}

Expand Down Expand Up @@ -4776,7 +4776,7 @@ func TestGetVserverAggrAttributes(t *testing.T) {
mockAPI := mockapi.NewMockOntapAPI(mockCtrl)
mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")
storageDriver := newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName,
false, mockAPI)
false, nil, mockAPI)

pool1 := storage.NewStoragePool(nil, "dummyPool1")
pool1.Attributes()[sa.BackendType] = sa.NewStringOffer("dummyBackend")
Expand Down Expand Up @@ -4835,7 +4835,7 @@ func TestInitializeStoragePoolsCommon(t *testing.T) {
mockAPI.EXPECT().SVMName().AnyTimes().Return("SVM1")

storageDriver := newTestOntapSANDriver(vserverAdminHost, "443", vserverAggrName,
false, mockAPI)
false, nil, mockAPI)
storageDriver.Config.Aggregate = ""
pool1 := storage.NewStoragePool(nil, "dummyPool1")
pool1.Attributes()[sa.Media] = sa.NewStringOffer("hdd")
Expand Down Expand Up @@ -5147,7 +5147,7 @@ func TestNewOntapTelemetry(t *testing.T) {
assert.Equal(t, storageDriver.Name(), telemetry.Plugin)
}

func MockGetVolumeInfo(ctx context.Context, volName string) (volume *api.Volume, err error) {
func MockGetVolumeInfo(_ context.Context, volName string) (volume *api.Volume, err error) {
volume = &api.Volume{
Name: volName,
SnapshotPolicy: "fakePolicy",
Expand Down
22 changes: 22 additions & 0 deletions storage_drivers/ontap/ontap_nas_flexgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
drivers "github.com/netapp/trident/storage_drivers"
"github.com/netapp/trident/storage_drivers/ontap/api"
"github.com/netapp/trident/storage_drivers/ontap/api/azgo"
"github.com/netapp/trident/storage_drivers/ontap/awsapi"
"github.com/netapp/trident/utils"
"github.com/netapp/trident/utils/errors"
)
Expand All @@ -32,6 +33,7 @@ type NASFlexGroupStorageDriver struct {
initialized bool
Config drivers.OntapStorageDriverConfig
API api.OntapAPI
AWSAPI awsapi.AWSAPI
telemetry *Telemetry

physicalPool storage.Pool
Expand Down Expand Up @@ -87,6 +89,16 @@ func (d *NASFlexGroupStorageDriver) Initialize(
}
d.Config = *config

// Initialize AWS API if applicable.
// Unit tests mock the API layer, so we only use the real API interface if it doesn't already exist.
if d.AWSAPI == nil {
d.AWSAPI, err = initializeAWSDriver(ctx, config)
if err != nil {
return fmt.Errorf("error initializing %s AWS driver; %v", d.Name(), err)
}
}

// Initialize the ONTAP API.
// Unit tests mock the API layer, so we only use the real API interface if it doesn't already exist.
if d.API == nil {
d.API, err = InitializeOntapDriver(ctx, config)
Expand Down Expand Up @@ -976,6 +988,16 @@ func (d *NASFlexGroupStorageDriver) Destroy(ctx context.Context, volConfig *stor
Logd(ctx, d.Name(), d.Config.DebugTraceFlags["method"]).WithFields(fields).Trace(">>>> Destroy")
defer Logd(ctx, d.Name(), d.Config.DebugTraceFlags["method"]).WithFields(fields).Trace("<<<< Destroy")

// If volume exists and this is FSx, try the FSx SDK first so that any backup mirror relationship
// is cleaned up. If the volume isn't found, then FSx may not know about it yet, so just try the
// underlying ONTAP delete call. Any race condition with FSx will be resolved on a retry.
if d.AWSAPI != nil {
err := destroyFSxVolume(ctx, d.AWSAPI, volConfig, &d.Config)
if err == nil || !errors.IsNotFoundError(err) {
return err
}
}

// This call is async, but we will receive an immediate error back for anything but very rare volume deletion
// failures. Failures in this category are almost certainly likely to be beyond our capability to fix or even
// diagnose, so we defer to the ONTAP cluster admin
Expand Down
Loading

0 comments on commit 6506551

Please sign in to comment.