Skip to content

fix: Latest active release check takes into account release channels#349

Merged
adityachoudhari26 merged 3 commits intomainfrom
latest-active-release-fix
Feb 28, 2025
Merged

fix: Latest active release check takes into account release channels#349
adityachoudhari26 merged 3 commits intomainfrom
latest-active-release-fix

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented Feb 28, 2025

Summary by CodeRabbit

  • New Features
    • Improved release validation now ensures that only the most recent active release is recognized per environment, enhancing deployment reliability.
  • Refactor
    • Streamlined the sequencing process and trigger grouping to provide clearer, more efficient release management.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 28, 2025

Walkthrough

This change streamlines the release sequencing logic. A new asynchronous function, isReleaseLatestActiveForEnvironment, has been introduced to replace the previous subquery mechanism. It performs database queries to determine whether a given release is the latest active release for a specified environment. Additionally, the isPassingNewerThanLastActiveReleasePolicy function now utilizes this new method, with the database queries refined to include deployment and environment ID checks and proper ordering by creation date. Overall, the code has been simplified by removing redundant variables and streamlining data flow.

Changes

File Path Change Summary
packages/job-dispatch/src/policies/release-sequencing.ts - Added async isReleaseLatestActiveForEnvironment function to check the latest active release per environment.
- Modified isPassingNewerThanLastActiveReleasePolicy to use the new function.
- Streamlined database query logic and removed deprecated subquery.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant P as Release Policy Checker
    participant F as isReleaseLatestActiveForEnvironment
    participant DB as Database

    C->>P: Validate new release
    P->>F: Check if release is the latest active for environment
    F->>DB: Query environment & policy data
    DB-->>F: Return environment and policy details
    F->>DB: Fetch latest active release with deployment & environment criteria
    DB-->>F: Return latest active release record
    F-->>P: Return true/false based on release recency
    P-->>C: Return policy check result
Loading

Possibly related PRs

Suggested reviewers

  • jsbroks

Poem

In a burrow of code so deep,
I hopped along the runtime leap.
New functions dance in the moonlight gleam,
Chasing bugs like a carrot dream.
Hurray, dear changes, we work as a team!
🐰💻

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
  • @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.

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
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/job-dispatch/src/policies/release-sequencing.ts (2)

83-151: Handle potential creation date ties and confirm environment lookup logic.

If multiple releases share the same createdAt, this method relies solely on createdAt for comparison. Meanwhile, the earlier policy isPassingNoActiveJobsPolicy uses a tiebreak on version if multiple releases are created at the same time. Consider aligning these tie-breaking approaches for consistency.

Also, verify that returning false when the environment is not found is indeed the intended behavior. If the environment is missing or invalid, you might want to log or throw an error rather than silently returning false.


170-186: Avoid repeated environment queries for each trigger group.

This logic calls isReleaseLatestActiveForEnvironment (and thus re-queries the environment) once per grouped set of triggers. If the same environment is reused across many triggers, consider caching or memoizing the environment fetch in memory to reduce DB calls.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c103110 and 77310f8.

📒 Files selected for processing (1)
  • packages/job-dispatch/src/policies/release-sequencing.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{ts,tsx}`: **Note on Error Handling:** Avoid strict en...

**/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

  • packages/job-dispatch/src/policies/release-sequencing.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Lint
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Typecheck
🔇 Additional comments (2)
packages/job-dispatch/src/policies/release-sequencing.ts (2)

7-7: No concerns with introducing 'desc' into the import list.


14-14: Usage of takeFirstOrNull looks fine.

@adityachoudhari26 adityachoudhari26 merged commit 14e43c4 into main Feb 28, 2025
8 checks passed
@adityachoudhari26 adityachoudhari26 deleted the latest-active-release-fix branch February 28, 2025 17:54
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.

1 participant