diff --git a/go.mod b/go.mod
index c2562544ac4ae..d7920417e82ce 100644
--- a/go.mod
+++ b/go.mod
@@ -92,7 +92,7 @@ require (
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.4.0
- github.com/spotinst/spotinst-sdk-go v1.43.0
+ github.com/spotinst/spotinst-sdk-go v1.49.0
github.com/stretchr/testify v1.4.0
github.com/urfave/cli v1.20.0
github.com/vmware/govmomi v0.20.3
diff --git a/go.sum b/go.sum
index 4470af879a14c..71ea40fb4dc2a 100644
--- a/go.sum
+++ b/go.sum
@@ -733,6 +733,8 @@ github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/spotinst/spotinst-sdk-go v1.43.0 h1:ba5LQrYHQaq6TeC2JR3Hau7pbymVFScj3zoDxhbRphs=
github.com/spotinst/spotinst-sdk-go v1.43.0/go.mod h1:nWi2DyjUi1WUZclpsqZFXvImsU0T39ppqqHwC4/T5mw=
+github.com/spotinst/spotinst-sdk-go v1.49.0 h1:JmsLlsgd/cCKpcn04HrParo5r34owDzIC12IW1SpSEs=
+github.com/spotinst/spotinst-sdk-go v1.49.0/go.mod h1:nWi2DyjUi1WUZclpsqZFXvImsU0T39ppqqHwC4/T5mw=
github.com/storageos/go-api v0.0.0-20180912212459-343b3eff91fc/go.mod h1:ZrLn+e0ZuF3Y65PNF6dIwbJPZqfmtCXxFm9ckv0agOY=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
diff --git a/pkg/model/spotinstmodel/instance_group.go b/pkg/model/spotinstmodel/instance_group.go
index 183a51296f35f..b1eec12b5466c 100644
--- a/pkg/model/spotinstmodel/instance_group.go
+++ b/pkg/model/spotinstmodel/instance_group.go
@@ -53,6 +53,11 @@ const (
// be enabled.
InstanceGroupLabelFallbackToOnDemand = "spotinst.io/fallback-to-ondemand"
+ // InstanceGroupLabelGracePeriod is the metadata label used on the
+ // instance group to specify a period of time, in seconds, that Ocean
+ // should wait before applying instance health checks.
+ InstanceGroupLabelGracePeriod = "spotinst.io/grace-period"
+
// InstanceGroupLabelHealthCheckType is the metadata label used on the
// instance group to specify the type of the health check that should be used.
InstanceGroupLabelHealthCheckType = "spotinst.io/health-check-type"
@@ -355,6 +360,12 @@ func (b *InstanceGroupModelBuilder) buildOcean(c *fi.ModelBuilderContext, igs ..
return err
}
+ case InstanceGroupLabelGracePeriod:
+ ocean.GracePeriod, err = parseInt(v)
+ if err != nil {
+ return err
+ }
+
case InstanceGroupLabelOceanInstanceTypesWhitelist:
ocean.InstanceTypesWhitelist, err = parseStringSlice(v)
if err != nil {
diff --git a/upup/pkg/fi/cloudup/spotinsttasks/ocean.go b/upup/pkg/fi/cloudup/spotinsttasks/ocean.go
index b4dc508fd056f..e1395d575c8cf 100644
--- a/upup/pkg/fi/cloudup/spotinsttasks/ocean.go
+++ b/upup/pkg/fi/cloudup/spotinsttasks/ocean.go
@@ -47,6 +47,7 @@ type Ocean struct {
SpotPercentage *float64
UtilizeReservedInstances *bool
FallbackToOnDemand *bool
+ GracePeriod *int64
InstanceTypesWhitelist []string
InstanceTypesBlacklist []string
Tags map[string]string
@@ -145,6 +146,10 @@ func (o *Ocean) Find(c *fi.Context) (*Ocean, error) {
actual.SpotPercentage = strategy.SpotPercentage
actual.FallbackToOnDemand = strategy.FallbackToOnDemand
actual.UtilizeReservedInstances = strategy.UtilizeReservedInstances
+
+ if strategy.GracePeriod != nil {
+ actual.GracePeriod = fi.Int64(int64(fi.IntValue(strategy.GracePeriod)))
+ }
}
}
@@ -366,6 +371,10 @@ func (_ *Ocean) create(cloud awsup.AWSCloud, a, e, changes *Ocean) error {
ocean.Strategy.SetSpotPercentage(e.SpotPercentage)
ocean.Strategy.SetFallbackToOnDemand(e.FallbackToOnDemand)
ocean.Strategy.SetUtilizeReservedInstances(e.UtilizeReservedInstances)
+
+ if e.GracePeriod != nil {
+ ocean.Strategy.SetGracePeriod(fi.Int(int(*e.GracePeriod)))
+ }
}
// Compute.
@@ -610,6 +619,17 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error {
changes.UtilizeReservedInstances = nil
changed = true
}
+
+ // Grace period.
+ if changes.GracePeriod != nil {
+ if ocean.Strategy == nil {
+ ocean.Strategy = new(aws.Strategy)
+ }
+
+ ocean.Strategy.SetGracePeriod(fi.Int(int(*e.GracePeriod)))
+ changes.GracePeriod = nil
+ changed = true
+ }
}
// Compute.
@@ -977,6 +997,7 @@ type terraformOceanStrategy struct {
SpotPercentage *float64 `json:"spot_percentage,omitempty" cty:"spot_percentage"`
FallbackToOnDemand *bool `json:"fallback_to_ondemand,omitempty" cty:"fallback_to_ondemand"`
UtilizeReservedInstances *bool `json:"utilize_reserved_instances,omitempty" cty:"utilize_reserved_instances"`
+ GracePeriod *int64 `json:"grace_period,omitempty" cty:"grace_period"`
}
type terraformOceanLaunchSpec struct {
@@ -1012,6 +1033,7 @@ func (_ *Ocean) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *Oce
SpotPercentage: e.SpotPercentage,
FallbackToOnDemand: e.FallbackToOnDemand,
UtilizeReservedInstances: e.UtilizeReservedInstances,
+ GracePeriod: e.GracePeriod,
},
terraformOceanLaunchSpec: &terraformOceanLaunchSpec{},
}
diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/NOTICE.md b/vendor/github.com/spotinst/spotinst-sdk-go/NOTICE.md
new file mode 100644
index 0000000000000..918a63fbf6b2d
--- /dev/null
+++ b/vendor/github.com/spotinst/spotinst-sdk-go/NOTICE.md
@@ -0,0 +1,14 @@
+
diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/gcp/gcp.go b/vendor/github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/gcp/gcp.go
index 7470063962905..9f9a11151b4bf 100644
--- a/vendor/github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/gcp/gcp.go
+++ b/vendor/github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/gcp/gcp.go
@@ -266,6 +266,7 @@ type NetworkInterface struct {
AccessConfigs []*AccessConfig `json:"accessConfigs,omitempty"`
AliasIPRanges []*AliasIPRange `json:"aliasIpRanges,omitempty"`
Network *string `json:"network,omitempty"`
+ ProjectID *string `json:"projectId,omitempty"`
forceSendFields []string
nullFields []string
@@ -1552,6 +1553,14 @@ func (o *NetworkInterface) SetNetwork(v *string) *NetworkInterface {
return o
}
+// SetProjectId sets the project identifier of the network.
+func (o *NetworkInterface) SetProjectId(v *string) *NetworkInterface {
+ if o.ProjectID = v; o.ProjectID == nil {
+ o.nullFields = append(o.nullFields, "ProjectID")
+ }
+ return o
+}
+
// region AccessConfig setters
func (o AccessConfig) MarshalJSON() ([]byte, error) {
diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/ocean.go b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/ocean.go
index 9f29fd4ecfd3c..bf8db27370a2b 100644
--- a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/ocean.go
+++ b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/ocean.go
@@ -50,6 +50,7 @@ type Strategy struct {
UtilizeReservedInstances *bool `json:"utilizeReservedInstances,omitempty"`
FallbackToOnDemand *bool `json:"fallbackToOd,omitempty"`
DrainingTimeout *int `json:"drainingTimeout,omitempty"`
+ GracePeriod *int `json:"gracePeriod,omitempty"`
forceSendFields []string
nullFields []string
@@ -575,6 +576,13 @@ func (o *Strategy) SetDrainingTimeout(v *int) *Strategy {
return o
}
+func (o *Strategy) SetGracePeriod(v *int) *Strategy {
+ if o.GracePeriod = v; o.GracePeriod == nil {
+ o.nullFields = append(o.nullFields, "GracePeriod")
+ }
+ return o
+}
+
// endregion
// region Capacity
diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/right_sizing.go b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/right_sizing.go
index 5c874150d53b8..768e5eb173795 100644
--- a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/right_sizing.go
+++ b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/aws/right_sizing.go
@@ -23,7 +23,8 @@ type ResourceSuggestion struct {
// ListResourceSuggestionsInput represents the input of `ListResourceSuggestions` function.
type ListResourceSuggestionsInput struct {
- OceanID *string `json:"oceanId,omitempty"`
+ OceanID *string `json:"oceanId,omitempty"`
+ Namespace *string `json:"namespace,omitempty"`
}
// ListResourceSuggestionsOutput represents the output of `ListResourceSuggestions` function.
@@ -74,6 +75,12 @@ func (s *ServiceOp) ListResourceSuggestions(ctx context.Context, input *ListReso
}
r := client.NewRequest(http.MethodGet, path)
+
+ if input.Namespace != nil {
+ r.Params.Set("namespace", *input.Namespace)
+ }
+ r.Obj = input
+
resp, err := client.RequireOK(s.Client.Do(ctx, r))
if err != nil {
return nil, err
diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/gcp/ocean.go b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/gcp/ocean.go
index 07e06f119b69a..d18ebe888dbaf 100644
--- a/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/gcp/ocean.go
+++ b/vendor/github.com/spotinst/spotinst-sdk-go/service/ocean/providers/gcp/ocean.go
@@ -66,8 +66,8 @@ type AutoScaler struct {
}
type AutoScalerDown struct {
- EvaluationPeriods *int `json:"evaluationPeriods,omitempty"`
- MaxScaleDownPercentage *int `json:"maxScaleDownPercentage,omitempty"`
+ EvaluationPeriods *int `json:"evaluationPeriods,omitempty"`
+ MaxScaleDownPercentage *float64 `json:"maxScaleDownPercentage,omitempty"`
forceSendFields []string
nullFields []string
@@ -196,6 +196,7 @@ type NetworkInterface struct {
AccessConfigs []*AccessConfig `json:"accessConfigs,omitempty"`
AliasIPRanges []*AliasIPRange `json:"aliasIpRanges,omitempty"`
Network *string `json:"network,omitempty"`
+ ProjectID *string `json:"projectId,omitempty"`
forceSendFields []string
nullFields []string
@@ -970,6 +971,13 @@ func (o *NetworkInterface) SetNetwork(v *string) *NetworkInterface {
return o
}
+func (o *NetworkInterface) SetProjectId(v *string) *NetworkInterface {
+ if o.ProjectID = v; o.ProjectID == nil {
+ o.nullFields = append(o.nullFields, "ProjectID")
+ }
+ return o
+}
+
// endregion
// region AliasIPRange
@@ -1157,4 +1165,11 @@ func (o *AutoScalerDown) SetEvaluationPeriods(v *int) *AutoScalerDown {
return o
}
+func (o *AutoScalerDown) SetMaxScaleDownPercentage(v *float64) *AutoScalerDown {
+ if o.MaxScaleDownPercentage = v; o.MaxScaleDownPercentage == nil {
+ o.nullFields = append(o.nullFields, "MaxScaleDownPercentage")
+ }
+ return o
+}
+
// endregion
diff --git a/vendor/github.com/spotinst/spotinst-sdk-go/spotinst/version.go b/vendor/github.com/spotinst/spotinst-sdk-go/spotinst/version.go
index a8d06c0a811aa..b18475d81004a 100644
--- a/vendor/github.com/spotinst/spotinst-sdk-go/spotinst/version.go
+++ b/vendor/github.com/spotinst/spotinst-sdk-go/spotinst/version.go
@@ -1,7 +1,7 @@
package spotinst
// SDKVersion is the current version of the SDK.
-const SDKVersion = "1.43.0"
+const SDKVersion = "1.49.0"
// SDKName is the name of the SDK.
const SDKName = "spotinst-sdk-go"
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 8bee6e6a2bb2b..4e5fb6f87da15 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -426,7 +426,7 @@ github.com/spf13/jwalterweatherman
github.com/spf13/pflag
# github.com/spf13/viper v1.4.0
github.com/spf13/viper
-# github.com/spotinst/spotinst-sdk-go v1.43.0
+# github.com/spotinst/spotinst-sdk-go v1.49.0
github.com/spotinst/spotinst-sdk-go/service/elastigroup
github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/aws
github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/azure