@@ -70,12 +70,14 @@ func GetStorageUpdateConfig(
70
70
// - Calculate currentDriveSize from the request. //
71
71
// - Calculate the requiredDriveCount for achieving the deltaCapacity. //
72
72
// - Find out if any rows from the decision matrix fit in our new configuration //
73
- // - Filter out the rows which do not have the same input.DriveType //
74
- // - Filter out rows which do not fit input.CurrentDriveSize in row.MinSize and row.MaxSize //
75
- // - Filter out rows which do not fit requiredDriveCount in row.InstanceMinDrives and row.InstanceMaxDrives //
73
+ // - Filter out the rows which do not have the same input.DriveType //
74
+ // - Filter out rows which do not fit input.CurrentDriveSize in row.MinSize and row.MaxSize //
75
+ // - Filter out rows which do not fit requiredDriveCount in row.InstanceMinDrives and row.InstanceMaxDrives //
76
+ //
76
77
// - Pick the 1st row from the decision matrix as your candidate. //
77
78
// - If no row found: //
78
- // - failed to AddDisk //
79
+ // - failed to AddDisk //
80
+ //
79
81
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
80
82
func AddDisk (
81
83
request * cloudops.StoragePoolUpdateRequest ,
@@ -173,9 +175,10 @@ func AddDisk(
173
175
// - Sort the rows by IOPS //
174
176
// - First row in the filtered decision matrix is our best candidate. //
175
177
// - If input.CurrentDriveSize + deltaCapacityPerDrive > row.MaxSize: //
176
- // - failed to expand //
177
- // Else //
178
- // - success //
178
+ // - failed to expand //
179
+ // Else //
180
+ // - success //
181
+ //
179
182
// ////////////////////////////////////////////////////////////////////////////////////////////////
180
183
func ResizeDisk (
181
184
request * cloudops.StoragePoolUpdateRequest ,
@@ -267,31 +270,34 @@ func calculateDriveCapacity(request *cloudops.StoragePoolUpdateRequest) uint64 {
267
270
// to achieve this:
268
271
//
269
272
// ////////////////////////////////////////////////////////////////////////////
270
- // - Calculate minCapacityPerZone = input.MinCapacity / zoneCount //
271
- // - Calculate maxCapacityPerZone = input.MaxCapacity / zoneCount //
272
- // - Filter the decision matrix based of our requirements: //
273
- // - Filter out the rows which do not have the same input.DriveType //
274
- // - Filter out the rows which do not meet input.IOPS //
275
- // - Sort the decision matrix by IOPS //
276
- // - Sort the decision matrix by Priority //
277
- // - instancesPerZone = input.RequestedInstancesPerZone //
278
- // - (row_loop) For each of the filtered row: //
279
- // - (instances_per_zone_loop) For instancesPerZone > 0: //
273
+ // - Calculate minCapacityPerZone = input.MinCapacity / zoneCount //
274
+ // - Calculate maxCapacityPerZone = input.MaxCapacity / zoneCount //
275
+ // - Filter the decision matrix based of our requirements: //
276
+ // - Filter out the rows which do not have the same input.DriveType //
277
+ // - Filter out the rows which do not meet input.IOPS //
278
+ // - Sort the decision matrix by IOPS //
279
+ // - Sort the decision matrix by Priority //
280
+ //
281
+ // - instancesPerZone = input.RequestedInstancesPerZone //
282
+ // - (row_loop) For each of the filtered row: //
283
+ // - (instances_per_zone_loop) For instancesPerZone > 0: //
280
284
// - Find capacityPerNode = minCapacityPerZone / instancesPerZone //
281
285
// - (drive_count_loop) For driveCount > row.InstanceMinDrives: //
282
- // - driveSize = capacityPerNode / driveCount //
283
- // - If driveSize within row.MinSize and row.MaxSize: //
284
- // break drive_count_loop (Found candidate) //
285
- // - If (drive_count_loop) fails/exhausts: //
286
- // - reduce instancesPerZone by 1 //
287
- // - goto (instances_per_zone_loop) //
288
- // Else found candidate //
289
- // - break instances_per_zone_loop (Found candidate) //
290
- // - If (instances_per_zone_loop) fails: //
291
- // - Try the next filtered row //
292
- // - goto (row_loop) //
293
- // - If (row_loop) fails: //
294
- // - failed to get a candidate //
286
+ // - driveSize = capacityPerNode / driveCount //
287
+ // - If driveSize within row.MinSize and row.MaxSize: //
288
+ // break drive_count_loop (Found candidate) //
289
+ // - If (drive_count_loop) fails/exhausts: //
290
+ // - reduce instancesPerZone by 1 //
291
+ // - goto (instances_per_zone_loop) //
292
+ // Else found candidate //
293
+ // - break instances_per_zone_loop (Found candidate) //
294
+ // - If (instances_per_zone_loop) fails: //
295
+ // - Try the next filtered row //
296
+ // - goto (row_loop) //
297
+ //
298
+ // - If (row_loop) fails: //
299
+ // - failed to get a candidate //
300
+ //
295
301
// ////////////////////////////////////////////////////////////////////////////
296
302
func GetStorageDistributionForPool (
297
303
decisionMatrix * cloudops.StorageDecisionMatrix ,
@@ -396,6 +402,39 @@ row_loop:
396
402
397
403
}
398
404
405
+ // GetMaxDriveSize returns the max drive size given an input
406
+ // cloud drive type
407
+ // Filter out rows matching input drive type
408
+ // Process the rows to find the max size
409
+ func GetMaxDriveSize (
410
+ request * cloudops.MaxDriveSizeRequest ,
411
+ decisionMatrix * cloudops.StorageDecisionMatrix ,
412
+ ) (* cloudops.MaxDriveSizeResponse , error ) {
413
+ logMaxDriveSizeRequest (request )
414
+
415
+ if len (request .DriveType ) == 0 {
416
+ return nil , & cloudops.ErrInvalidMaxDriveSizeRequest {
417
+ Request : request ,
418
+ Reason : "empty drive type" ,
419
+ }
420
+ }
421
+
422
+ dm := utils .CopyDecisionMatrix (decisionMatrix )
423
+
424
+ // Filter the decision matrix rows based on the input request
425
+ dm .FilterByDriveType (request .DriveType ).SortByMaxSize ()
426
+ if len (dm .Rows ) == 0 {
427
+ return nil , & cloudops.ErrMaxDriveSizeCandidateNotFound {
428
+ Request : request ,
429
+ Reason : "no matching inputs found for input drive type" ,
430
+ }
431
+ }
432
+
433
+ return & cloudops.MaxDriveSizeResponse {
434
+ MaxSize : dm .Rows [0 ].MaxSize ,
435
+ }, nil
436
+ }
437
+
399
438
// validateUpdateRequest validates the StoragePoolUpdateRequest
400
439
func validateUpdateRequest (
401
440
request * cloudops.StoragePoolUpdateRequest ,
@@ -470,3 +509,11 @@ func logUpdateRequest(
470
509
"OperationType" : request .ResizeOperationType ,
471
510
}).Debugf ("-- Storage Distribution Pool Update Request --" )
472
511
}
512
+
513
+ func logMaxDriveSizeRequest (
514
+ request * cloudops.MaxDriveSizeRequest ,
515
+ ) {
516
+ logrus .WithFields (logrus.Fields {
517
+ "DriveType" : request .DriveType ,
518
+ }).Debugf ("-- Get Max Drive Size request --" )
519
+ }
0 commit comments