Skip to content

[ECS-Plugin]: Implement ECS_TRAFFIC_ROUTING stage#6613

Open
armistcxy wants to merge 2 commits intopipe-cd:masterfrom
armistcxy:ecs-plugin/traffic
Open

[ECS-Plugin]: Implement ECS_TRAFFIC_ROUTING stage#6613
armistcxy wants to merge 2 commits intopipe-cd:masterfrom
armistcxy:ecs-plugin/traffic

Conversation

@armistcxy
Copy link
Copy Markdown
Contributor

What this PR does: Implement ECS_TRAFFIC_ROUTING stage

Why we need it: This stage modifies the ALB listener's forward rules to set the desired weight between the primary and canary target groups, making it the bridge between task set management (what runs) and traffic control (what users hit).

sequenceDiagram
        participant Plugin as ECSTrafficRoutingStage
        participant Store as Metadata Store
        participant Provider as ECS Client
        participant ELB as AWS ALB

        Plugin->>Store: PutDeploymentPluginMetadata(canary-target-group-arn)
        alt Save canary ARN error
            Plugin->>Plugin: Log error
            Plugin-->>Plugin: StageStatusFailure
        else Saved
            Plugin->>Provider: Create ECS client
            alt Client creation error
                Plugin->>Plugin: Log error
                Plugin-->>Plugin: StageStatusFailure
            else Client ready
                Plugin->>Store: PutDeploymentPluginMetadataMulti(primary%, canary%)
                alt Save percentage error
                    Plugin->>Plugin: Log error
                    Plugin-->>Plugin: StageStatusFailure
                else Saved
                    Plugin->>Store: GetDeploymentPluginMetadata(current-listeners)
                    alt Get error
                        Plugin->>Plugin: Log error
                        Plugin-->>Plugin: StageStatusFailure
                    else Listener ARNs cached
                        Plugin->>Plugin: Use cached listener ARNs
                    else Not cached
                        Plugin->>ELB: GetListenerArns(primaryTargetGroup)
                        alt GetListenerArns error
                            Plugin->>Plugin: Log error
                            Plugin-->>Plugin: StageStatusFailure
                        else ARNs fetched
                            Plugin->>Plugin: Use fetched listener ARNs
                        end
                    end
                    Plugin->>Store: PutDeploymentPluginMetadata(current-listeners)
                    alt Save listeners error
                        Plugin->>Plugin: Log error
                        Plugin-->>Plugin: StageStatusFailure
                    else Saved
                        Plugin->>ELB: ModifyListeners(listenerArns, primary:X%, canary:Y%)
                        alt ModifyListeners error
                            Plugin->>Plugin: Log error
                            Plugin-->>Plugin: StageStatusFailure
                        else Modified
                            Plugin->>Plugin: Log "Modified N listener rules"
                            Plugin-->>Plugin: StageStatusSuccess
                        end
                    end
                end
            end
        end

Loading

Which issue(s) this PR fixes: Part of #6443

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

@armistcxy
Copy link
Copy Markdown
Contributor Author

I have tested this stage with a simple approach, primary return 1 and canary return 2 when requesting to them

Start with only primary

========== Results ==========
Total:    100 requests in 2.779s
Version 1: 100  (100.0%)
Version 2: 0  (0.0%)
Errors:    0

After modify traffic (50:50)

      - name: ECS_TRAFFIC_ROUTING
        with:
          canary: 50
========== Results ==========
Total:    100 requests in 2.902s
Version 1: 47  (47.0%)
Version 2: 53  (53.0%)
Errors:    0
image

Signed-off-by: Hoang Ngo <adlehoang118@gmail.com>
Signed-off-by: Hoang Ngo <adlehoang118@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant