Skip to content

Conversation

@adityachoudhari26
Copy link
Contributor

@adityachoudhari26 adityachoudhari26 commented May 6, 2025

Summary by CodeRabbit

  • New Features

    • Added concurrency checks to prevent multiple active jobs for the same release target.
    • Introduced asynchronous handling in rule evaluation for improved accuracy.
    • Enhanced job update process to trigger release target evaluation via event queueing.
    • Added UI indication when a deployment version is blocked by active jobs from other releases.
    • Added API endpoint to fetch active jobs grouped by release target with access control.
  • Bug Fixes

    • Improved rule evaluation to correctly handle asynchronous pre-validation logic, ensuring accurate results during release processing.
  • Chores

    • Removed legacy job completion and failure handlers to streamline job processing logic.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 6, 2025

Walkthrough

The changes introduce a new ReleaseTargetConcurrencyRule class to enforce concurrency constraints on release targets. The rule is integrated into the rule evaluation process by updating function signatures and method calls to accept a releaseTargetId. The PreValidationRule interface and its usage are updated to support asynchronous validation logic. Additionally, job completion and failure handling logic is refactored: the previous onJobCompletion and onJobFailure functions are removed, and job update processing now enqueues evaluation tasks for release targets instead of directly invoking these handlers.

Changes

File(s) Change Summary
packages/rule-engine/src/manager/version-manager-rules.ts Updated getRules to accept releaseTargetId and prepend ReleaseTargetConcurrencyRule to returned rules.
packages/rule-engine/src/manager/version-manager.ts Modified call to getRules in VersionReleaseManager.evaluate to pass releaseTarget.id.
packages/rule-engine/src/manager/version-rule-engine.ts Made pre-validation rule evaluation asynchronous by awaiting rule.passing().
packages/rule-engine/src/rules/release-target-concurrency-rule.ts Added new ReleaseTargetConcurrencyRule class implementing concurrency checks for release targets.
packages/rule-engine/src/types.ts Updated PreValidationRule.passing() to allow returning a promise for asynchronous validation logic.
packages/job-dispatch/src/job-creation.ts Removed onJobCompletion function and related imports handling dependent job triggers on job completion.
packages/job-dispatch/src/job-failure.ts Removed entire file including onJobFailure function handling job failure retries and related triggers.
packages/job-dispatch/src/job-update.ts Refactored updateJob to remove direct calls to onJobCompletion and onJobFailure; added logic to enqueue release target evaluation on job completion. Added helper functions getIsJobJustCompleted and getReleaseTarget.
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/DeploymentVersionEnvironmentCell.tsx Added BlockedByActiveJobsCell component and integrated active jobs query with conditional UI blocking logic.
packages/api/src/router/release-target.ts Added new protected procedure activeJobs to query and return active jobs grouped by release target with authorization checks.

Sequence Diagram(s)

sequenceDiagram
    participant Manager as VersionReleaseManager
    participant Rules as getRules
    participant Concurrency as ReleaseTargetConcurrencyRule
    participant Engine as VersionRuleEngine

    Manager->>Rules: getRules(policy, releaseTarget.id)
    Rules->>Concurrency: new ReleaseTargetConcurrencyRule(releaseTarget.id)
    Rules-->>Manager: [ReleaseTargetConcurrencyRule, ...otherRules]
    Manager->>Engine: evaluate(rules)
    loop For each pre-validation rule
        Engine->>Concurrency: await rule.passing()
        Concurrency->>Concurrency: Query DB for active jobs
        Concurrency-->>Engine: { passing: true/false, rejectionReason? }
    end
Loading
sequenceDiagram
    participant JobUpdate as updateJob
    participant DB as Database
    participant Queue as EventQueue

    JobUpdate->>JobUpdate: getIsJobJustCompleted(previousStatus, newStatus)
    alt Job just completed
        JobUpdate->>DB: getReleaseTarget(jobId)
        DB-->>JobUpdate: releaseTarget data
        JobUpdate->>Queue: enqueue EvaluateReleaseTarget with releaseTarget key and data
    else Job not completed
        JobUpdate-->>JobUpdate: return early
    end
Loading

Suggested reviewers

  • jsbroks

Poem

In the warren of code, a new rule appears,
To check for busy burrows and job frontiers.
Now with async hops, our checks are quite spry,
No two bunnies collide as their releases fly!
With concurrency guarded, the meadow feels right—
All thanks to teamwork, and code shining bright. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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
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 (1)
packages/rule-engine/src/rules/release-target-concurrency-rule.ts (1)

1-42: Consider adding a comment describing the rule's purpose.

While the code is well-structured and self-documenting, a brief class-level JSDoc comment explaining the rule's purpose and behavior would enhance maintainability for future developers.

import { and, eq, notInArray, takeFirstOrNull } from "@ctrlplane/db";
import { db } from "@ctrlplane/db/client";
import * as schema from "@ctrlplane/db/schema";
import { exitedStatus } from "@ctrlplane/validators/jobs";

import type { PreValidationRule } from "../types";

+/**
+ * Rule that prevents concurrent jobs for the same release target.
+ * Fails validation if there are any active (non-exited status) jobs
+ * already associated with the specified release target ID.
+ */
export class ReleaseTargetConcurrencyRule implements PreValidationRule {
  public readonly name = "ReleaseTargetConcurrencyRule";
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fce18c1 and 237f3be.

📒 Files selected for processing (5)
  • packages/rule-engine/src/manager/version-manager-rules.ts (2 hunks)
  • packages/rule-engine/src/manager/version-manager.ts (1 hunks)
  • packages/rule-engine/src/manager/version-rule-engine.ts (1 hunks)
  • packages/rule-engine/src/rules/release-target-concurrency-rule.ts (1 hunks)
  • packages/rule-engine/src/types.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{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...

**/*.{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/rule-engine/src/types.ts
  • packages/rule-engine/src/manager/version-rule-engine.ts
  • packages/rule-engine/src/manager/version-manager.ts
  • packages/rule-engine/src/rules/release-target-concurrency-rule.ts
  • packages/rule-engine/src/manager/version-manager-rules.ts
🧬 Code Graph Analysis (1)
packages/rule-engine/src/manager/version-manager-rules.ts (4)
packages/rule-engine/src/types.ts (2)
  • FilterRule (31-36)
  • PreValidationRule (43-46)
packages/rule-engine/src/manager/version-rule-engine.ts (1)
  • Version (11-17)
packages/rule-engine/src/rules/release-target-concurrency-rule.ts (1)
  • ReleaseTargetConcurrencyRule (8-42)
packages/db/src/schema/policy.ts (1)
  • policy (42-62)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Typecheck
  • GitHub Check: Lint
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
🔇 Additional comments (11)
packages/rule-engine/src/types.ts (1)

45-45: Good update to support asynchronous rule validation.

The interface now allows passing() to return either a synchronous PreValidationResult or a Promise<PreValidationResult>, enabling asynchronous validation operations like database queries. This change correctly enables the new release target concurrency implementation.

packages/rule-engine/src/manager/version-rule-engine.ts (1)

65-65: Correctly added await to handle async validation.

Adding the await keyword ensures proper handling of the potentially asynchronous passing() method that was updated in the PreValidationRule interface. This is necessary for the new concurrency rule to work correctly.

packages/rule-engine/src/manager/version-manager.ts (1)

168-168: Properly added releaseTargetId parameter to rule creation.

The evaluate method now correctly passes this.releaseTarget.id to the getRules function, enabling the creation of the release target concurrency validation rule with the appropriate ID to check for active jobs.

packages/rule-engine/src/manager/version-manager-rules.ts (3)

4-4: Added import for the new concurrency rule.

The import for ReleaseTargetConcurrencyRule is correctly added to support the implementation.


70-73: Updated getRules function signature correctly.

The function now accepts a releaseTargetId parameter, which is necessary for creating the concurrency rule that checks for active jobs on a specific release target.


74-78: Properly integrated the concurrency rule with existing validation.

The implementation correctly prepends a new instance of ReleaseTargetConcurrencyRule to the existing list of version approval rules. This ensures concurrency validation happens before other approval rules are evaluated, which is an appropriate order of operations.

packages/rule-engine/src/rules/release-target-concurrency-rule.ts (5)

1-5: Good job with the imports.

The imports are well-organized, separating external database-related utilities from schema definitions and validators. The exitedStatus import will be used effectively to filter out jobs that have already completed.


8-11: Clear class definition with descriptive name.

The class properly implements the PreValidationRule interface and has a clear, self-documenting name that indicates its purpose. The readonly name property provides good identification for logging and debugging.


11-11: Constructor is concise and effective.

Good use of TypeScript's private readonly parameter to ensure the releaseTargetId is immutable and properly encapsulated within the class.


13-34: Well-structured database query.

The database query is well-constructed with clear joins between the necessary tables to find active jobs for the specified release target. The use of limit(1) and takeFirstOrNull is efficient since you only need to know if any active job exists.

The Promise chain approach is clean and aligns with the coding guidelines that allow for various error handling patterns beyond strict try/catch blocks.


35-41: Clear response handling with informative error message.

The method provides appropriate responses for both success and failure cases. The rejection reason includes the releaseTargetId, which will be helpful for debugging and error reporting.

Copy link
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: 2

🔭 Outside diff range comments (1)
packages/job-dispatch/src/job-creation.ts (1)

31-33: 🛠️ Refactor suggestion

_.merge mutates jobAgent.config – may leak state between jobs

Using _.merge(jobAgent.config, runbook.jobAgentConfig) directly modifies jobAgent.config in-place.
If the same jobAgent object is reused elsewhere in the current transaction (or cached after the call), its config will now include runbook-specific overrides, leading to very hard-to-trace bugs.

-      jobAgentConfig: _.merge(jobAgent.config, runbook.jobAgentConfig),
+      // clone first to avoid mutating values coming from the DB layer
+      jobAgentConfig: _.merge({}, jobAgent.config, runbook.jobAgentConfig),
🧹 Nitpick comments (2)
packages/job-dispatch/src/job-creation.ts (1)

14-17: Typo in log message hurts observability

"Triger triggered runbook job …" contains a misspelling (Triger). Small, but log lines are often grepped verbatim; the typo makes searches harder.

-logger.info(`Triger triggered runbook job ${runbook.name}`, {
+logger.info(`Triggering runbook job ${runbook.name}`, {
packages/job-dispatch/src/job-update.ts (1)

84-91: Minor: replace linear-search array with Set for O(1) lookup

exitedStatus.includes(…) is fine for small arrays, but since this helper can be called on every job update, switching to a Set removes the repeated linear scan.

-const getIsJobJustCompleted = (
-  previousStatus: JobStatus,
-  newStatus: JobStatus,
-) => {
-  const isPreviousStatusExited = exitedStatus.includes(previousStatus);
-  const isNewStatusExited = exitedStatus.includes(newStatus);
-  return !isPreviousStatusExited && isNewStatusExited;
-};
+const exitedStatusSet = new Set<JobStatus>(exitedStatus);
+const getIsJobJustCompleted = (
+  previousStatus: JobStatus,
+  newStatus: JobStatus,
+) =>
+  !exitedStatusSet.has(previousStatus) && exitedStatusSet.has(newStatus);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 237f3be and 105e5ea.

📒 Files selected for processing (3)
  • packages/job-dispatch/src/job-creation.ts (1 hunks)
  • packages/job-dispatch/src/job-failure.ts (0 hunks)
  • packages/job-dispatch/src/job-update.ts (3 hunks)
💤 Files with no reviewable changes (1)
  • packages/job-dispatch/src/job-failure.ts
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{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...

**/*.{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/job-creation.ts
  • packages/job-dispatch/src/job-update.ts
🧬 Code Graph Analysis (1)
packages/job-dispatch/src/job-update.ts (6)
packages/db/src/schema/job.ts (1)
  • JobStatus (141-141)
packages/validators/src/jobs/index.ts (1)
  • exitedStatus (35-43)
packages/db/src/client.ts (1)
  • db (15-15)
packages/db/src/common.ts (1)
  • takeFirst (9-13)
packages/db/src/schema/release.ts (1)
  • releaseTarget (20-42)
packages/events/src/index.ts (1)
  • getQueue (28-34)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Lint
  • GitHub Check: Typecheck
🔇 Additional comments (1)
packages/job-dispatch/src/job-update.ts (1)

6-6:

✅ Verification successful

Ensure Channel.EvaluateReleaseTarget exists

The new import expects Channel to expose an EvaluateReleaseTarget member.
A missing enum entry will surface only at runtime in JavaScript output, so please double-check.

Run:


🏁 Script executed:

#!/usr/bin/env bash
# Expect at least one occurrence of the enum/key.
rg -A3 -N "enum.+Channel" | grep -n "EvaluateReleaseTarget"

Length of output: 57


🏁 Script executed:

#!/usr/bin/env bash
# Locate the definition of Channel in the events package
rg -n "export enum Channel" -A5
rg -n "export type Channel" -A5

# Search for any occurrence of EvaluateReleaseTarget
rg -n "EvaluateReleaseTarget"

Length of output: 2500


Confirmed: Channel.EvaluateReleaseTarget Is Defined
The Channel enum in packages/events/src/types.ts (line 32) includes an EvaluateReleaseTarget member, so importing Channel.EvaluateReleaseTarget from @ctrlplane/events is valid—no changes needed.

Copy link
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 (1)
packages/job-dispatch/src/job-update.ts (1)

151-156: Properly handles missing release targets

The implementation now includes a null check before enqueueing the evaluation task, addressing the concern raised in the previous review. This ensures that non-release jobs won't cause errors during the update process.

Consider adding a debug log when no release target is found, similar to what was suggested in the previous review:

  const releaseTarget = await getReleaseTarget(db, jobId);
-  if (releaseTarget == null) return updatedJob;
+  if (releaseTarget == null) {
+    log.debug(`Job ${jobId} is not part of a release pipeline – skipping release-target evaluation`);
+    return updatedJob;
+  }
  await getQueue(Channel.EvaluateReleaseTarget).add(
    `${releaseTarget.resourceId}-${releaseTarget.environmentId}-${releaseTarget.deploymentId}`,
    releaseTarget,
  );
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 105e5ea and e328e7e.

📒 Files selected for processing (1)
  • packages/job-dispatch/src/job-update.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{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...

**/*.{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/job-update.ts
🧬 Code Graph Analysis (1)
packages/job-dispatch/src/job-update.ts (6)
packages/db/src/schema/job.ts (1)
  • JobStatus (141-141)
packages/validators/src/jobs/index.ts (1)
  • exitedStatus (35-43)
packages/db/src/client.ts (1)
  • db (15-15)
packages/db/src/common.ts (1)
  • takeFirstOrNull (15-20)
packages/db/src/schema/release.ts (1)
  • releaseTarget (20-42)
packages/events/src/index.ts (1)
  • getQueue (28-34)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Typecheck
  • GitHub Check: Lint
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
🔇 Additional comments (4)
packages/job-dispatch/src/job-update.ts (4)

3-3: Added new import for better error handling

The addition of takeFirstOrNull is a good improvement for error handling as it allows gracefully handling cases where no matching records are found instead of throwing exceptions.


84-91: Good extraction of job completion detection logic

This helper function cleanly encapsulates the logic for detecting when a job transitions into a completed state. The implementation correctly checks if a job has moved from a non-exited state to an exited state.


93-114: Well-structured database query with proper error handling

This function properly retrieves release target information using a series of joins, and importantly, uses takeFirstOrNull to handle cases where no release target is found (non-release jobs). This addresses the issues raised in previous reviews.


145-149: Clean implementation of job completion detection

The code now uses the extracted helper function to clearly check for job completion, making the logic more readable and maintainable.

Copy link
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/api/src/router/release-target.ts (1)

164-174: Consider adding error handling for the data transformation.

While the data transformation using lodash is well-structured, it assumes that jobsByTarget[0] will always exist when accessing releaseTarget. Although this is likely true given the query structure, adding a defensive check would improve robustness.

-          const releaseTarget = jobsByTarget[0]!.release_target;
+          const releaseTarget = jobsByTarget[0]?.release_target;
+          if (!releaseTarget) {
+            return null;
+          }

Then filter out nulls before returning:

-        .value();
+        .filter(Boolean)
+        .value();
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/DeploymentVersionEnvironmentCell.tsx (1)

198-201: Consider adding null check before flatMap operation.

While targetsWithActiveJobs ?? [] provides a default empty array if the data is null, it would be more explicit to check for null/undefined before calling flatMap.

-  const allActiveJobs = (targetsWithActiveJobs ?? []).flatMap((t) => t.jobs);
+  const allActiveJobs = targetsWithActiveJobs 
+    ? targetsWithActiveJobs.flatMap((t) => t.jobs ?? [])
+    : [];
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e328e7e and 81ccf19.

📒 Files selected for processing (2)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/DeploymentVersionEnvironmentCell.tsx (5 hunks)
  • packages/api/src/router/release-target.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{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...

**/*.{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/api/src/router/release-target.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/DeploymentVersionEnvironmentCell.tsx
🧬 Code Graph Analysis (1)
packages/api/src/router/release-target.ts (4)
packages/api/src/trpc.ts (1)
  • protectedProcedure (173-173)
packages/validators/src/jobs/index.ts (1)
  • exitedStatus (35-43)
packages/db/src/schema/job.ts (1)
  • job (75-107)
packages/db/src/schema/release.ts (1)
  • releaseTarget (20-42)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Typecheck
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Lint
🔇 Additional comments (8)
packages/api/src/router/release-target.ts (3)

1-1: Appropriate use of lodash for data transformation.

The addition of lodash is well-justified for the complex data transformation operations performed in the new activeJobs procedure.


5-8: Import additions support the new query functionality.

The added imports (notInArray and exitedStatus) are appropriately used to filter out completed jobs in the query.


83-175: Well-implemented active jobs query with proper authorization.

The new activeJobs procedure follows good patterns:

  • Reuses the same input validation and authorization logic as the existing procedures
  • Properly joins necessary tables to fetch active jobs
  • Uses the exitedStatus array to filter for non-completed jobs
  • Effectively transforms the data using lodash for grouping by target

The query properly handles optional filter parameters and returns a well-structured response that includes both release target data and its associated jobs.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/DeploymentVersionEnvironmentCell.tsx (5)

7-7: Added necessary icon import.

The IconClock addition is appropriate for the new blocked state visualization.


50-83: Well-implemented blocking component with clear user feedback.

The BlockedByActiveJobsCell component provides:

  • Clear visual indication of the blocked state with an appropriate icon
  • Helpful message explaining why the version is blocked
  • A link to the deployment's releases page where users can view active jobs

This provides good UX by not only showing that something is blocked but also directing users to where they can see more information.


133-140: Added query for active jobs with proper loading state handling.

The implementation of the activeJobs query is appropriate, fetching data based on the current environment and deployment context.


153-158: Correctly updated loading condition.

The loading state was properly updated to include the new query's loading status.


198-203: Clear implementation of blocking logic.

The implementation:

  1. Flattens all jobs from all targets
  2. Checks if any jobs belong to a different version than the current one
  3. Renders the blocking component when appropriate

This correctly implements the concurrency constraint in the UI.

@adityachoudhari26 adityachoudhari26 merged commit df766fb into main May 6, 2025
8 of 9 checks passed
@adityachoudhari26 adityachoudhari26 deleted the release-target-concurrency-prevalidation branch May 6, 2025 21:22
@coderabbitai coderabbitai bot mentioned this pull request May 22, 2025
@coderabbitai coderabbitai bot mentioned this pull request May 31, 2025
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