Skip to content

Commit

Permalink
feat(ECS): enable selection of listener rules (pipe-cd#4668)
Browse files Browse the repository at this point in the history
* feat(ECS): enable selection of listener rules

Signed-off-by: moko-poi <mokopoi44@gmail.com>

* Update pkg/app/piped/platformprovider/ecs/client.go

Signed-off-by: moko-poi <mokopoi44@gmail.com>

* Make actions plan preview handle timeout option (pipe-cd#4648)

* Format and make tests pass in tool/actions-plan-preview

Signed-off-by: mi11km <mi11km.program@gmail.com>

* Use --piped-handle-timeout to make the timeout arg activate

Signed-off-by: mi11km <mi11km.program@gmail.com>

* Add tests to model/notificationevent (pipe-cd#4631)

* Add tests to model/notificationevent

Signed-off-by: Kenta Kozuka <kenta.kozuka@gmail.com>

* Add Parallel()

Signed-off-by: Kenta Kozuka <kenta.kozuka@gmail.com>

---------

Signed-off-by: Kenta Kozuka <kenta.kozuka@gmail.com>
Signed-off-by: mi11km <mi11km.program@gmail.com>

* add piped-handle-timeout(input args)

Signed-off-by: mi11km <mi11km.program@gmail.com>

---------

Signed-off-by: mi11km <mi11km.program@gmail.com>
Signed-off-by: Kenta Kozuka <kenta.kozuka@gmail.com>
Co-authored-by: Kenta Kozuka <kenta.kozuka@gmail.com>
Co-authored-by: Khanh Tran <32532742+khanhtc1202@users.noreply.github.com>
Signed-off-by: moko-poi <mokopoi44@gmail.com>

* Increase limit of stale action operations (pipe-cd#4671)

Signed-off-by: moko-poi <mokopoi44@gmail.com>

* Add docs for k8s annotations (pipe-cd#4673)

Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>
Signed-off-by: moko-poi <mokopoi44@gmail.com>

* feat: add modifylisner and modifyrule

Signed-off-by: moko-poi <mokopoi44@gmail.com>

* fix: ModifyRules

Signed-off-by: moko-poi <mokopoi44@gmail.com>

* fix: rollback

Signed-off-by: moko-poi <mokopoi44@gmail.com>

* fix: routing

Signed-off-by: moko-poi <mokopoi44@gmail.com>

* fix: action.Type == elbtypes.ActionTypeEnumForward

Signed-off-by: moko-poi <mokopoi44@gmail.com>

* fix: Update ModifyListeners and ModifyRules for Selective Action Modification

Signed-off-by: moko-poi <mokopoi44@gmail.com>

---------

Signed-off-by: moko-poi <mokopoi44@gmail.com>
Signed-off-by: mi11km <mi11km.program@gmail.com>
Signed-off-by: Kenta Kozuka <kenta.kozuka@gmail.com>
Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>
Co-authored-by: Khanh Tran <32532742+khanhtc1202@users.noreply.github.com>
Co-authored-by: Masafumi Ikeyama <54844746+mi11km@users.noreply.github.com>
Co-authored-by: Kenta Kozuka <kenta.kozuka@gmail.com>
Co-authored-by: Yoshiki Fujikane <40124947+ffjlabo@users.noreply.github.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
  • Loading branch information
5 people authored and sZma5a committed Dec 17, 2023
1 parent a2ba951 commit 0820ecc
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/app/piped/executor/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,21 @@ func routing(ctx context.Context, in *executor.Input, platformProviderName strin
return false
}

currListenerRuleArns, err := client.GetListenerRuleArns(ctx, currListenerArns)
if err != nil {
in.LogPersister.Errorf("Failed to get current active listener rule: %v", err)
return false
}

if len(currListenerRuleArns) > 0 {
if err := client.ModifyRules(ctx, currListenerRuleArns, routingTrafficCfg); err != nil {
in.LogPersister.Errorf("Failed to routing traffic to PRIMARY/CANARY variants: %v", err)
return false
}

return true
}

if err := client.ModifyListeners(ctx, currListenerArns, routingTrafficCfg); err != nil {
in.LogPersister.Errorf("Failed to routing traffic to PRIMARY/CANARY variants: %v", err)
return false
Expand Down
15 changes: 15 additions & 0 deletions pkg/app/piped/executor/ecs/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ func rollback(ctx context.Context, in *executor.Input, platformProviderName stri
return false
}

currListenerRuleArns, err := client.GetListenerRuleArns(ctx, currListenerArns)
if err != nil {
in.LogPersister.Errorf("Failed to get current active listener rule: %v", err)
return false
}

if len(currListenerRuleArns) > 0 {
if err := client.ModifyRules(ctx, currListenerRuleArns, routingTrafficCfg); err != nil {
in.LogPersister.Errorf("Failed to routing traffic to PRIMARY/CANARY variants: %v", err)
return false
}

return true
}

if err := client.ModifyListeners(ctx, currListenerArns, routingTrafficCfg); err != nil {
in.LogPersister.Errorf("Failed to routing traffic to PRIMARY/CANARY variants: %v", err)
return false
Expand Down
25 changes: 25 additions & 0 deletions pkg/app/piped/platformprovider/ecs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"errors"
"fmt"
"strings"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
Expand Down Expand Up @@ -417,6 +418,30 @@ func (c *client) GetListenerArns(ctx context.Context, targetGroup types.LoadBala
return arns, nil
}

func (c *client) GetListenerRuleArns(ctx context.Context, listenerArns []string) ([]string, error) {
var ruleArns []string

// Fetch all rules by listeners
for _, listenerArn := range listenerArns {
input := &elasticloadbalancingv2.DescribeRulesInput{
ListenerArn: aws.String(listenerArn),
}
output, err := c.elbClient.DescribeRules(ctx, input)
if err != nil {
return nil, err
}
for _, rule := range output.Rules {
ruleArns = append(ruleArns, *rule.RuleArn)
}
}

if len(ruleArns) == 0 {
return nil, platformprovider.ErrNotFound
}

return ruleArns, nil
}

func (c *client) getLoadBalancerArn(ctx context.Context, targetGroupArn string) (string, error) {
input := &elasticloadbalancingv2.DescribeTargetGroupsInput{
TargetGroupArns: []string{targetGroupArn},
Expand Down
1 change: 1 addition & 0 deletions pkg/app/piped/platformprovider/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type ELB interface {
// 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
ModifyRules(ctx context.Context, listenerRuleArns []string, routingTrafficCfg RoutingTrafficConfig) error
}

// Registry holds a pool of aws client wrappers.
Expand Down

0 comments on commit 0820ecc

Please sign in to comment.