Skip to content

Commit

Permalink
OCM-9876 | feat: enable custom worker disk sizes on node pools
Browse files Browse the repository at this point in the history
Signed-off-by: wkutler <willkutler@gmail.com>
  • Loading branch information
willkutler committed Aug 30, 2024
1 parent a3f69c8 commit a01e0a5
Show file tree
Hide file tree
Showing 187 changed files with 64,580 additions and 36,146 deletions.
66 changes: 42 additions & 24 deletions cmd/create/cluster/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4128,24 +4128,27 @@ func getSecurityGroups(r *rosa.Runtime, cmd *cobra.Command, isVersionCompatibleC

func getMachinePoolRootDisk(r *rosa.Runtime, cmd *cobra.Command, version string,
isHostedCP bool, defaultMachinePoolRootDiskSize int) (machinePoolRootDisk *ocm.Volume, err error) {

isVersionCompatibleMachinePoolRootDisk, err := versions.IsGreaterThanOrEqual(
version, ocm.MinVersionForMachinePoolRootDisk)
if err != nil {
return nil, fmt.Errorf("There was a problem checking version compatibility: %v", err)
}
if !isVersionCompatibleMachinePoolRootDisk && cmd.Flags().Changed(workerDiskSizeFlag) {
formattedVersion, err := versions.FormatMajorMinorPatch(ocm.MinVersionForMachinePoolRootDisk)
var isVersionCompatibleMachinePoolRootDisk bool
if !isHostedCP {
isVersionCompatibleMachinePoolRootDisk, err = versions.IsGreaterThanOrEqual(
version, ocm.MinVersionForMachinePoolRootDisk)
if err != nil {
r.Reporter.Errorf(versions.MajorMinorPatchFormattedErrorOutput, err)
os.Exit(1)
return nil, fmt.Errorf("There was a problem checking version compatibility: %v", err)
}
if !isVersionCompatibleMachinePoolRootDisk && cmd.Flags().Changed(workerDiskSizeFlag) {
formattedVersion, err := versions.FormatMajorMinorPatch(ocm.MinVersionForMachinePoolRootDisk)
if err != nil {
r.Reporter.Errorf(versions.MajorMinorPatchFormattedErrorOutput, err)
os.Exit(1)
}
return nil, fmt.Errorf(
"Updating Worker disk size is not supported for versions prior to '%s'",
formattedVersion,
)
}
return nil, fmt.Errorf(
"Updating Worker disk size is not supported for versions prior to '%s'",
formattedVersion,
)
}
if isVersionCompatibleMachinePoolRootDisk && !isHostedCP &&

if (isVersionCompatibleMachinePoolRootDisk || isHostedCP) &&
(args.machinePoolRootDiskSize != "" || interactive.Enabled()) {
var machinePoolRootDiskSizeStr string
if args.machinePoolRootDiskSize == "" {
Expand All @@ -4161,14 +4164,25 @@ func getMachinePoolRootDisk(r *rosa.Runtime, cmd *cobra.Command, version string,
// Even if it was not valid, we want to display it to the user, then the CLI will show an
// error and the value can be corrected
// Also, if nothing is given, we want to display the default value fetched from the OCM API
machinePoolRootDiskSizeStr, err = interactive.GetString(interactive.Input{
Question: "Machine pool root disk size (GiB or TiB)",
Help: cmd.Flags().Lookup(workerDiskSizeFlag).Usage,
Default: machinePoolRootDiskSizeStr,
Validators: []interactive.Validator{
interactive.MachinePoolRootDiskSizeValidator(version),
},
})
if isHostedCP {
machinePoolRootDiskSizeStr, err = interactive.GetString(interactive.Input{
Question: "Machine pool root disk size (GiB or TiB)",
Help: cmd.Flags().Lookup(workerDiskSizeFlag).Usage,
Default: machinePoolRootDiskSizeStr,
Validators: []interactive.Validator{
interactive.NodePoolRootDiskSizeValidator(),
},
})
} else {
machinePoolRootDiskSizeStr, err = interactive.GetString(interactive.Input{
Question: "Machine pool root disk size (GiB or TiB)",
Help: cmd.Flags().Lookup(workerDiskSizeFlag).Usage,
Default: machinePoolRootDiskSizeStr,
Validators: []interactive.Validator{
interactive.MachinePoolRootDiskSizeValidator(version),
},
})
}
if err != nil {
return nil, fmt.Errorf("Expected a valid machine pool root disk size value: %v", err)
}
Expand All @@ -4182,7 +4196,11 @@ func getMachinePoolRootDisk(r *rosa.Runtime, cmd *cobra.Command, version string,

}

err = diskValidator.ValidateMachinePoolRootDiskSize(version, machinePoolRootDiskSize)
if isHostedCP {
err = diskValidator.ValidateNodePoolRootDiskSize(machinePoolRootDiskSize)
} else {
err = diskValidator.ValidateMachinePoolRootDiskSize(version, machinePoolRootDiskSize)
}
if err != nil {
return nil, err
}
Expand Down
12 changes: 12 additions & 0 deletions cmd/create/cluster/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,18 @@ var _ = Describe("getMachinePoolRootDisk()", func() {
"maximum size exceeded"))
Expect(machinePoolRootDisk).To(BeNil())
})

It("OK: bad disk size argument and hcp", func() {
args.machinePoolRootDiskSize = "200000000000000000000TiB"

machinePoolRootDisk, err := getMachinePoolRootDisk(r, cmd,
version, true, defaultMachinePoolRootDiskSize)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("Expected a valid machine pool root disk size value" +
" '200000000000000000000TiB': invalid disk size: '200000000000000000000Ti'. " +
"maximum size exceeded"))
Expect(machinePoolRootDisk).To(BeNil())
})
})

var _ = Describe("Validations", func() {
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/AlecAivazis/survey/v2 v2.2.15
github.com/Masterminds/semver v1.5.0
github.com/PuerkitoBio/goquery v1.8.1
github.com/aws/aws-sdk-go-v2 v1.30.0
github.com/aws/aws-sdk-go-v2 v1.30.3
github.com/aws/aws-sdk-go-v2/config v1.27.11
github.com/aws/aws-sdk-go-v2/credentials v1.17.11
github.com/aws/aws-sdk-go-v2/service/cloudformation v1.50.0
Expand All @@ -19,7 +19,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.28.6
github.com/aws/aws-sdk-go-v2/service/servicequotas v1.21.4
github.com/aws/aws-sdk-go-v2/service/sts v1.28.6
github.com/aws/smithy-go v1.20.2
github.com/aws/smithy-go v1.20.3
github.com/briandowns/spinner v1.11.1
github.com/dchest/validator v0.0.0-20191217151620-8e45250f2371
github.com/dustin/go-humanize v1.0.0
Expand All @@ -31,8 +31,8 @@ require (
github.com/nathan-fiscaletti/consolesize-go v0.0.0-20210105204122-a87d9f614b9d
github.com/onsi/ginkgo/v2 v2.17.1
github.com/onsi/gomega v1.30.0
github.com/openshift-online/ocm-common v0.0.7
github.com/openshift-online/ocm-sdk-go v0.1.435
github.com/openshift-online/ocm-common v0.0.10
github.com/openshift-online/ocm-sdk-go v0.1.438
github.com/pkg/errors v0.9.1
github.com/robfig/cron/v3 v3.0.1
github.com/sirupsen/logrus v1.9.3
Expand All @@ -48,6 +48,7 @@ require (
)

require (
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.34.0 // indirect
github.com/aws/aws-sdk-go-v2/service/ram v1.26.1 // indirect
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
)
Expand All @@ -60,12 +61,11 @@ require (
github.com/apparentlymart/go-cidr v1.1.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.12 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.12 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.5 // indirect
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.35.1 // indirect
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.24.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.7 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.7 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsVi
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU=
github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
github.com/aws/aws-sdk-go-v2 v1.30.0 h1:6qAwtzlfcTtcL8NHtbDQAqgM5s6NDipQTkPxyH/6kAA=
github.com/aws/aws-sdk-go-v2 v1.30.0/go.mod h1:ffIFB97e2yNsv4aTSGkqtHnppsIJzw7G7BReUZ3jCXM=
github.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY=
github.com/aws/aws-sdk-go-v2 v1.30.3/go.mod h1:nIQjQVp5sfpQcTc9mPSr1B0PaWK5ByX9MOoDadSN4lc=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 h1:x6xsQXGSmW6frevwDA+vi/wqhp1ct18mVXYN08/93to=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2/go.mod h1:lPprDr1e6cJdyYeGXnRaJoP4Md+cDBvi2eOj00BlGmg=
github.com/aws/aws-sdk-go-v2/config v1.27.11 h1:f47rANd2LQEYHda2ddSCKYId18/8BhSRM4BULGmfgNA=
Expand All @@ -30,10 +30,10 @@ github.com/aws/aws-sdk-go-v2/credentials v1.17.11 h1:YuIB1dJNf1Re822rriUOTxopaHH
github.com/aws/aws-sdk-go-v2/credentials v1.17.11/go.mod h1:AQtFPsDH9bI2O+71anW6EKL+NcD7LG3dpKGMV4SShgo=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 h1:FVJ0r5XTHSmIHJV6KuDmdYhEpvlHpiSd38RQWhut5J4=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1/go.mod h1:zusuAeqezXzAB24LGuzuekqMAEgWkVYukBec3kr3jUg=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.12 h1:SJ04WXGTwnHlWIODtC5kJzKbeuHt+OUNOgKg7nfnUGw=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.12/go.mod h1:FkpvXhA92gb3GE9LD6Og0pHHycTxW7xGpnEh5E7Opwo=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.12 h1:hb5KgeYfObi5MHkSSZMEudnIvX30iB+E21evI4r6BnQ=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.12/go.mod h1:CroKe/eWJdyfy9Vx4rljP5wTUjNJfb+fPz1uMYUhEGM=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 h1:SoNJ4RlFEQEbtDcCEt+QG56MY4fm4W8rYirAmq+/DdU=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15/go.mod h1:U9ke74k1n2bf+RIgoX1SXFed1HLs51OgUSs+Ph0KJP8=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 h1:C6WHdGnTDIYETAm5iErQUiVNsclNx9qbJVPIt03B6bI=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15/go.mod h1:ZQLZqhcu+JhSrA9/NXRm8SkDvsycE+JkV3WGY41e+IM=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 h1:hT8rVHwugYE2lEfdFE0QWVo81lF7jMrYJVDWI+f+VxU=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0/go.mod h1:8tu/lYfQfFe6IGnaOdrpVgEL2IrrDOf6/m9RQum4NkY=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.5 h1:81KE7vaZzrl7yHBYHVEzYB8sypz11NMOZ40YlWvPxsU=
Expand All @@ -44,8 +44,8 @@ github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.35.1 h1:suWu59CRsDNhw2YXP
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.35.1/go.mod h1:tZiRxrv5yBRgZ9Z4OOOxwscAZRFk5DgYhEcjX1QpvgI=
github.com/aws/aws-sdk-go-v2/service/ec2 v1.159.0 h1:DmmVmiLPlcntOcjWMRwDPMNx/wi2kAVrf2ZmSN5gkAg=
github.com/aws/aws-sdk-go-v2/service/ec2 v1.159.0/go.mod h1:xejKuuRDjz6z5OqyeLsz01MlOqqW7CqpAB4PabNvpu8=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.24.4 h1:V5YvSMQwZklktzYeOOhYdptx7rP650XP3RnxwNu1UEQ=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.24.4/go.mod h1:aYygRYqRxmLGrxRxAisgNarwo4x8bcJG14rh4r57VqE=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.34.0 h1:8rDRtPOu3ax8jEctw7G926JQlnFdhZZA4KJzQ+4ks3Q=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.34.0/go.mod h1:L5bVuO4PeXuDuMYZfL3IW69E6mz6PDCYpp6IKDlcLMA=
github.com/aws/aws-sdk-go-v2/service/iam v1.32.0 h1:ZNlfPdw849gBo/lvLFbEEvpTJMij0LXqiNWZ+lIamlU=
github.com/aws/aws-sdk-go-v2/service/iam v1.32.0/go.mod h1:aXWImQV0uTW35LM0A/T4wEg6R1/ReXUu4SM6/lUHYK0=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 h1:Ji0DY1xUsUr3I8cHps0G+XM3WWU16lP6yG8qu1GAZAs=
Expand Down Expand Up @@ -76,8 +76,8 @@ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4 h1:Jux+gDDyi1Lruk+KHF91tK2K
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4/go.mod h1:mUYPBhaF2lGiukDEjJX2BLRRKTmoUSitGDUgM4tRxak=
github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 h1:cwIxeBttqPN3qkaAjcEcsh8NYr8n2HZPkcKgPAi1phU=
github.com/aws/aws-sdk-go-v2/service/sts v1.28.6/go.mod h1:FZf1/nKNEkHdGGJP/cI2MoIMquumuRK6ol3QQJNDxmw=
github.com/aws/smithy-go v1.20.2 h1:tbp628ireGtzcHDDmLT/6ADHidqnwgF57XOXZe6tp4Q=
github.com/aws/smithy-go v1.20.2/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/aws/smithy-go v1.20.3 h1:ryHwveWzPV5BIof6fyDvor6V3iUL7nTfiTKXHiW05nE=
github.com/aws/smithy-go v1.20.3/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down Expand Up @@ -273,10 +273,10 @@ github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8
github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/openshift-online/ocm-common v0.0.7 h1:2/3G7W4gIyAZ1RyqbC+IUOHlf52Rd1Sf+MqmbQ2FYGk=
github.com/openshift-online/ocm-common v0.0.7/go.mod h1:gsBWQYLZB0w0ZRR+NLASuTr29uFo5nekEODasFKxESc=
github.com/openshift-online/ocm-sdk-go v0.1.435 h1:VDpDpkZmE5rknxQAdS+7p6653y6qKyDbz+nSuBgTxX8=
github.com/openshift-online/ocm-sdk-go v0.1.435/go.mod h1:CiAu2jwl3ITKOxkeV0Qnhzv4gs35AmpIzVABQLtcI2Y=
github.com/openshift-online/ocm-common v0.0.10 h1:J3QtAOK/ZQlHTPB4uQfshO45vjYdJ9099PLM0HoOUR0=
github.com/openshift-online/ocm-common v0.0.10/go.mod h1:6MWje2NFNJ3IWpGs7BYj6DWagWXHyp8EnmYY7XFTtI4=
github.com/openshift-online/ocm-sdk-go v0.1.438 h1:tsLCCUzbLCTL4RZG02y9RuopmGCXp2cjxqhdyCutdes=
github.com/openshift-online/ocm-sdk-go v0.1.438/go.mod h1:CiAu2jwl3ITKOxkeV0Qnhzv4gs35AmpIzVABQLtcI2Y=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
19 changes: 19 additions & 0 deletions pkg/interactive/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,22 @@ func MachinePoolRootDiskSizeValidator(version string) Validator {
return diskValidator.ValidateMachinePoolRootDiskSize(version, size)
}
}

func NodePoolRootDiskSizeValidator() Validator {
return func(val interface{}) error {
// We expect GigiByte as the unit for the root volume size

// Validate the worker root volume size is an integer
nodePoolRootDiskSize, ok := val.(string)
if !ok {
return fmt.Errorf("node pool root disk size must be an string, got %T", nodePoolRootDiskSize)
}

// parse it to validate it is a valid unit
size, err := ocm.ParseDiskSizeToGigibyte(nodePoolRootDiskSize)
if err != nil {
return fmt.Errorf("failed to parse machine pool root disk size '%s': %v", nodePoolRootDiskSize, err)
}
return diskValidator.ValidateNodePoolRootDiskSize(size)
}
}
5 changes: 5 additions & 0 deletions pkg/machinepool/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func createAwsNodePoolBuilder(
securityGroupIds []string,
httpTokens string,
awsTags map[string]string,
rootDiskSize *int,
) *cmv1.AWSNodePoolBuilder {
awsNpBuilder := cmv1.NewAWSNodePool().InstanceType(instanceType)

Expand All @@ -146,6 +147,10 @@ func createAwsNodePoolBuilder(

awsNpBuilder.Ec2MetadataHttpTokens(cmv1.Ec2MetadataHttpTokens(httpTokens))

if rootDiskSize != nil {
awsNpBuilder.RootVolume(cmv1.NewAWSVolume().Size(*rootDiskSize))
}

return awsNpBuilder
}

Expand Down
39 changes: 36 additions & 3 deletions pkg/machinepool/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var _ = Describe("Machine pool helper", func() {
securityGroupIds,
"optional",
awsTags,
nil,
)
awsNodePool, err := awsNpBuilder.Build()
Expect(err).ToNot(HaveOccurred())
Expand All @@ -79,7 +80,13 @@ var _ = Describe("Machine pool helper", func() {
instanceType := "123"
securityGroupIds := []string{"123"}

awsNpBuilder := createAwsNodePoolBuilder(instanceType, securityGroupIds, "optional", map[string]string{})
awsNpBuilder := createAwsNodePoolBuilder(
instanceType,
securityGroupIds,
"optional",
map[string]string{},
nil,
)
awsNodePool, err := awsNpBuilder.Build()
Expect(err).ToNot(HaveOccurred())
Expect(awsNodePool.AdditionalSecurityGroupIds()).To(Equal(securityGroupIds))
Expand All @@ -89,13 +96,37 @@ var _ = Describe("Machine pool helper", func() {
It("Create AWS node pool without security group IDs if not provided", func() {
instanceType := "123"

awsNpBuilder := createAwsNodePoolBuilder(instanceType, []string{}, "optional", map[string]string{})
awsNpBuilder := createAwsNodePoolBuilder(
instanceType,
[]string{},
"optional",
map[string]string{},
nil,
)
awsNodePool, err := awsNpBuilder.Build()
Expect(err).ToNot(HaveOccurred())
Expect(awsNodePool.AdditionalSecurityGroupIds()).To(HaveLen(0))
Expect(awsNodePool.InstanceType()).To(Equal(instanceType))
Expect(awsNodePool.Tags()).To(HaveLen(0))
})
It("Create AWS node pool with aws tags when provided", func() {
instanceType := "123"
securityGroupIds := []string{"123"}
npSize := 300

awsNpBuilder := createAwsNodePoolBuilder(
instanceType,
securityGroupIds,
"optional",
map[string]string{},
&npSize,
)
awsNodePool, err := awsNpBuilder.Build()
Expect(err).ToNot(HaveOccurred())
Expect(awsNodePool.AdditionalSecurityGroupIds()).To(Equal(securityGroupIds))
Expect(awsNodePool.InstanceType()).To(Equal(instanceType))
Expect(awsNodePool.RootVolume().Size()).To(Equal(300))
})
})

Context("It validate version is compatible for security groups", func() {
Expand Down Expand Up @@ -389,15 +420,17 @@ var _ = Describe("CreateAwsNodePoolBuilder", func() {
securityGroupIds := []string{"sg-12345"}
awsTags := map[string]string{"env": "test"}
httpTokens := "required"
size := 300

builder := createAwsNodePoolBuilder(instanceType, securityGroupIds, httpTokens, awsTags)
builder := createAwsNodePoolBuilder(instanceType, securityGroupIds, httpTokens, awsTags, &size)
built, err := builder.Build()

Expect(err).ToNot(HaveOccurred())
Expect(built.InstanceType()).To(Equal(instanceType))
Expect(built.AdditionalSecurityGroupIds()).To(ConsistOf(securityGroupIds))
Expect(string(built.Ec2MetadataHttpTokens())).To(Equal(httpTokens))
Expect(built.Tags()).To(Equal(awsTags))
Expect(built.RootVolume().Size()).To(Equal(300))
})
})

Expand Down
Loading

0 comments on commit a01e0a5

Please sign in to comment.