8000 fix: (temporal) skip deleting workflows when they are already completed by laouji · Pull Request #272 · formancehq/payments · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: (temporal) skip deleting workflows when they are already completed #272

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

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

laouji
Copy link
Contributor
@laouji laouji commented Jan 22, 2025

If a schedule doesn't exist anymore (was previously terminated manually or otherwise) we get an infinite loop in the connector uninstall child workflow with this error:

time="2025-01-22T10:58:21Z" level=error msg="Activity error." ActivityType=TemporalDeleteSchedule Attempt=34 Error="workflow execution already completed" Namespace=<redacted> RunID=55d36adb-6fb9-4fbe-b4e1-6ec947807374 TaskQueue=vnqazlblsytk-eoda-default WorkerID=1@payments-worker-7648b957b7-7zpr8@ WorkflowID=1cc2f97f-8423-4831-bd35-5cd14c9eec5b_5

Was able to confirm we can catch the serviceerror.NotFound type correctly using the debug message:

time="2025-01-22T12:25:08Z" level=debug msg="skipping deletion of schedule \"shabryttvape-pvuw-eyJQcm92aWRlciI6Im1vbmV5Y29ycCIsIlJlZmVyZW5jZSI6Ijc2M2VhYWU3LTRhY2EtNDIyZC1hMmFlLTcyODkzMTM5MzRhOCJ9-FETCH_BALANCES-3903\" due to:  workflow execution already completed"

Copy link
Contributor
coderabbitai bot commented Jan 22, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces a comprehensive set of mock implementations for client interfaces in the Temporal SDK, specifically within the activities package. The changes include generating mock clients for Client, CloudOperationsClient, NamespaceClient, ScheduleClient, and ScheduleHandle. These mock implementations are created using the MockGen tool and provide testing utilities that allow developers to simulate client behaviors without making actual service calls. Additionally, the PR includes improved error handling for schedule deletion and corresponding unit tests.

Changes

File Change Summary
internal/connectors/engine/activities/client_generated.go Added mock implementations for Temporal SDK clients with methods for workflow execution, activity management, and various client operations
internal/connectors/engine/activities/schedule_client.go Defined interfaces for ScheduleClient and ScheduleHandle with methods for schedule management
internal/connectors/engine/activities/schedule_client_generated.go Generated mock implementations for schedule-related interfaces
internal/connectors/engine/activities/temporal_schedule_delete.go Enhanced error handling for schedule deletion, adding support for notFoundErr
internal/connectors/engine/activities/temporal_schedule_delete_test.go Added unit tests for TemporalScheduleDelete function with various error scenarios

Possibly related PRs

Poem

🐰 Mock Clients Hop and Dance

In Temporal's testing expanse,
Interfaces mocked with glee,
No real calls, just mockery!

Schedules delete, errors take flight,
Our rabbit testers shine so bright! 🧪


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6ec3c0 and a63e01f.

⛔ Files ignored due to path filters (1)
  • go.mod is excluded by !**/*.mod
📒 Files selected for processing (5)
  • internal/connectors/engine/activities/client_generated.go (1 hunks)
  • internal/connectors/engine/activities/schedule_client.go (1 hunks)
  • internal/connectors/engine/activities/schedule_client_generated.go (1 hunks)
  • internal/connectors/engine/activities/temporal_schedule_delete.go (2 hunks)
  • internal/connectors/engine/activities/temporal_schedule_delete_test.go (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 8.75912% with 500 lines in your changes missing coverage. Please review.

Project coverage is 71.60%. Comparing base (291efa7) to head (a63e01f).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...l/connectors/engine/activities/client_generated.go 3.18% 425 Missing ⚠️
...ors/engine/activities/schedule_client_generated.go 27.18% 75 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #272      +/-   ##
==========================================
- Coverage   72.86%   71.60%   -1.26%     
==========================================
  Files         538      540       +2     
  Lines       26986    27532     +546     
==========================================
+ Hits        19664    19715      +51     
- Misses       6259     6754     +495     
  Partials     1063     1063              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@laouji laouji force-pushed the fix/delete-workflow-not-found branch from bba4a3e to d2fd48f Compare January 22, 2025 13:22
@laouji laouji force-pushed the fix/delete-workflow-not-found branch from d2fd48f to a63e01f Compare January 22, 2025 13:26
@laouji laouji marked this pull request as ready for review January 22, 2025 13:31
@laouji laouji requested a review from a team as a code owner January 22, 2025 13:31
@@ -13,16 +14,20 @@ func (a Activities) TemporalScheduleDelete(ctx context.Context, scheduleID strin
err := handle.Delete(ctx)
if err != nil {
var applicationErr *temporal.ApplicationError
var notFoundErr *serviceerror.NotFound
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch !

@laouji laouji merged commit be87eb0 into main Jan 22, 2025
6 of 9 checks passed
@laouji laouji deleted the fix/delete-workflow-not-found branch January 22, 2025 13:34
@@ -0,0 +1,792 @@
// Code generated by MockGen. DO NOT EDIT.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add this file in the exclude files of code coverage ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0