Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: mssql_elasticpool max_size_bytes to max_size_gb #2695

Merged
merged 46 commits into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
6c4a9c0
WIP: Initial check-in for max_size_gb
WodansSon Jan 16, 2019
e6a2bd3
Finished adding validation for Elasticpool max_size_gb
WodansSon Jan 17, 2019
615fd79
Added additional SKU check and updated docs
WodansSon Jan 17, 2019
8fcfb4a
Updated tests to use max_size_gb
WodansSon Jan 17, 2019
6ba0752
fix lint errors
WodansSon Jan 17, 2019
3ccc0b4
Added additional Standard and Premium size check
WodansSon Jan 18, 2019
706e7a7
Switched logic to use maps instead
WodansSon Jan 18, 2019
541ee9e
Added values to error msgs
WodansSon Jan 18, 2019
92cd03a
fix format casing
WodansSon Jan 18, 2019
8289782
Addressed PR comments and updated some func names
WodansSon Jan 18, 2019
028c5b1
Fixed lint errors and remove helper function
WodansSon Jan 18, 2019
ee38137
Fixed test issue
WodansSon Jan 19, 2019
9635e5c
Had to special case Basic tier for setting max_size_gb
WodansSon Jan 19, 2019
4b2a43f
Added Name Tier combo validation
WodansSon Jan 24, 2019
9b5352e
Updated to auto-fill tier based of name attribute
WodansSon Jan 24, 2019
0b5dd6d
Added auto-fill attributes for Tier and Family
WodansSon Jan 25, 2019
8a86194
Added Test cases for DTU and vCore autofill
WodansSon Jan 25, 2019
2c4cb79
Update for lint errors
WodansSon Jan 25, 2019
a589be8
Update tests
WodansSon Jan 25, 2019
41f04b5
Fixed test cases
WodansSon Jan 25, 2019
0507be0
Fix Lint error
WodansSon Jan 25, 2019
08522c4
Updated GetOkExists to GetOk
WodansSon Jan 25, 2019
70d8638
Revert Auto-fill functionality
WodansSon Jan 25, 2019
807aa42
Merge branch 'master' into refactor-elasticpool-maxsize
WodansSon Jan 25, 2019
dd7d968
Fixing up after merge from master
WodansSon Jan 25, 2019
eb2f5d2
Fix lint errors
WodansSon Jan 25, 2019
faf2c8e
Removed commented code
WodansSon Jan 25, 2019
39f4113
Exposed max_size_bytes, updated documentation, and added test case
WodansSon Jan 29, 2019
0ab8771
Update azurerm/resource_arm_mssql_elasticpool.go
katbyte Jan 30, 2019
f4b805c
Fixes for PR comments
WodansSon Jan 31, 2019
544b19a
Updated GetTierFromSKUName to use map
WodansSon Jan 31, 2019
347f83d
Updated error msg for clarity
WodansSon Jan 31, 2019
3421bff
Switch to using nested maps
WodansSon Jan 31, 2019
ab9c67a
Updated errors to be dynamically generated
WodansSon Feb 1, 2019
66ac53b
Added descriptions of maps
WodansSon Feb 1, 2019
98eb1d3
Unifying func signatures
WodansSon Feb 1, 2019
d397373
Removed unneeded validation check
WodansSon Feb 1, 2019
5994856
Updated name and family validation
WodansSon Feb 1, 2019
be8580b
Fixed issue due to code editor auto-complete
WodansSon Feb 1, 2019
2e3809b
Changed to Errorf
WodansSon Feb 1, 2019
6933c4b
Update for edge case
WodansSon Feb 2, 2019
0bd9ea7
Updated map to get better code reuse
WodansSon Feb 2, 2019
321139f
Missed a space
WodansSon Feb 2, 2019
56ecf29
Fix lint error
WodansSon Feb 2, 2019
857797e
broke doSKUValidation into two seperate functions
katbyte Feb 5, 2019
9d69371
fix linting
katbyte Feb 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
197 changes: 197 additions & 0 deletions azurerm/helpers/azure/elasticpool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
package azure

import (
"math"
"strings"
)

var basicMaxSize = map[int]float64{
50: 4.8828125,
100: 9.765625,
200: 19.53125,
300: 29.296875,
400: 39.0625,
800: 78.125,
1200: 117.1875,
1600: 156.25,
}

var standardMaxSize = map[int]float64{
50: 500,
100: 750,
200: 1024,
300: 1280,
400: 1536,
800: 2048,
1200: 2560,
1600: 3072,
2000: 3584,
2500: 4096,
3000: 4096,
}

var premiumMaxSize = map[int]float64{
125: 1024,
250: 1024,
500: 1024,
1000: 1024,
1500: 1536,
2000: 2048,
2500: 2560,
3000: 3072,
3500: 3584,
4000: 4096,
}

var supportedDTUMaxGBValues = map[float64]bool{
50: true,
100: true,
150: true,
200: true,
250: true,
300: true,
400: true,
500: true,
750: true,
800: true,
1024: true,
1200: true,
1280: true,
1536: true,
1600: true,
1792: true,
2000: true,
2048: true,
2304: true,
2500: true,
2560: true,
2816: true,
3000: true,
3072: true,
3328: true,
3584: true,
3840: true,
4096: true,
}

var generalPurposeGen4MaxGB = map[int]float64{
1: 512,
2: 756,
3: 1536,
4: 1536,
5: 1536,
6: 2048,
7: 2048,
8: 2048,
9: 2048,
10: 2048,
16: 3584,
24: 4096,
}

var generalPurposeGen5MaxGB = map[int]float64{
2: 512,
4: 756,
6: 1536,
8: 1536,
10: 1536,
12: 2048,
14: 2048,
16: 2048,
18: 3072,
20: 3072,
24: 3072,
32: 4096,
40: 4096,
80: 4096,
}

var businessCriticalGen4MaxGB = map[int]float64{
2: 1024,
3: 1024,
4: 1024,
5: 1024,
6: 1024,
7: 1024,
8: 1024,
9: 1024,
10: 1024,
16: 1024,
24: 1024,
}

var businessCriticalGen5MaxGB = map[int]float64{
4: 1024,
6: 1536,
8: 1536,
10: 1536,
12: 3072,
14: 3072,
16: 3072,
18: 3072,
20: 3072,
24: 4096,
32: 4096,
40: 4096,
80: 4096,
}

func BasicGetMaxSizeGB(DTUs int) float64 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a bit more specific of name:

Suggested change
func BasicGetMaxSizeGB(DTUs int) float64 {
func MSSQLElasticPoolBasicGetMaxSizeGB(DTUs int) float64 {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

return basicMaxSize[DTUs]
}

func StandardGetMaxSizeGB(DTUs int) float64 {
return standardMaxSize[DTUs]
}

func PremiumGetMaxSizeGB(DTUs int) float64 {
return premiumMaxSize[DTUs]
}

func StantardPremiumMaxGBValid(gb float64) bool {
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
return supportedDTUMaxGBValues[gb]
}

func GeneralPurposeGetMaxSizeGB(vCores int, family string) float64 {

if family == "gen4" {
return generalPurposeGen4MaxGB[vCores]
}

if family == "gen5" {
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
return generalPurposeGen5MaxGB[vCores]
}

// Invalid family
return -1
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
}

func BusinessCriticalGetMaxSizeGB(vCores int, family string) float64 {

if family == "gen4" {
return businessCriticalGen4MaxGB[vCores]
}

if family == "gen5" {
return businessCriticalGen5MaxGB[vCores]
}

// Invalid family
return -1
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
}

func IsIntAsBytes(maxSizeGB float64) bool {
// Get the maxSizeGB for the value in bytes
max := 1073741824 * maxSizeGB

// Check to see if the resulting max_size_bytes value is an integral value
if max != math.Trunc(max) {
return false
}

return true
}

func NameFamilyValid(name string, family string) bool {
return strings.Contains(strings.ToLower(name), strings.ToLower(family))
}