Remove access log attributes when the spec is removed from cluster spec

This commit is contained in:
AkiraFukushima 2021-08-03 17:45:20 +09:00
parent 226cbe5561
commit 2fd69ba3a3
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
2 changed files with 9 additions and 2 deletions

View File

@ -249,6 +249,13 @@ func (b *APILoadBalancerBuilder) Build(c *fi.ModelBuilderContext) error {
S3BucketName: fi.String(lbSpec.AccessLog.Bucket),
S3BucketPrefix: fi.String(lbSpec.AccessLog.BucketPrefix),
}
} else {
clb.AccessLog = &awstasks.ClassicLoadBalancerAccessLog{
Enabled: fi.Bool(false),
}
nlb.AccessLog = &awstasks.NetworkLoadBalancerAccessLog{
Enabled: fi.Bool(false),
}
}
if b.APILoadBalancerClass() == kops.LoadBalancerClassClassic {

View File

@ -62,7 +62,7 @@ func findNetworkLoadBalancerAttributes(cloud awsup.AWSCloud, LoadBalancerArn str
}
func (_ *NetworkLoadBalancer) modifyLoadBalancerAttributes(t *awsup.AWSAPITarget, a, e, changes *NetworkLoadBalancer, loadBalancerArn string) error {
if changes.CrossZoneLoadBalancing == nil {
if changes.CrossZoneLoadBalancing == nil && changes.AccessLog == nil {
klog.V(4).Infof("No LoadBalancerAttribute changes; skipping update")
return nil
}
@ -84,7 +84,7 @@ func (_ *NetworkLoadBalancer) modifyLoadBalancerAttributes(t *awsup.AWSAPITarget
}
attributes = append(attributes, attribute)
if e.AccessLog != nil && e.AccessLog.Enabled != nil {
if e.AccessLog != nil {
attr := &elbv2.LoadBalancerAttribute{
Key: aws.String("access_logs.s3.enabled"),
Value: aws.String(strconv.FormatBool(aws.BoolValue(e.AccessLog.Enabled))),