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

Bugs Fixes: Elastigroup AWS (AUT-3714), (AUT-3713), (PROD-4204) #163

Merged
merged 1 commit into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

BUG FIXES:
* resource/spotinst_ocean_gke_import: resolved error with `desired_capacity` not applying 0 as value
* resource/spotinst_elastigroup_aws: resolved errors with `max_scale_down_percentage`
* resource/spotinst_elastigroup_aws: resolved errors with `key_name`
* resource/spotinst_ocean_strategy: resolved errors with `spot_percentage`

## 1.35.0 (March 1, 2021)

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/elastigroup_aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ Usage:
## Stateful

We support instance persistence via the following configurations. all values are boolean.
For more information on instance persistence please see: [Stateful configuration](https://api.spotinst.com/integration-docs/elastigroup/concepts/stateful-concepts/introduction/)
For more information on instance persistence please see: [Stateful configuration](https://docs.spot.io/elastigroup/features/stateful-instance/stateful-instances)

* `persist_root_device` - (Optional) Boolean, should the instance maintain its root device volumes.
* `persist_block_devices` - (Optional) Boolean, should the instance maintain its Data volumes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,22 @@ func expandAWSGroupAutoScaleHeadroom(data interface{}) (*aws.AutoScaleHeadroom,
return nil, nil
}

func expandAWSGroupAutoScaleDown(data interface{}) (*aws.AutoScaleDown, error) {
func expandAWSGroupAutoScaleDown(data interface{}, isMaxScaleDownPercentageExist bool) (*aws.AutoScaleDown, error) {
if list := data.([]interface{}); len(list) > 0 {
autoScaleDown := &aws.AutoScaleDown{}
if list != nil && list[0] != nil {
m := list[0].(map[string]interface{})
var maxScaleDownPercentage *float64 = nil

if v, ok := m[string(EvaluationPeriods)].(int); ok && v > 0 {
autoScaleDown.SetEvaluationPeriods(spotinst.Int(v))
}

if v, ok := m[string(MaxScaleDownPercentage)].(float64); ok && v > 0 {
autoScaleDown.SetMaxScaleDownPercentage(spotinst.Float64(v))
maxScaleDownPercentage = spotinst.Float64(v)
}
if isMaxScaleDownPercentageExist {
autoScaleDown.SetMaxScaleDownPercentage(maxScaleDownPercentage)
}
}
return autoScaleDown, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func expandAWSGroupDockerSwarmIntegration(data interface{}, nullify bool) (*aws.
}

if v, ok := m[string(AutoscaleDown)]; ok {
down, err := expandAWSGroupAutoScaleDown(v)
down, err := expandAWSGroupAutoScaleDown(v, true)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func expandAWSGroupEC2ContainerServiceIntegration(data interface{}) (*aws.EC2Con
}

if v, ok := m[string(AutoscaleDown)]; ok {
down, err := expandAWSGroupAutoScaleDown(v)
down, err := expandAWSGroupAutoScaleDown(v, true)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func expandAWSGroupKubernetesIntegration(data interface{}) (*aws.KubernetesInteg
}

if v, ok := m[string(AutoscaleDown)]; ok {
down, err := expandAWSGroupAutoScaleDown(v)
down, err := expandAWSGroupAutoScaleDown(v, false)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func expandAWSGroupNomadIntegration(data interface{}, nullify bool) (*aws.NomadI
}

if v, ok := m[string(AutoscaleDown)]; ok {
down, err := expandAWSGroupAutoScaleDown(v)
down, err := expandAWSGroupAutoScaleDown(v, false)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ func Setup(fieldsMap map[commons.FieldName]*commons.GenericField) {
func(resourceObject interface{}, resourceData *schema.ResourceData, meta interface{}) error {
egWrapper := resourceObject.(*commons.ElastigroupWrapper)
elastigroup := egWrapper.GetElastigroup()
var value *string = nil
if v, ok := resourceData.Get(string(KeyName)).(string); ok && v != "" {
elastigroup.Compute.LaunchSpecification.SetKeyPair(spotinst.String(v))
value = spotinst.String(v)
}
elastigroup.Compute.LaunchSpecification.SetKeyPair(value)
return nil
},
nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,12 @@ func Setup(fieldsMap map[commons.FieldName]*commons.GenericField) {
func(resourceObject interface{}, resourceData *schema.ResourceData, meta interface{}) error {
clusterWrapper := resourceObject.(*commons.AWSClusterWrapper)
cluster := clusterWrapper.GetCluster()
var spotPercentage *float64 = nil
if v := resourceData.Get(string(SpotPercentage)).(int); v > -1 {
cluster.Strategy.SetSpotPercentage(spotinst.Float64(float64(v)))
if v > 0 {
spotPercentage = spotinst.Float64(float64(v))
}
cluster.Strategy.SetSpotPercentage(spotPercentage)
}
return nil
},
Expand Down