-
Notifications
You must be signed in to change notification settings - Fork 182
ECS: Add UI Logs for Listener Rules in TRAFFIC_ROUTING and ROLLBACK #5842
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
Changes from 5 commits
e73d864
d0ced61
2b069b0
8bde09d
ca341d8
35315ac
19f5643
ce1a4e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -472,17 +472,19 @@ func (c *client) getLoadBalancerArn(ctx context.Context, targetGroupArn string) | |
return output.TargetGroups[0].LoadBalancerArns[0], nil | ||
} | ||
|
||
func (c *client) ModifyListeners(ctx context.Context, listenerArns []string, routingTrafficCfg RoutingTrafficConfig) error { | ||
func (c *client) ModifyListeners(ctx context.Context, listenerArns []string, routingTrafficCfg RoutingTrafficConfig) ([]string, error) { | ||
if len(routingTrafficCfg) != 2 { | ||
return fmt.Errorf("invalid listener configuration: requires 2 target groups") | ||
return nil, fmt.Errorf("invalid listener configuration: requires 2 target groups") | ||
} | ||
|
||
modifiedRuleArns := make([]string, 0) | ||
|
||
for _, listenerArn := range listenerArns { | ||
describeRulesOutput, err := c.elbClient.DescribeRules(ctx, &elasticloadbalancingv2.DescribeRulesInput{ | ||
ListenerArn: aws.String(listenerArn), | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("failed to describe rules of listener %s: %w", listenerArn, err) | ||
return nil, fmt.Errorf("failed to describe rules of listener %s: %w", listenerArn, err) | ||
} | ||
|
||
for _, rule := range describeRulesOutput.Rules { | ||
|
@@ -519,20 +521,22 @@ func (c *client) ModifyListeners(ctx context.Context, listenerArns []string, rou | |
DefaultActions: modifiedActions, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("failed to modify default rule %s: %w", *rule.RuleArn, err) | ||
return modifiedRuleArns, fmt.Errorf("failed to modify default rule %s: %w", *rule.RuleArn, err) | ||
} | ||
modifiedRuleArns = append(modifiedRuleArns, fmt.Sprintf("default rule of listener %s", listenerArn)) | ||
} else { | ||
_, err := c.elbClient.ModifyRule(ctx, &elasticloadbalancingv2.ModifyRuleInput{ | ||
RuleArn: rule.RuleArn, | ||
Actions: modifiedActions, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("failed to modify rule %s: %w", *rule.RuleArn, err) | ||
return modifiedRuleArns, fmt.Errorf("failed to modify rule %s: %w", *rule.RuleArn, err) | ||
} | ||
modifiedRuleArns = append(modifiedRuleArns, *rule.RuleArn) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In error handlings, return the current |
||
} | ||
} | ||
} | ||
return nil | ||
return modifiedRuleArns, nil | ||
} | ||
|
||
func (c *client) TagResource(ctx context.Context, resourceArn string, tags []types.Tag) error { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ type ELB interface { | |
GetListenerArns(ctx context.Context, targetGroup types.LoadBalancer) ([]string, error) | ||
// ModifyListeners modifies the actions of type ActionTypeEnumForward to perform routing traffic | ||
// to the given target groups. Other actions won't be modified. | ||
ModifyListeners(ctx context.Context, listenerArns []string, routingTrafficCfg RoutingTrafficConfig) error | ||
ModifyListeners(ctx context.Context, listenerArns []string, routingTrafficCfg RoutingTrafficConfig) (modifiedRuleArns []string, err error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add comments for methods to note that it returns a non-nil modifiedRuleArns value even when returning a non-nil error because it differs from the usual behavior of the go codes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a note |
||
} | ||
|
||
// Registry holds a pool of aws client wrappers. | ||
|
Uh oh!
There was an error while loading. Please reload this page.