Skip to content
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
17 changes: 14 additions & 3 deletions storage_drivers/ontap/ontap_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,7 @@ const (
DefaultLuksEncryption = "false"
DefaultMirroring = "false"
DefaultLimitAggregateUsage = ""
DefaultLimitAggregateUsageOnResize = ""
DefaultLimitVolumeSize = ""
DefaultLimitVolumePoolSize = ""
DefaultDenyNewVolumePools = "false"
Expand Down Expand Up @@ -1962,6 +1963,7 @@ func PopulateConfigurationDefaults(ctx context.Context, config *drivers.OntapSto
"LUKSEncryption": config.LUKSEncryption,
"Mirroring": config.Mirroring,
"LimitAggregateUsage": config.LimitAggregateUsage,
"LimitAggregateUsageOnResize": config.LimitAggregateUsageOnResize,
"LimitVolumeSize": config.LimitVolumeSize,
"LimitVolumePoolSize": config.LimitVolumePoolSize,
"DenyNewVolumePools": config.DenyNewVolumePools,
Expand Down Expand Up @@ -2092,6 +2094,7 @@ func PopulateASAConfigurationDefaults(ctx context.Context, config *drivers.Ontap
"LUKSEncryption": config.LUKSEncryption,
"Mirroring": config.Mirroring,
"LimitAggregateUsage": config.LimitAggregateUsage,
"LimitAggregateUsageOnResize": config.LimitAggregateUsageOnResize,
"LimitVolumeSize": config.LimitVolumeSize,
"Size": config.Size,
"TieringPolicy": config.TieringPolicy,
Expand All @@ -2117,12 +2120,12 @@ func checkAggregateLimitsForFlexvol(
return fmt.Errorf("aggregate info not available from Flexvol %s", flexvol)
}

return checkAggregateLimits(ctx, volInfo.Aggregates[0], volInfo.SpaceReserve, requestedSizeInt, config,
client)
return checkAggregateLimits(ctx, volInfo.Aggregates[0], volInfo.SpaceReserve, requestedSizeInt, "resize",
config, client)
}

func checkAggregateLimits(
ctx context.Context, aggregate, spaceReserve string, requestedSizeInt uint64,
ctx context.Context, aggregate, spaceReserve string, requestedSizeInt uint64, checkType string,
config drivers.OntapStorageDriverConfig, client api.OntapAPI,
) error {
if aggregate == managedStoragePoolName {
Expand All @@ -2132,7 +2135,15 @@ func checkAggregateLimits(

requestedSize := float64(requestedSizeInt)

// checkType should be either "resize" or "create".
// Fall back to limitAggregateUsage for a resize if the
// limitAggregateUsageOnResize config is not set.
limitAggregateUsage := config.LimitAggregateUsage
if checkType != "" && checkType == "resize" {
if config.LimitAggregateUsageOnResize != "" {
limitAggregateUsage = config.LimitAggregateUsageOnResize
}
}
limitAggregateUsage = strings.Replace(limitAggregateUsage, "%", "", -1) // strip off any %

Logc(ctx).WithFields(LogFields{
Expand Down
14 changes: 7 additions & 7 deletions storage_drivers/ontap/ontap_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ func TestCheckAggregateLimits(t *testing.T) {
},
).AnyTimes()

err := checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
err := checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)
assert.Equal(t, "could not find aggregate, cannot check aggregate provisioning limits for aggr1", err.Error())

// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -654,7 +654,7 @@ func TestCheckAggregateLimits(t *testing.T) {
},
).AnyTimes()

err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)
assert.Equal(t, "could not find aggregate, cannot check aggregate provisioning limits for aggr1", err.Error())

// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -673,15 +673,15 @@ func TestCheckAggregateLimits(t *testing.T) {
},
).AnyTimes()

err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)
assert.Nil(t, err)

// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
// negative case: aggregate name is empty

aggr = ""

err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)

assert.Error(t, err)

Expand All @@ -693,7 +693,7 @@ func TestCheckAggregateLimits(t *testing.T) {
mockOntapAPI.EXPECT().GetSVMAggregateSpace(gomock.Any(), aggr).Return([]api.SVMAggregateSpace{},
errors.New("GetSVMAggregateSpace returned error"))

err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)

assert.Error(t, err)

Expand All @@ -716,7 +716,7 @@ func TestCheckAggregateLimits(t *testing.T) {
},
).AnyTimes()

err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)

assert.Error(t, err)

Expand All @@ -739,7 +739,7 @@ func TestCheckAggregateLimits(t *testing.T) {
},
).AnyTimes()

err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)

assert.Error(t, err)
}
Expand Down
2 changes: 1 addition & 1 deletion storage_drivers/ontap/ontap_nas.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func (d *NASStorageDriver) Create(
physicalPoolNames = append(physicalPoolNames, aggregate)

if aggrLimitsErr := checkAggregateLimits(
ctx, aggregate, spaceReserve, sizeBytes, d.Config, d.GetAPI(),
ctx, aggregate, spaceReserve, sizeBytes, "create", d.Config, d.GetAPI(),
); aggrLimitsErr != nil {
errMessage := fmt.Sprintf("ONTAP-NAS pool %s/%s; error: %v", storagePool.Name(), aggregate, aggrLimitsErr)
Logc(ctx).Error(errMessage)
Expand Down
2 changes: 1 addition & 1 deletion storage_drivers/ontap/ontap_nas_qtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func (d *NASQtreeStorageDriver) Create(
physicalPoolNames = append(physicalPoolNames, aggregate)

if aggrLimitsErr := checkAggregateLimits(
ctx, aggregate, spaceReserve, sizeBytes, d.Config, d.GetAPI(),
ctx, aggregate, spaceReserve, sizeBytes, "create", d.Config, d.GetAPI(),
); aggrLimitsErr != nil {
errMessage := fmt.Sprintf("ONTAP-NAS-QTREE pool %s/%s; error: %v", storagePool.Name(), aggregate,
aggrLimitsErr)
Expand Down
2 changes: 1 addition & 1 deletion storage_drivers/ontap/ontap_san.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func (d *SANStorageDriver) Create(
physicalPoolNames = append(physicalPoolNames, aggregate)

if aggrLimitsErr := checkAggregateLimits(
ctx, aggregate, spaceReserve, flexvolBufferSize, d.Config, d.GetAPI(),
ctx, aggregate, spaceReserve, flexvolBufferSize, "create", d.Config, d.GetAPI(),
); aggrLimitsErr != nil {
errMessage := fmt.Sprintf("ONTAP-SAN pool %s/%s; error: %v", storagePool.Name(), aggregate, aggrLimitsErr)
Logc(ctx).Error(errMessage)
Expand Down
2 changes: 1 addition & 1 deletion storage_drivers/ontap/ontap_san_economy.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ func (d *SANEconomyStorageDriver) Create(
physicalPoolNames = append(physicalPoolNames, aggregate)

if aggrLimitsErr := checkAggregateLimits(
ctx, aggregate, spaceReserve, sizeBytes, d.Config, d.GetAPI(),
ctx, aggregate, spaceReserve, sizeBytes, "create", d.Config, d.GetAPI(),
); aggrLimitsErr != nil {
errMessage := fmt.Sprintf(
"ONTAP-SAN-ECONOMY pool %s/%s; error: %v", storagePool.Name(), aggregate, aggrLimitsErr,
Expand Down
2 changes: 1 addition & 1 deletion storage_drivers/ontap/ontap_san_nvme.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func (d *NVMeStorageDriver) Create(
physicalPoolNames = append(physicalPoolNames, aggregate)

if aggrLimitsErr := checkAggregateLimits(
ctx, aggregate, spaceReserve, flexVolBufferSize, d.Config, d.GetAPI(),
ctx, aggregate, spaceReserve, flexVolBufferSize, "create", d.Config, d.GetAPI(),
); aggrLimitsErr != nil {
errMessage := fmt.Sprintf("ONTAP-NVMe pool %s/%s; error: %v", storagePool.Name(), aggregate, aggrLimitsErr)
Logc(ctx).Error(errMessage)
Expand Down
1 change: 1 addition & 0 deletions storage_drivers/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ type OntapStorageDriverConfig struct {
CloneSplitDelay string `json:"cloneSplitDelay,omitempty"` // in seconds, default to 10
NfsMountOptions string `json:"nfsMountOptions"`
LimitAggregateUsage string `json:"limitAggregateUsage"`
LimitAggregateUsageOnResize string `json:"limitAggregateUsageOnResize"`
LimitVolumePoolSize string `json:"limitVolumePoolSize"`
DenyNewVolumePools string `json:"denyNewVolumePools"`
AutoExportPolicy bool `json:"autoExportPolicy"`
Expand Down
Loading