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
|
||||
|
||||
if warmPool.EnableLifecycleHook {
|
||||
name := "kops-warmpool"
|
||||
hookName := "kops-warmpool"
|
||||
name := fmt.Sprintf("%s-%s", hookName, ig.GetName())
|
||||
|
||||
lifecyleTask := &awstasks.AutoscalingLifecycleHook{
|
||||
ID: aws.String(name),
|
||||
Name: aws.String(name),
|
||||
HookName: aws.String(hookName),
|
||||
Lifecycle: b.Lifecycle,
|
||||
AutoscalingGroup: b.LinkToAutoscalingGroup(ig),
|
||||
DefaultResult: aws.String("ABANDON"),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ go_library(
|
|||
srcs = [
|
||||
"autoscalinggroup.go",
|
||||
"autoscalinggroup_fitask.go",
|
||||
"autoscalinggroup_lifecyclehook.go",
|
||||
"autoscalinglifecyclehook.go",
|
||||
"autoscalinglifecyclehook_fitask.go",
|
||||
"block_device_mappings.go",
|
||||
"classic_load_balancer.go",
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ type AutoscalingLifecycleHook struct {
|
|||
Name *string
|
||||
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
|
||||
DefaultResult *string
|
||||
HeartbeatTimeout *int64
|
||||
|
|
@ -50,7 +55,7 @@ func (h *AutoscalingLifecycleHook) Find(c *fi.Context) (*AutoscalingLifecycleHoo
|
|||
|
||||
request := &autoscaling.DescribeLifecycleHooksInput{
|
||||
AutoScalingGroupName: h.AutoscalingGroup.Name,
|
||||
LifecycleHookNames: []*string{h.Name},
|
||||
LifecycleHookNames: []*string{h.GetHookName()},
|
||||
}
|
||||
|
||||
response, err := cloud.Autoscaling().DescribeLifecycleHooks(request)
|
||||
|
|
@ -66,8 +71,9 @@ func (h *AutoscalingLifecycleHook) Find(c *fi.Context) (*AutoscalingLifecycleHoo
|
|||
|
||||
hook := response.LifecycleHooks[0]
|
||||
actual := &AutoscalingLifecycleHook{
|
||||
ID: hook.LifecycleHookName,
|
||||
Name: hook.LifecycleHookName,
|
||||
ID: h.Name,
|
||||
Name: h.Name,
|
||||
HookName: h.HookName,
|
||||
Lifecycle: h.Lifecycle,
|
||||
AutoscalingGroup: h.AutoscalingGroup,
|
||||
DefaultResult: hook.DefaultResult,
|
||||
|
|
@ -101,7 +107,7 @@ func (*AutoscalingLifecycleHook) RenderAWS(t *awsup.AWSAPITarget, a, e, changes
|
|||
AutoScalingGroupName: e.AutoscalingGroup.Name,
|
||||
DefaultResult: e.DefaultResult,
|
||||
HeartbeatTimeout: e.HeartbeatTimeout,
|
||||
LifecycleHookName: e.Name,
|
||||
LifecycleHookName: e.GetHookName(),
|
||||
LifecycleTransition: e.LifecycleTransition,
|
||||
}
|
||||
_, err := t.Cloud.Autoscaling().PutLifecycleHook(request)
|
||||
|
|
@ -123,7 +129,7 @@ type terraformASGLifecycleHook struct {
|
|||
|
||||
func (_ *AutoscalingLifecycleHook) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *AutoscalingLifecycleHook) error {
|
||||
tf := &terraformASGLifecycleHook{
|
||||
Name: e.Name,
|
||||
Name: e.GetHookName(),
|
||||
AutoScalingGroupName: e.AutoscalingGroup.TerraformLink(),
|
||||
DefaultResult: e.DefaultResult,
|
||||
HeartbeatTimeout: e.HeartbeatTimeout,
|
||||
|
|
@ -143,7 +149,7 @@ type cloudformationASGLifecycleHook struct {
|
|||
|
||||
func (_ *AutoscalingLifecycleHook) RenderCloudformation(t *cloudformation.CloudformationTarget, a, e, changes *AutoscalingLifecycleHook) error {
|
||||
tf := &cloudformationASGLifecycleHook{
|
||||
LifecycleHookName: e.Name,
|
||||
LifecycleHookName: e.GetHookName(),
|
||||
AutoScalingGroupName: e.AutoscalingGroup.CloudformationLink(),
|
||||
DefaultResult: e.DefaultResult,
|
||||
HeartbeatTimeout: e.HeartbeatTimeout,
|
||||
|
|
@ -152,3 +158,10 @@ func (_ *AutoscalingLifecycleHook) RenderCloudformation(t *cloudformation.Cloudf
|
|||
|
||||
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