Skip to content

Commit a68ce42

Browse files
committed
Added the limitAggregateUsageOnResize configuration parameter for ONTAP
backends that support the limitAggregateUsage configuration parameter. If the limitAggregateUsageOnResize parameter is not set, the original behavior with the limitAggregateUsage parameter is used. If the limitAggregateUsageOnResize is configured, PVC expansion can be allowed at a different aggregate utilization threshold than PVC creation.
1 parent 508a137 commit a68ce42

File tree

8 files changed

+27
-15
lines changed

8 files changed

+27
-15
lines changed

storage_drivers/ontap/ontap_common.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,7 @@ const (
17601760
DefaultLuksEncryption = "false"
17611761
DefaultMirroring = "false"
17621762
DefaultLimitAggregateUsage = ""
1763+
DefaultLimitAggregateUsageOnResize = ""
17631764
DefaultLimitVolumeSize = ""
17641765
DefaultLimitVolumePoolSize = ""
17651766
DefaultDenyNewVolumePools = "false"
@@ -1962,6 +1963,7 @@ func PopulateConfigurationDefaults(ctx context.Context, config *drivers.OntapSto
19621963
"LUKSEncryption": config.LUKSEncryption,
19631964
"Mirroring": config.Mirroring,
19641965
"LimitAggregateUsage": config.LimitAggregateUsage,
1966+
"LimitAggregateUsageOnResize": config.LimitAggregateUsageOnResize,
19651967
"LimitVolumeSize": config.LimitVolumeSize,
19661968
"LimitVolumePoolSize": config.LimitVolumePoolSize,
19671969
"DenyNewVolumePools": config.DenyNewVolumePools,
@@ -2092,6 +2094,7 @@ func PopulateASAConfigurationDefaults(ctx context.Context, config *drivers.Ontap
20922094
"LUKSEncryption": config.LUKSEncryption,
20932095
"Mirroring": config.Mirroring,
20942096
"LimitAggregateUsage": config.LimitAggregateUsage,
2097+
"LimitAggregateUsageOnResize": config.LimitAggregateUsageOnResize,
20952098
"LimitVolumeSize": config.LimitVolumeSize,
20962099
"Size": config.Size,
20972100
"TieringPolicy": config.TieringPolicy,
@@ -2117,12 +2120,12 @@ func checkAggregateLimitsForFlexvol(
21172120
return fmt.Errorf("aggregate info not available from Flexvol %s", flexvol)
21182121
}
21192122

2120-
return checkAggregateLimits(ctx, volInfo.Aggregates[0], volInfo.SpaceReserve, requestedSizeInt, config,
2121-
client)
2123+
return checkAggregateLimits(ctx, volInfo.Aggregates[0], volInfo.SpaceReserve, requestedSizeInt, "resize",
2124+
config, client)
21222125
}
21232126

21242127
func checkAggregateLimits(
2125-
ctx context.Context, aggregate, spaceReserve string, requestedSizeInt uint64,
2128+
ctx context.Context, aggregate, spaceReserve string, requestedSizeInt uint64, checkType string,
21262129
config drivers.OntapStorageDriverConfig, client api.OntapAPI,
21272130
) error {
21282131
if aggregate == managedStoragePoolName {
@@ -2132,7 +2135,15 @@ func checkAggregateLimits(
21322135

21332136
requestedSize := float64(requestedSizeInt)
21342137

2138+
// checkType should be either "resize" or "create".
2139+
// Fall back to limitAggregateUsage for a resize if the
2140+
// limitAggregateUsageOnResize config is not set.
21352141
limitAggregateUsage := config.LimitAggregateUsage
2142+
if checkType != "" && checkType == "resize" {
2143+
if config.LimitAggregateUsageOnResize != "" {
2144+
limitAggregateUsage = config.LimitAggregateUsageOnResize
2145+
}
2146+
}
21362147
limitAggregateUsage = strings.Replace(limitAggregateUsage, "%", "", -1) // strip off any %
21372148

21382149
Logc(ctx).WithFields(LogFields{

storage_drivers/ontap/ontap_common_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ func TestCheckAggregateLimits(t *testing.T) {
641641
},
642642
).AnyTimes()
643643

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

647647
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -654,7 +654,7 @@ func TestCheckAggregateLimits(t *testing.T) {
654654
},
655655
).AnyTimes()
656656

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

660660
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -673,15 +673,15 @@ func TestCheckAggregateLimits(t *testing.T) {
673673
},
674674
).AnyTimes()
675675

676-
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
676+
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)
677677
assert.Nil(t, err)
678678

679679
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
680680
// negative case: aggregate name is empty
681681

682682
aggr = ""
683683

684-
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
684+
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)
685685

686686
assert.Error(t, err)
687687

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

696-
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
696+
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)
697697

698698
assert.Error(t, err)
699699

@@ -716,7 +716,7 @@ func TestCheckAggregateLimits(t *testing.T) {
716716
},
717717
).AnyTimes()
718718

719-
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
719+
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)
720720

721721
assert.Error(t, err)
722722

@@ -739,7 +739,7 @@ func TestCheckAggregateLimits(t *testing.T) {
739739
},
740740
).AnyTimes()
741741

742-
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), ontapConfig, mockOntapAPI)
742+
err = checkAggregateLimits(ctx, aggr, spaceReserve, uint64(requestedSizeInt), "create", ontapConfig, mockOntapAPI)
743743

744744
assert.Error(t, err)
745745
}

storage_drivers/ontap/ontap_nas.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ func (d *NASStorageDriver) Create(
389389
physicalPoolNames = append(physicalPoolNames, aggregate)
390390

391391
if aggrLimitsErr := checkAggregateLimits(
392-
ctx, aggregate, spaceReserve, sizeBytes, d.Config, d.GetAPI(),
392+
ctx, aggregate, spaceReserve, sizeBytes, "create", d.Config, d.GetAPI(),
393393
); aggrLimitsErr != nil {
394394
errMessage := fmt.Sprintf("ONTAP-NAS pool %s/%s; error: %v", storagePool.Name(), aggregate, aggrLimitsErr)
395395
Logc(ctx).Error(errMessage)

storage_drivers/ontap/ontap_nas_qtree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ func (d *NASQtreeStorageDriver) Create(
451451
physicalPoolNames = append(physicalPoolNames, aggregate)
452452

453453
if aggrLimitsErr := checkAggregateLimits(
454-
ctx, aggregate, spaceReserve, sizeBytes, d.Config, d.GetAPI(),
454+
ctx, aggregate, spaceReserve, sizeBytes, "create", d.Config, d.GetAPI(),
455455
); aggrLimitsErr != nil {
456456
errMessage := fmt.Sprintf("ONTAP-NAS-QTREE pool %s/%s; error: %v", storagePool.Name(), aggregate,
457457
aggrLimitsErr)

storage_drivers/ontap/ontap_san.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ func (d *SANStorageDriver) Create(
481481
physicalPoolNames = append(physicalPoolNames, aggregate)
482482

483483
if aggrLimitsErr := checkAggregateLimits(
484-
ctx, aggregate, spaceReserve, flexvolBufferSize, d.Config, d.GetAPI(),
484+
ctx, aggregate, spaceReserve, flexvolBufferSize, "create", d.Config, d.GetAPI(),
485485
); aggrLimitsErr != nil {
486486
errMessage := fmt.Sprintf("ONTAP-SAN pool %s/%s; error: %v", storagePool.Name(), aggregate, aggrLimitsErr)
487487
Logc(ctx).Error(errMessage)

storage_drivers/ontap/ontap_san_economy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ func (d *SANEconomyStorageDriver) Create(
587587
physicalPoolNames = append(physicalPoolNames, aggregate)
588588

589589
if aggrLimitsErr := checkAggregateLimits(
590-
ctx, aggregate, spaceReserve, sizeBytes, d.Config, d.GetAPI(),
590+
ctx, aggregate, spaceReserve, sizeBytes, "create", d.Config, d.GetAPI(),
591591
); aggrLimitsErr != nil {
592592
errMessage := fmt.Sprintf(
593593
"ONTAP-SAN-ECONOMY pool %s/%s; error: %v", storagePool.Name(), aggregate, aggrLimitsErr,

storage_drivers/ontap/ontap_san_nvme.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ func (d *NVMeStorageDriver) Create(
415415
physicalPoolNames = append(physicalPoolNames, aggregate)
416416

417417
if aggrLimitsErr := checkAggregateLimits(
418-
ctx, aggregate, spaceReserve, flexVolBufferSize, d.Config, d.GetAPI(),
418+
ctx, aggregate, spaceReserve, flexVolBufferSize, "create", d.Config, d.GetAPI(),
419419
); aggrLimitsErr != nil {
420420
errMessage := fmt.Sprintf("ONTAP-NVMe pool %s/%s; error: %v", storagePool.Name(), aggregate, aggrLimitsErr)
421421
Logc(ctx).Error(errMessage)

storage_drivers/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ type OntapStorageDriverConfig struct {
127127
CloneSplitDelay string `json:"cloneSplitDelay,omitempty"` // in seconds, default to 10
128128
NfsMountOptions string `json:"nfsMountOptions"`
129129
LimitAggregateUsage string `json:"limitAggregateUsage"`
130+
LimitAggregateUsageOnResize string `json:"limitAggregateUsageOnResize"`
130131
LimitVolumePoolSize string `json:"limitVolumePoolSize"`
131132
DenyNewVolumePools string `json:"denyNewVolumePools"`
132133
AutoExportPolicy bool `json:"autoExportPolicy"`

0 commit comments

Comments
 (0)