Skip to content

Commit

Permalink
Fix validation message & add integration test for spot-block
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoderjazz committed Mar 30, 2020
1 parent 9e2f829 commit c511921
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/apis/kops/validation/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ func awsValidateSpotDurationInMinute(fieldPath *field.Path, ig *kops.InstanceGro
allErrs := field.ErrorList{}
if ig.Spec.SpotDurationInMinutes != nil {
if *ig.Spec.SpotDurationInMinutes < 60 {
errDetails := fmt.Sprintf("cannot be lesser than 60")
errDetails := fmt.Sprintf("cannot be less than 60")
allErrs = append(allErrs, field.Invalid(fieldPath, ig.Spec.SpotDurationInMinutes, errDetails))
} else if *ig.Spec.SpotDurationInMinutes > 360 {
errDetails := fmt.Sprintf("cannot be greater than 360")
allErrs = append(allErrs, field.Invalid(fieldPath, ig.Spec.SpotDurationInMinutes, errDetails))
} else if *ig.Spec.SpotDurationInMinutes%60 != 0 {
errDetails := fmt.Sprintf("should be multiples of 60")
errDetails := fmt.Sprintf("must be a multiple of 60")
allErrs = append(allErrs, field.Invalid(fieldPath, ig.Spec.SpotDurationInMinutes, errDetails))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,13 @@
"ImageId": "ami-12345678",
"InstanceType": "t3.medium",
"KeyName": "kubernetes.launchtemplates.example.com-c4:a6:ed:9a:a8:89:b9:e2:c3:9c:d6:63:eb:9c:71:57",
"InstanceMarketOptions": {
"MarketType": "spot",
"SpotOptions": {
"BlockDurationMinutes": 120,
"MaxPrice": "0.1"
}
},
"NetworkInterfaces": [
{
"AssociatePublicIpAddress": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ spec:
minSize: 2
role: Node
instanceProtection: true
maxPrice: "0.1"
spotDurationInMinutes: 120
subnets:
- us-test-1b
---

apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,15 @@ resource "aws_launch_template" "nodes-launchtemplates-example-com" {
instance_type = "t3.medium"
key_name = "${aws_key_pair.kubernetes-launchtemplates-example-com-c4a6ed9aa889b9e2c39cd663eb9c7157.id}"

instance_market_options = {
market_type = "spot"

spot_options = {
block_duration_minutes = 120
max_price = "0.1"
}
}

network_interfaces = {
associate_public_ip_address = true
delete_on_termination = true
Expand Down

0 comments on commit c511921

Please sign in to comment.