mirror of https://github.com/kubernetes/kops.git
Merge pull request #11335 from olemarkus/warmpool-fix-hook-name
Fix lifecycle hook naming
This commit is contained in:
commit
75999163df
|
|
@ -100,11 +100,13 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
warmPoolTask.MaxSize = warmPool.MaxSize
|
warmPoolTask.MaxSize = warmPool.MaxSize
|
||||||
|
|
||||||
if warmPool.EnableLifecycleHook {
|
if warmPool.EnableLifecycleHook {
|
||||||
name := "kops-warmpool"
|
hookName := "kops-warmpool"
|
||||||
|
name := fmt.Sprintf("%s-%s", hookName, ig.GetName())
|
||||||
|
|
||||||
lifecyleTask := &awstasks.AutoscalingLifecycleHook{
|
lifecyleTask := &awstasks.AutoscalingLifecycleHook{
|
||||||
ID: aws.String(name),
|
ID: aws.String(name),
|
||||||
Name: aws.String(name),
|
Name: aws.String(name),
|
||||||
|
HookName: aws.String(hookName),
|
||||||
Lifecycle: b.Lifecycle,
|
Lifecycle: b.Lifecycle,
|
||||||
AutoscalingGroup: b.LinkToAutoscalingGroup(ig),
|
AutoscalingGroup: b.LinkToAutoscalingGroup(ig),
|
||||||
DefaultResult: aws.String("ABANDON"),
|
DefaultResult: aws.String("ABANDON"),
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ go_library(
|
||||||
srcs = [
|
srcs = [
|
||||||
"autoscalinggroup.go",
|
"autoscalinggroup.go",
|
||||||
"autoscalinggroup_fitask.go",
|
"autoscalinggroup_fitask.go",
|
||||||
"autoscalinggroup_lifecyclehook.go",
|
"autoscalinglifecyclehook.go",
|
||||||
"autoscalinglifecyclehook_fitask.go",
|
"autoscalinglifecyclehook_fitask.go",
|
||||||
"block_device_mappings.go",
|
"block_device_mappings.go",
|
||||||
"classic_load_balancer.go",
|
"classic_load_balancer.go",
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,11 @@ type AutoscalingLifecycleHook struct {
|
||||||
Name *string
|
Name *string
|
||||||
Lifecycle *fi.Lifecycle
|
Lifecycle *fi.Lifecycle
|
||||||
|
|
||||||
|
// HookName is the name of the lifecycle hook.
|
||||||
|
// It needs to be unique within the autoscaling group.
|
||||||
|
// If not set, Name will be used.
|
||||||
|
HookName *string
|
||||||
|
|
||||||
AutoscalingGroup *AutoscalingGroup
|
AutoscalingGroup *AutoscalingGroup
|
||||||
DefaultResult *string
|
DefaultResult *string
|
||||||
HeartbeatTimeout *int64
|
HeartbeatTimeout *int64
|
||||||
|
|
@ -50,7 +55,7 @@ func (h *AutoscalingLifecycleHook) Find(c *fi.Context) (*AutoscalingLifecycleHoo
|
||||||
|
|
||||||
request := &autoscaling.DescribeLifecycleHooksInput{
|
request := &autoscaling.DescribeLifecycleHooksInput{
|
||||||
AutoScalingGroupName: h.AutoscalingGroup.Name,
|
AutoScalingGroupName: h.AutoscalingGroup.Name,
|
||||||
LifecycleHookNames: []*string{h.Name},
|
LifecycleHookNames: []*string{h.GetHookName()},
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := cloud.Autoscaling().DescribeLifecycleHooks(request)
|
response, err := cloud.Autoscaling().DescribeLifecycleHooks(request)
|
||||||
|
|
@ -66,8 +71,9 @@ func (h *AutoscalingLifecycleHook) Find(c *fi.Context) (*AutoscalingLifecycleHoo
|
||||||
|
|
||||||
hook := response.LifecycleHooks[0]
|
hook := response.LifecycleHooks[0]
|
||||||
actual := &AutoscalingLifecycleHook{
|
actual := &AutoscalingLifecycleHook{
|
||||||
ID: hook.LifecycleHookName,
|
ID: h.Name,
|
||||||
Name: hook.LifecycleHookName,
|
Name: h.Name,
|
||||||
|
HookName: h.HookName,
|
||||||
Lifecycle: h.Lifecycle,
|
Lifecycle: h.Lifecycle,
|
||||||
AutoscalingGroup: h.AutoscalingGroup,
|
AutoscalingGroup: h.AutoscalingGroup,
|
||||||
DefaultResult: hook.DefaultResult,
|
DefaultResult: hook.DefaultResult,
|
||||||
|
|
@ -101,7 +107,7 @@ func (*AutoscalingLifecycleHook) RenderAWS(t *awsup.AWSAPITarget, a, e, changes
|
||||||
AutoScalingGroupName: e.AutoscalingGroup.Name,
|
AutoScalingGroupName: e.AutoscalingGroup.Name,
|
||||||
DefaultResult: e.DefaultResult,
|
DefaultResult: e.DefaultResult,
|
||||||
HeartbeatTimeout: e.HeartbeatTimeout,
|
HeartbeatTimeout: e.HeartbeatTimeout,
|
||||||
LifecycleHookName: e.Name,
|
LifecycleHookName: e.GetHookName(),
|
||||||
LifecycleTransition: e.LifecycleTransition,
|
LifecycleTransition: e.LifecycleTransition,
|
||||||
}
|
}
|
||||||
_, err := t.Cloud.Autoscaling().PutLifecycleHook(request)
|
_, err := t.Cloud.Autoscaling().PutLifecycleHook(request)
|
||||||
|
|
@ -123,7 +129,7 @@ type terraformASGLifecycleHook struct {
|
||||||
|
|
||||||
func (_ *AutoscalingLifecycleHook) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *AutoscalingLifecycleHook) error {
|
func (_ *AutoscalingLifecycleHook) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *AutoscalingLifecycleHook) error {
|
||||||
tf := &terraformASGLifecycleHook{
|
tf := &terraformASGLifecycleHook{
|
||||||
Name: e.Name,
|
Name: e.GetHookName(),
|
||||||
AutoScalingGroupName: e.AutoscalingGroup.TerraformLink(),
|
AutoScalingGroupName: e.AutoscalingGroup.TerraformLink(),
|
||||||
DefaultResult: e.DefaultResult,
|
DefaultResult: e.DefaultResult,
|
||||||
HeartbeatTimeout: e.HeartbeatTimeout,
|
HeartbeatTimeout: e.HeartbeatTimeout,
|
||||||
|
|
@ -143,7 +149,7 @@ type cloudformationASGLifecycleHook struct {
|
||||||
|
|
||||||
func (_ *AutoscalingLifecycleHook) RenderCloudformation(t *cloudformation.CloudformationTarget, a, e, changes *AutoscalingLifecycleHook) error {
|
func (_ *AutoscalingLifecycleHook) RenderCloudformation(t *cloudformation.CloudformationTarget, a, e, changes *AutoscalingLifecycleHook) error {
|
||||||
tf := &cloudformationASGLifecycleHook{
|
tf := &cloudformationASGLifecycleHook{
|
||||||
LifecycleHookName: e.Name,
|
LifecycleHookName: e.GetHookName(),
|
||||||
AutoScalingGroupName: e.AutoscalingGroup.CloudformationLink(),
|
AutoScalingGroupName: e.AutoscalingGroup.CloudformationLink(),
|
||||||
DefaultResult: e.DefaultResult,
|
DefaultResult: e.DefaultResult,
|
||||||
HeartbeatTimeout: e.HeartbeatTimeout,
|
HeartbeatTimeout: e.HeartbeatTimeout,
|
||||||
|
|
@ -152,3 +158,10 @@ func (_ *AutoscalingLifecycleHook) RenderCloudformation(t *cloudformation.Cloudf
|
||||||
|
|
||||||
return t.RenderResource("AWS::AutoScaling::LifecycleHook", *e.Name, tf)
|
return t.RenderResource("AWS::AutoScaling::LifecycleHook", *e.Name, tf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *AutoscalingLifecycleHook) GetHookName() *string {
|
||||||
|
if h.HookName != nil {
|
||||||
|
return h.HookName
|
||||||
|
}
|
||||||
|
return h.Name
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue