Skip to content
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

Fix ECS rollback stage does not remove canary created tasks #4465

Merged
merged 3 commits into from
Jul 6, 2023

Conversation

ductnn
Copy link
Contributor

@ductnn ductnn commented Jul 5, 2023

What this PR does / why we need it:

  • Fix Cancel with rollback does not remove canary created tasks

Which issue(s) this PR fixes:

Fixes #4329

Does this PR introduce a user-facing change?:

  • Is this breaking change:
  • How to migrate (if breaking change):
  • How are users affected by this change: Fix ECS rollback stage does not remove ECS canary created tasks

Comment on lines 159 to 168
// Delete Canary taskSet
canaryTaskSet, ok := in.MetadataStore.Shared().Get(canaryTaskSetARNKeyName)
if !ok {
in.LogPersister.Errorf("Unable to restore CANARY task set to clean: Not found")
return false
}
if err = client.DeleteTaskSet(ctx, *service, canaryTaskSet); err != nil {
in.LogPersister.Errorf("Failed to remove unused previous PRIMARY taskSet %s: %v", canaryTaskSet, err)
return false
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we tried to clean the canary stub by this part, so how about to reuse clean function?
https://github.com/pipe-cd/pipecd/blob/master/pkg/app/piped/executor/ecs/ecs.go#L349

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Thanks! I'll reuse clean function 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khanhtc1202 I fixed it! reuse clean function, please review it 🙏

Comment on lines 136 to 169
// Reset routing
routingTrafficCfg := provider.RoutingTrafficConfig{
{
TargetGroupArn: *primaryTargetGroup.TargetGroupArn,
Weight: 100,
},
{
TargetGroupArn: *canaryTargetGroup.TargetGroupArn,
Weight: 0,
},
}

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

if err := client.ModifyListeners(ctx, currListenerArns, routingTrafficCfg); err != nil {
in.LogPersister.Errorf("Failed to routing traffic to CANARY variant: %v", err)
return false
}

// Delete Canary taskSet
canaryTaskSet, ok := in.MetadataStore.Shared().Get(canaryTaskSetARNKeyName)
if !ok {
in.LogPersister.Errorf("Unable to restore CANARY task set to clean: Not found")
return false
}
if err = client.DeleteTaskSet(ctx, *service, canaryTaskSet); err != nil {
in.LogPersister.Errorf("Failed to remove unused previous PRIMARY taskSet %s: %v", canaryTaskSet, err)
return false
}

Copy link
Member

@khanhtc1202 khanhtc1202 Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safer to do this after L182 (after we finish updating the rollbacked taskset as the primary taskset of the current service and remove the previous primary taskset), since it's more sense to only routing the traffic after primary tasksets are well-prepared and ready to handle incoming requests. Wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • You're right, it's a secure choice to proceed 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khanhtc1202 I fixed it! reuse clean function, please review it 🙏

@khanhtc1202 khanhtc1202 changed the title Fix cannot remove canary created task Fix ECS rollback stage does not remove canary created task Jul 6, 2023
@khanhtc1202 khanhtc1202 changed the title Fix ECS rollback stage does not remove canary created task Fix ECS rollback stage does not remove canary created tasks Jul 6, 2023

currListenerArns, err := client.GetListenerArns(ctx, *primaryTargetGroup)
if err != nil {
in.LogPersister.Errorf("Failed to get current active listener: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
in.LogPersister.Errorf("Failed to get current active listener: %v", err)
in.LogPersister.Errorf("Failed to get current active listeners: %v", err)

nits

}

if err := client.ModifyListeners(ctx, currListenerArns, routingTrafficCfg); err != nil {
in.LogPersister.Errorf("Failed to routing traffic to CANARY variant: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
in.LogPersister.Errorf("Failed to routing traffic to CANARY variant: %v", err)
in.LogPersister.Errorf("Failed to routing traffic to PRIMARY variant: %v", err)

Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you 🙌

@khanhtc1202 khanhtc1202 merged commit 1c2e5cb into pipe-cd:master Jul 6, 2023
kentakozuka pushed a commit that referenced this pull request Jul 12, 2023
* Fix cannot remove canary created task

Signed-off-by: ductnn <[email protected]>

* Fix reuse clean function

Signed-off-by: ductnn <[email protected]>

* Update logs message for ECS routing stage rollback

Signed-off-by: ductnn <[email protected]>

---------

Signed-off-by: ductnn <[email protected]>
kentakozuka pushed a commit that referenced this pull request Jul 12, 2023
* Fix cannot remove canary created task

Signed-off-by: ductnn <[email protected]>

* Fix reuse clean function

Signed-off-by: ductnn <[email protected]>

* Update logs message for ECS routing stage rollback

Signed-off-by: ductnn <[email protected]>

---------

Signed-off-by: ductnn <[email protected]>
Signed-off-by: Kenta Kozuka <[email protected]>
kentakozuka added a commit that referenced this pull request Jul 12, 2023
)

* Update web deps (#4451)

Signed-off-by: khanhtc1202 <[email protected]>
Signed-off-by: Kenta Kozuka <[email protected]>

* Update quickstart to support arm hardware(ex: M1) (#4457)

* Add: arch selection for mysql image
Update chart values and templates for mysql deployment

Signed-off-by: gitbluf <[email protected]>

* Update: MySql image selector function to be more descriptive

Signed-off-by: gitbluf <[email protected]>

* Remove: mysql image set on piped installation

Signed-off-by: gitbluf <[email protected]>

* Update method name

Signed-off-by: gitbluf <[email protected]>

---------

Signed-off-by: gitbluf <[email protected]>
Signed-off-by: Kenta Kozuka <[email protected]>

* Support AWS LoadBalancer with multi listeners (#4462)

* Support AWS LoadBalancer with multi listeners

Signed-off-by: khanhtc1202 <[email protected]>

* Fix go array index

Signed-off-by: khanhtc1202 <[email protected]>

* Rename symbol

Signed-off-by: khanhtc1202 <[email protected]>

---------

Signed-off-by: khanhtc1202 <[email protected]>
Signed-off-by: Kenta Kozuka <[email protected]>

* Specify Version For Templating Tools (#4463)

* specify version for templating tools

Signed-off-by: Viet Anh Pham Nhu <[email protected]>

* Handle Error Both Install Helm And Kustomize

Signed-off-by: Viet Anh Pham Nhu <[email protected]>

---------

Signed-off-by: Viet Anh Pham Nhu <[email protected]>
Signed-off-by: Kenta Kozuka <[email protected]>

* Output usage only when flag parsing fails #4381 (#4464)

Signed-off-by: Yoshiki Fujikane <[email protected]>
Signed-off-by: Kenta Kozuka <[email protected]>

* Fix ECS rollback stage does not remove canary created tasks (#4465)

* Fix cannot remove canary created task

Signed-off-by: ductnn <[email protected]>

* Fix reuse clean function

Signed-off-by: ductnn <[email protected]>

* Update logs message for ECS routing stage rollback

Signed-off-by: ductnn <[email protected]>

---------

Signed-off-by: ductnn <[email protected]>
Signed-off-by: Kenta Kozuka <[email protected]>

* Update logs message for ECS routing stage executor (#4466)

Signed-off-by: khanhtc1202 <[email protected]>
Signed-off-by: Kenta Kozuka <[email protected]>

* fix: update deprecated apiVersion since gke removed (#4469)

GoogleCloudPlatform/gke-managed-certs#58

Signed-off-by: hungran <[email protected]>
Signed-off-by: Kenta Kozuka <[email protected]>

* Skip update AppState when no log updates (#4482)

Signed-off-by: Kenta Kozuka <[email protected]>

---------

Signed-off-by: khanhtc1202 <[email protected]>
Signed-off-by: Kenta Kozuka <[email protected]>
Signed-off-by: gitbluf <[email protected]>
Signed-off-by: Viet Anh Pham Nhu <[email protected]>
Signed-off-by: Yoshiki Fujikane <[email protected]>
Signed-off-by: ductnn <[email protected]>
Signed-off-by: hungran <[email protected]>
Co-authored-by: Khanh Tran <[email protected]>
Co-authored-by: Marko Petrovic <[email protected]>
Co-authored-by: Viet Anh Pham Nhu <[email protected]>
Co-authored-by: Yoshiki Fujikane <[email protected]>
Co-authored-by: Duc Tran <[email protected]>
Co-authored-by: Henry Vu <[email protected]>
Co-authored-by: Kurochan <[email protected]>
@github-actions github-actions bot mentioned this pull request Jul 12, 2023
@github-actions github-actions bot mentioned this pull request Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ECS] Cancel with rollback does not remove canary created tasks
3 participants