Skip to content

Conversation

@edragain2nd
Copy link
Contributor

@edragain2nd edragain2nd commented Oct 17, 2025

Summary by CodeRabbit

  • New Features

    • Added deadline support across submit/run/update/allocate/queue commands with new --deadline flags.
    • Deadlines shown in listings as an optional "Deadline" column and via %deadline/%Deadline in custom formats; displayed in local time or "unknown" when unset.
    • Update command can modify job deadlines independently; invalid deadline inputs yield a clear "Invalid deadline" error.
  • Documentation

    • Help text and examples updated to document the new deadline option.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 17, 2025

Walkthrough

Adds end-to-end deadline support: protobuf fields and enums, RPC renames for time-constraint APIs, CLI flags across clients, parsing/wiring of deadline timestamps into task messages, display processors/columns, and control-plane ModifyTask deadline update.

Changes

Cohort / File(s) Summary
Protocol definitions
protos/Crane.proto, protos/PublicDefs.proto, protos/Supervisor.proto
Add deadline_time Timestamp fields to task/step/request messages; add Deadline TaskStatus and ERR_INVALID_DEADLINE; rename ChangeJobTimeLimit/ChangeTaskTimeLimit → ChangeJobTimeConstraint/ChangeTaskTimeConstraint and add deadline fields to constraint requests.
CLI flags / wiring
internal/*/cmd.go
internal/cacct/cmd.go, internal/cbatch/cmd.go, internal/cqueue/cmd.go, internal/calloc/cmd.go, internal/crun/cmd.go
Add FlagDeadlineTime variables and register --deadline flags across client commands.
Account & queue display
internal/cacct/cacct.go, internal/cqueue/format.go, internal/cqueue/output.go, internal/cacct/cmd.go
Add ProcessDeadline processor, register "deadline" field, update help/format strings, and append Deadline column/value in full and dynamic outputs when enabled.
Batch/submit parsing
internal/cbatch/line.go, internal/cbatch/cbatch.go
Recognize --deadline script option and CLI flag, parse into task.DeadlineTime, and reuse existing error handling patterns.
Allocation/runtime submission
internal/calloc/calloc.go, internal/crun/crun.go
Parse --deadline flag in calloc/crun flows, set task.DeadlineTime = timestamppb.New(...) or return command-arg error on parse failure.
Control plane / update logic
internal/ccontrol/ccontrol.go, internal/ccontrol/cmd.go, internal/ccontrol/help.go
Add DeadlineTypeFlag and ChangeDeadlineTime function; parse deadline=<...> in update params; construct ModifyTaskRequest with Deadline attribute and deadline_time timestamp; call RPC and handle replies/errors.
Utilities / errors
internal/util/util.go, internal/util/err.go
Add exported InfiniteFuture sentinel time and map ERR_INVALID_DEADLINE to an error message.
Misc changes
internal/cacct/*, internal/*/cmd.go (various)
Help/format string updates and small formatting tweaks to include the new %deadline/%Deadline specifiers and CLI guidance.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant CLI
  participant Ctld as Ctld(gRPC)
  participant Supervisor

  rect rgb(245,250,255)
    Note over User,CLI: User supplies --deadline or update param deadline=<t>
  end

  User->>CLI: run submit/update with deadline
  CLI->>CLI: parse deadline string (util.ParseTime)
  CLI->>CLI: create google.protobuf.Timestamp (timestamppb.New)
  CLI->>Ctld: SubmitTask / ModifyTask (include deadline_time)
  Ctld->>Supervisor: forward deadline_time in internal RPC
  Ctld-->>CLI: Reply (ok / error)
  alt success
    CLI->>User: print success
  else parse/RPC error
    CLI->>User: print error (invalid deadline / ERR_INVALID_DEADLINE)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to protobuf renames/field numbering and generated code implications.
  • Inspect ModifyTaskRequest Deadline enum/value wiring and UpdateJob path in ccontrol for consistent enum use.
  • Verify util.InfiniteFuture usage and timezone/local formatting in ProcessDeadline.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • L-Xiafeng
  • NamelessOIer
  • RileyWen

Poem

🐰 I hopped through flags and protobuf lines,

Planted deadlines where the scheduler pines.
From CLI parse to Ctld's reply,
Timestamps hum as jobs pass by.
A tiny hop — now time is wise.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'feat: cbatch --deadline' is misleading. While the PR does add deadline support to cbatch, it actually implements deadline functionality across multiple CLI tools (cacct, cbatch, cqueue, calloc, crun, ccontrol) and updates core protobuf definitions. The title suggests the change is limited to cbatch only. Revise the title to reflect the broader scope, such as 'feat: add deadline support across CLI tools' or 'feat: implement deadline time constraints for jobs'.
Docstring Coverage ⚠️ Warning Docstring coverage is 18.75% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 3

🧹 Nitpick comments (2)
internal/cbatch/cbatch.go (2)

125-131: Remove redundant error logging.

Line 128 logs an error that's immediately returned with proper formatting on line 129. This redundant logging is unnecessary since the error message already provides sufficient context.

Apply this diff to remove redundant logging:

 	case "--deadline":
 		deadlineTime, err := util.ParseTime(arg.val)
 		if err != nil {
-			log.Errorf("Invalid argument: %v in script: %v", arg.name, err)
 			return nil, fmt.Errorf("invalid argument: %s value '%s' in script: %w", arg.name, arg.val, err)
 		}
 		task.DeadlineTime = timestamppb.New(deadlineTime)

313-320: Remove redundant error logging.

Line 316 logs an error that's immediately returned with proper formatting on line 317. This redundant logging is unnecessary since the error message already provides sufficient context.

Apply this diff to remove redundant logging:

 	if FlagDeadlineTime != "" {
 		deadlineTime, err := util.ParseTime(FlagDeadlineTime)
 		if err != nil {
-			log.Errorf("Invalid argument: invalid --deadline: %v", err)
 			return nil, fmt.Errorf("invalid argument: invalid --deadline value '%s': %w", FlagDeadlineTime, err)
 		}
 		task.DeadlineTime = timestamppb.New(deadlineTime)
 	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between babf743 and b4f46a8.

📒 Files selected for processing (14)
  • internal/cacct/cacct.go (7 hunks)
  • internal/cacct/cmd.go (3 hunks)
  • internal/cbatch/cbatch.go (2 hunks)
  • internal/cbatch/cmd.go (2 hunks)
  • internal/cbatch/line.go (1 hunks)
  • internal/ccontrol/ccontrol.go (6 hunks)
  • internal/ccontrol/cmd.go (3 hunks)
  • internal/ccontrol/help.go (1 hunks)
  • internal/cqueue/cmd.go (3 hunks)
  • internal/cqueue/format.go (2 hunks)
  • internal/cqueue/output.go (3 hunks)
  • protos/Crane.proto (4 hunks)
  • protos/PublicDefs.proto (5 hunks)
  • protos/Supervisor.proto (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (9)
internal/ccontrol/cmd.go (5)
internal/ccontrol/ccontrol.go (2)
  • DeadlineTypeFlag (55-55)
  • ChangeDeadlineTime (638-680)
internal/cbatch/cmd.go (1)
  • FlagDeadlineTime (70-70)
internal/cacct/cmd.go (1)
  • FlagDeadlineTime (44-44)
internal/cqueue/cmd.go (1)
  • FlagDeadlineTime (32-32)
internal/util/err.go (1)
  • ErrorGeneric (35-35)
internal/cbatch/cmd.go (3)
internal/cacct/cmd.go (1)
  • FlagDeadlineTime (44-44)
internal/cqueue/cmd.go (1)
  • FlagDeadlineTime (32-32)
internal/ccontrol/cmd.go (1)
  • FlagDeadlineTime (53-53)
internal/cacct/cmd.go (3)
internal/cbatch/cmd.go (1)
  • FlagDeadlineTime (70-70)
internal/cqueue/cmd.go (1)
  • FlagDeadlineTime (32-32)
internal/ccontrol/cmd.go (1)
  • FlagDeadlineTime (53-53)
internal/cbatch/cbatch.go (2)
internal/util/string.go (1)
  • ParseTime (377-436)
internal/cbatch/cmd.go (1)
  • FlagDeadlineTime (70-70)
internal/cqueue/output.go (4)
internal/cacct/cacct.go (1)
  • ProcessDeadline (388-394)
internal/cqueue/format.go (1)
  • ProcessDeadline (33-39)
internal/cacct/cmd.go (1)
  • FlagDeadlineTime (44-44)
internal/cqueue/cmd.go (1)
  • FlagDeadlineTime (32-32)
internal/cqueue/format.go (1)
internal/cacct/cacct.go (1)
  • ProcessDeadline (388-394)
internal/cqueue/cmd.go (3)
internal/cbatch/cmd.go (1)
  • FlagDeadlineTime (70-70)
internal/cacct/cmd.go (1)
  • FlagDeadlineTime (44-44)
internal/ccontrol/cmd.go (1)
  • FlagDeadlineTime (53-53)
internal/cacct/cacct.go (3)
internal/cacct/cmd.go (1)
  • FlagDeadlineTime (44-44)
internal/cqueue/cmd.go (1)
  • FlagDeadlineTime (32-32)
internal/cqueue/format.go (1)
  • ProcessDeadline (33-39)
internal/ccontrol/ccontrol.go (5)
internal/util/string.go (2)
  • ParseTime (377-436)
  • ParseJobIdList (1066-1078)
internal/util/err.go (4)
  • CraneError (43-47)
  • ErrorCmdArg (36-36)
  • ErrorNetwork (37-37)
  • ErrorBackend (38-38)
internal/util/grpc.go (1)
  • GrpcErrorPrintf (387-398)
internal/ccontrol/cmd.go (1)
  • FlagJson (45-45)
internal/util/formatter.go (1)
  • FmtJson (58-58)
🔇 Additional comments (12)
internal/ccontrol/help.go (1)

67-75: LGTM! Clear documentation for the new deadline parameter.

The help text additions are well-formatted and consistent with the existing parameter documentation style.

protos/PublicDefs.proto (2)

118-118: LGTM! New task status enum value added correctly.

The Deadline = 7 status value fits logically with the existing task termination states (Completed, Failed, ExceedTimeLimit, Cancelled, OutOfMemory).


174-174: LGTM! Deadline fields added consistently across protocol messages.

The deadline_time fields are added to all relevant task-related messages (TaskToCtld, TaskToD, TaskInfo) with appropriate field numbers and consistent use of google.protobuf.Timestamp type.

Also applies to: 221-221, 336-336

internal/cbatch/line.go (1)

67-67: LGTM! Deadline option properly registered for Slurm compatibility.

The --deadline flag is correctly added to the supported options map, enabling batch scripts to specify deadlines via #SBATCH --deadline directives.

internal/cqueue/cmd.go (2)

32-32: LGTM! Deadline display flag added appropriately.

The boolean FlagDeadlineTime is correctly used as a display toggle for cqueue (to show/hide the deadline column), which differs appropriately from cbatch/ccontrol where it's a string value to set.

Also applies to: 99-99


116-116: LGTM! Format specifier documentation added clearly.

The %deadline/%Deadline format tokens are documented consistently with the existing format specifier help text.

internal/cqueue/format.go (1)

199-200: LGTM! Deadline field processor registered correctly.

The deadline field is properly added to the field map with appropriate header and processor function.

internal/cqueue/output.go (2)

55-55: LGTM! Deadline column integrated into full table mode.

The deadline column is correctly added to both the header and row data for full-mode display.

Also applies to: 84-84


129-134: LGTM! Dynamic deadline column properly gated by flag.

The conditional deadline column addition follows the established pattern for dynamic columns (like StartTime and QoS).

internal/cacct/cmd.go (2)

44-44: LGTM! Deadline display flag added consistently.

The boolean flag for toggling deadline visibility is implemented consistently with the cqueue module.

Also applies to: 111-111


126-126: LGTM! Format specifier documentation added.

The deadline format token is documented clearly in the help text.

internal/cbatch/cmd.go (1)

69-70: LGTM! Deadline flag added appropriately for batch submission.

The string-typed FlagDeadlineTime is correctly used to accept a deadline value for job submission, which appropriately differs from the boolean display flags in cqueue/cacct.

Also applies to: 160-160

Copy link
Collaborator

@L-Xiafeng L-Xiafeng left a comment

Choose a reason for hiding this comment

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

crun/calloc没加deadline选项

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: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b4f46a8 and 02318f4.

📒 Files selected for processing (6)
  • internal/cacct/cacct.go (7 hunks)
  • internal/calloc/calloc.go (2 hunks)
  • internal/calloc/cmd.go (3 hunks)
  • internal/cqueue/format.go (2 hunks)
  • internal/crun/cmd.go (3 hunks)
  • internal/crun/crun.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/cqueue/format.go
🧰 Additional context used
🧬 Code graph analysis (5)
internal/calloc/cmd.go (5)
internal/crun/cmd.go (1)
  • FlagDeadlineTime (62-62)
internal/cbatch/cmd.go (1)
  • FlagDeadlineTime (70-70)
internal/cacct/cmd.go (1)
  • FlagDeadlineTime (44-44)
internal/cqueue/cmd.go (1)
  • FlagDeadlineTime (32-32)
internal/ccontrol/cmd.go (1)
  • FlagDeadlineTime (53-53)
internal/crun/crun.go (2)
internal/crun/cmd.go (1)
  • FlagDeadlineTime (62-62)
internal/util/string.go (1)
  • ParseTime (377-436)
internal/cacct/cacct.go (5)
internal/cqueue/format.go (2)
  • ProcessDeadline (33-40)
  • InfiniteFuture (35-35)
internal/calloc/cmd.go (1)
  • FlagDeadlineTime (56-56)
internal/crun/cmd.go (1)
  • FlagDeadlineTime (62-62)
internal/cacct/cmd.go (1)
  • FlagDeadlineTime (44-44)
internal/cqueue/cmd.go (1)
  • FlagDeadlineTime (32-32)
internal/calloc/calloc.go (2)
internal/calloc/cmd.go (1)
  • FlagDeadlineTime (56-56)
internal/util/string.go (1)
  • ParseTime (377-436)
internal/crun/cmd.go (3)
internal/calloc/cmd.go (2)
  • RootCmd (58-69)
  • FlagDeadlineTime (56-56)
internal/cbatch/cmd.go (2)
  • RootCmd (72-117)
  • FlagDeadlineTime (70-70)
internal/ccontrol/cmd.go (1)
  • FlagDeadlineTime (53-53)
🔇 Additional comments (5)
internal/calloc/cmd.go (1)

55-56: LGTM!

The new FlagDeadlineTime variable and --deadline flag are properly declared and registered.

internal/crun/cmd.go (1)

61-62: LGTM!

The new FlagDeadlineTime variable and --deadline flag are properly declared and registered.

internal/cacct/cacct.go (3)

185-250: LGTM!

The deadline column is correctly integrated into the full output display, with proper formatting via ProcessDeadline.


305-310: LGTM!

The conditional append of the Deadline column when FlagDeadlineTime is set provides users control over display verbosity in non-full mode.


567-567: LGTM!

The deadline field processor is correctly registered, enabling format string support.

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)
internal/crun/crun.go (1)

1126-1135: Fix error message format for consistency.

The error handling correctly addresses the previous review concern by properly returning errors instead of silently ignoring them. However, the error message format is inconsistent with similar error messages in this file.

Compare:

  • Line 1057: "Invalid argument: invalid --time: %s."
  • Line 1131: "Invalid argument: --deadline: %s"

Apply this diff for consistency:

 			return &util.CraneError{
 				Code:    util.ErrorCmdArg,
-				Message: fmt.Sprintf("Invalid argument: --deadline: %s", err),
+				Message: fmt.Sprintf("Invalid argument: invalid --deadline: %s.", err),
 			}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02318f4 and 9fd61a1.

📒 Files selected for processing (3)
  • internal/calloc/calloc.go (2 hunks)
  • internal/cbatch/cbatch.go (2 hunks)
  • internal/crun/crun.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/calloc/calloc.go
  • internal/cbatch/cbatch.go
🧰 Additional context used
🧬 Code graph analysis (1)
internal/crun/crun.go (3)
internal/crun/cmd.go (1)
  • FlagDeadlineTime (62-62)
internal/util/string.go (1)
  • ParseTime (377-436)
internal/util/err.go (2)
  • CraneError (43-47)
  • ErrorCmdArg (36-36)
🔇 Additional comments (1)
internal/crun/crun.go (1)

48-48: LGTM!

The timestamppb import is correctly added and used for converting the parsed deadline time to a protobuf timestamp.

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

♻️ Duplicate comments (2)
internal/cqueue/format.go (1)

32-39: Inconsistency: "unknown" vs "InfiniteFuture".

The ProcessDeadline function in this file returns "unknown" for infinite deadlines (line 38), but the identical function in internal/cacct/cacct.go (line 389) returns "InfiniteFuture" for the same condition. This creates inconsistent UX where users see different representations depending on which tool they use.

As noted in previous reviews, consider standardizing on a single return value across both implementations.

internal/cacct/cacct.go (1)

383-390: Code duplication with cqueue/format.go.

The ProcessDeadline function duplicates nearly identical logic found in internal/cqueue/format.go (lines 32-39). The only difference is the return value for the infinite deadline case: this file returns "InfiniteFuture" while cqueue returns "unknown".

As noted in previous reviews, extract the shared logic into a common utility function (e.g., in internal/util) to eliminate duplication and ensure consistency.

🧹 Nitpick comments (1)
internal/util/util.go (1)

110-110: Add parentheses for clarity.

While the expression 1<<63-1 is technically correct due to operator precedence (shift has higher precedence than subtraction), it may be misread at a glance.

Apply this diff to make the precedence explicit:

-	InfiniteFuture = time.Unix(1<<63-1, 0)
+	InfiniteFuture = time.Unix((1<<63)-1, 0)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9fd61a1 and 08ced61.

📒 Files selected for processing (3)
  • internal/cacct/cacct.go (7 hunks)
  • internal/cqueue/format.go (2 hunks)
  • internal/util/util.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
internal/cacct/cacct.go (4)
internal/cqueue/format.go (1)
  • ProcessDeadline (33-39)
internal/cacct/cmd.go (1)
  • FlagDeadlineTime (44-44)
internal/cqueue/cmd.go (1)
  • FlagDeadlineTime (32-32)
internal/util/util.go (1)
  • InfiniteFuture (110-110)
internal/cqueue/format.go (2)
internal/cacct/cacct.go (1)
  • ProcessDeadline (384-390)
internal/util/util.go (1)
  • InfiniteFuture (110-110)
🔇 Additional comments (7)
internal/cqueue/format.go (1)

199-200: LGTM—deadline field registered correctly.

The "deadline" specifier is properly registered in the field map with the correct header and processor function.

internal/cacct/cacct.go (5)

185-185: LGTM—Deadline column added to full header.

The "Deadline" column is correctly appended to the full-mode table header, providing visibility into task deadlines.


226-227: LGTM—Deadline properly integrated into full-mode rows.

The deadline is correctly formatted via ProcessDeadline and appended to each table row in full mode.

Also applies to: 249-250


305-310: LGTM—Conditional deadline column logic is correct.

The deadline column is conditionally appended when FlagDeadlineTime is set, allowing users to opt into viewing deadline information in non-full mode.


566-566: LGTM—Deadline processor registered correctly.

The "deadline" field is properly registered in the fieldProcessors map, enabling custom format string support for deadline fields.


736-736: LGTM—Help text updated to include deadline specifier.

The format specifier help text correctly documents the new "deadline/Deadline" option.

internal/util/util.go (1)

110-110: Sentinel value change needs backend verification.

The change from time.Date(9999, 12, 31, 23, 59, 59, 999999999, time.UTC) to time.Unix(1<<63-1, 0) represents a significant difference:

  • Old value: ~253 billion seconds (year 9999)
  • New value: ~9.2 quintillion seconds (year 292277026596)

The constant MaxJobTimeStamp = 253402300799 remains defined and is used for validation in internal/ccontrol/ccontrol.go:413. The InfiniteFuture constant is used only for read-side comparisons in display formatting (internal/cqueue/format.go:35 and internal/cacct/cacct.go:386).

Risk: If the backend initializes or returns deadline_time using the historical sentinel value (9999-12-31 23:59:59), the equality checks will fail, breaking deadline display logic. No backend initialization code or migration logic was found in the codebase to confirm this behavior.

Action: Verify with backend integration or API documentation whether:

  • Backend ever sets deadline_time to the old sentinel (253402300799)
  • Existing tasks in production use this value
  • Migration or compatibility handling is required

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: 1

♻️ Duplicate comments (1)
internal/cacct/cacct.go (1)

384-390: Code duplication already flagged.

This implementation duplicates logic in internal/cqueue/format.go (lines 32-38). A previous review comment already suggested extracting this to a shared utility function in internal/util/format.go.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 08ced61 and 089c53b.

📒 Files selected for processing (1)
  • internal/cacct/cacct.go (7 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
internal/cacct/cacct.go (3)
internal/cqueue/format.go (1)
  • ProcessDeadline (33-39)
internal/cacct/cmd.go (1)
  • FlagDeadlineTime (44-44)
internal/util/util.go (1)
  • InfiniteFuture (110-110)
🔇 Additional comments (4)
internal/cacct/cacct.go (4)

185-185: LGTM: Deadline column integrated into full output.

The deadline field is correctly added to the full table header and data, following the same pattern as other time-based fields.

Also applies to: 226-227, 249-250


305-310: LGTM: Conditional deadline column logic is correct.

The implementation correctly mirrors the pattern used for other conditional time fields (StartTime, EndTime, SubmitTime).


566-566: LGTM: Field processor entry is correct.

The "deadline" mapping is properly registered and follows the established pattern.


736-736: LGTM: Help text updated.

The format specifier documentation correctly includes the new deadline option.

}

timeDeadline := taskInfo.DeadlineTime.AsTime()
if !timeDeadline.Before(timeStart) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这好像不对吧

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: 1

♻️ Duplicate comments (2)
internal/cqueue/format.go (1)

32-39: Duplication with internal/cacct/cacct.go resolved from past review.

The implementation now correctly returns "unknown" instead of an empty string, which addresses the previous inconsistency. However, this function remains duplicated with an identical implementation in internal/cacct/cacct.go (lines 394-400).

Consider extracting this common logic to a shared utility package to eliminate duplication and improve maintainability. Based on learnings.

internal/cacct/cacct.go (1)

394-401: Fix misleading comment.

The comment // Deadline (D) is incorrect. The format specifier "D" is already used for ElapsedTime (line 375). The actual format specifier for deadline is "deadline" (full word), as registered on line 577.

Apply this diff:

-// Deadline (D)
+// Deadline (deadline)
 func ProcessDeadline(task *protos.TaskInfo) string {

Additionally, this function is duplicated with an identical implementation in internal/cqueue/format.go (lines 32-39). Consider extracting to a shared utility package to eliminate duplication. Based on learnings.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e12ad78 and ff98b06.

📒 Files selected for processing (20)
  • internal/cacct/cacct.go (7 hunks)
  • internal/cacct/cmd.go (3 hunks)
  • internal/calloc/calloc.go (2 hunks)
  • internal/calloc/cmd.go (3 hunks)
  • internal/cbatch/cbatch.go (2 hunks)
  • internal/cbatch/cmd.go (2 hunks)
  • internal/cbatch/line.go (1 hunks)
  • internal/ccontrol/ccontrol.go (3 hunks)
  • internal/ccontrol/cmd.go (3 hunks)
  • internal/ccontrol/help.go (1 hunks)
  • internal/cqueue/cmd.go (3 hunks)
  • internal/cqueue/format.go (2 hunks)
  • internal/cqueue/output.go (3 hunks)
  • internal/crun/cmd.go (3 hunks)
  • internal/crun/crun.go (2 hunks)
  • internal/util/err.go (1 hunks)
  • internal/util/util.go (2 hunks)
  • protos/Crane.proto (4 hunks)
  • protos/PublicDefs.proto (14 hunks)
  • protos/Supervisor.proto (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • internal/cacct/cmd.go
  • internal/ccontrol/cmd.go
  • internal/calloc/cmd.go
  • internal/crun/crun.go
  • protos/Supervisor.proto
  • internal/crun/cmd.go
  • internal/cbatch/cmd.go
  • internal/util/util.go
  • internal/calloc/calloc.go
  • internal/cbatch/cbatch.go
🧰 Additional context used
🧬 Code graph analysis (5)
internal/cqueue/format.go (2)
internal/cacct/cacct.go (1)
  • ProcessDeadline (395-401)
internal/util/util.go (1)
  • InfiniteFuture (112-112)
internal/cacct/cacct.go (3)
internal/cqueue/format.go (1)
  • ProcessDeadline (33-39)
internal/cacct/cmd.go (1)
  • FlagDeadlineTime (45-45)
internal/util/util.go (1)
  • InfiniteFuture (112-112)
internal/cqueue/cmd.go (5)
internal/calloc/cmd.go (1)
  • FlagDeadlineTime (56-56)
internal/crun/cmd.go (1)
  • FlagDeadlineTime (62-62)
internal/cbatch/cmd.go (1)
  • FlagDeadlineTime (68-68)
internal/cacct/cmd.go (1)
  • FlagDeadlineTime (45-45)
internal/ccontrol/cmd.go (1)
  • FlagDeadlineTime (53-53)
internal/cqueue/output.go (2)
internal/cqueue/format.go (1)
  • ProcessDeadline (33-39)
internal/cqueue/cmd.go (1)
  • FlagDeadlineTime (32-32)
internal/ccontrol/ccontrol.go (5)
internal/util/string.go (2)
  • ParseTime (377-436)
  • ParseJobIdList (1098-1110)
internal/util/err.go (4)
  • CraneError (43-47)
  • ErrorCmdArg (36-36)
  • ErrorNetwork (37-37)
  • ErrorBackend (38-38)
internal/util/grpc.go (1)
  • GrpcErrorPrintf (387-398)
internal/ccontrol/cmd.go (1)
  • FlagJson (45-45)
internal/util/formatter.go (1)
  • FmtJson (58-58)
🔇 Additional comments (27)
internal/cbatch/line.go (1)

67-67: LGTM!

The addition of "--deadline": true to the supported Slurm options map is correctly placed and follows the existing pattern for other Slurm flags.

internal/cqueue/output.go (3)

55-55: LGTM!

The "Deadline" column is correctly added to the full header list, maintaining consistency with the full row data mapping.


84-84: LGTM!

The deadline value is correctly appended to the full row data using ProcessDeadline(task), which properly formats the deadline timestamp.


129-134: LGTM!

The conditional Deadline column addition in non-full mode follows the same pattern as other dynamic columns (StartTime, QoS) and correctly uses the FlagDeadlineTime flag to control visibility.

internal/cqueue/cmd.go (3)

32-32: LGTM!

The FlagDeadlineTime boolean flag is correctly declared alongside other flag variables.


102-102: LGTM!

The --deadline flag is properly registered with appropriate description and follows the same pattern as other boolean flags in the command.


119-119: LGTM!

The format documentation correctly describes the new %deadline/%Deadline placeholder and its purpose for displaying job deadline times.

internal/ccontrol/help.go (2)

67-67: LGTM!

The help text correctly documents the new deadline=<deadline> parameter in the update command syntax, following the same pattern as other optional parameters.


75-75: LGTM!

The parameter description clearly explains the purpose of the deadline parameter.

internal/cqueue/format.go (1)

199-200: LGTM!

The "deadline" field mapping is correctly registered with header "Deadline" and the ProcessDeadline function.

internal/ccontrol/ccontrol.go (3)

33-33: LGTM!

The import of timestamppb is necessary for setting the deadline timestamp in the ModifyTaskRequest.


49-49: LGTM!

The DeadlineTypeFlag constant is correctly added to the UpdateJobParamFlags enum using the bitwise shift pattern.


132-174: LGTM!

The ChangeDeadlineTime function correctly implements deadline modification:

  • Parses the deadline string using util.ParseTime
  • Validates task IDs with proper error handling
  • Constructs the ModifyTaskRequest with the Deadline attribute
  • Uses timestamppb.New(time) to convert the parsed time
  • Handles JSON output and error responses consistently with other modify operations

The implementation follows the same pattern as ChangeTaskTimeLimit and integrates properly with the existing error handling framework.

internal/cacct/cacct.go (5)

196-196: LGTM!

The "Deadline" column is correctly added to the full header array in the appropriate position.


237-261: LGTM!

The deadline processing is correctly integrated:

  • Line 237 calls ProcessDeadline(taskInfo) to format the deadline
  • Line 261 includes the deadline string in the table data row

The implementation properly handles deadline formatting for the full display mode.


316-321: LGTM!

The conditional deadline column addition in non-full mode correctly uses the FlagDeadlineTime flag and applies ProcessDeadline to each task, following the same pattern as other conditional columns.


577-577: LGTM!

The "deadline" field mapping is correctly registered in the fieldProcessors map with header "Deadline" and the ProcessDeadline function.


747-747: LGTM!

The format specifier error message is properly updated to include "deadline/Deadline" in the list of supported identifiers.

protos/Crane.proto (5)

151-155: LGTM!

The message rename from ChangeJobTimeLimitRequest to ChangeJobTimeConstraintRequest appropriately reflects the expanded scope. The changes are backward-compatible:

  • time_limit_seconds is now optional (line 153)
  • New optional int64 deadline_time field added (line 154)
  • Field numbering is correct and non-conflicting

157-159: LGTM!

The reply message is correctly renamed to match the request message.


234-234: LGTM!

The Deadline = 3 enum value is correctly added to TargetAttributes without conflicting with existing values.


250-250: LGTM!

The google.protobuf.Timestamp deadline_time = 8 field is correctly added to the oneof value with proper field numbering that doesn't conflict with existing fields.


1074-1074: LGTM!

The RPC rename from ChangeJobTimeLimit to ChangeJobTimeConstraint correctly reflects the expanded functionality to handle both time limits and deadlines.

protos/PublicDefs.proto (4)

121-121: TaskStatus enum correctly extended.

The addition of Deadline = 10 supports explicit deadline-related status tracking, complementing the new deadline_time fields across message types.


178-178: Deadline timestamp fields properly integrated.

The deadline_time fields are consistently added across TaskToCtld, StepToCtld, StepToD, TaskInfo, and StepInfo messages. Field numbers are unique and non-conflicting, and all use the standard google.protobuf.Timestamp type aligned with existing time fields.

Also applies to: 243-243, 336-336, 469-469, 486-486


460-464: Documentation comments enhance clarity.

The added comments explain elapsed time calculation handling and UserInfo protobuf-to-DB mapping semantics, which will aid developers maintaining clock skew resilience and understanding message semantics.

Also applies to: 511-515, 755-765


632-636: Error codes properly structured for deadline and QoS support.

New error codes are added with appropriate semantics: ERR_INVALID_DEADLINE (78) for deadline validation, QoS-related codes (25–29) for constraint management, and CRI error codes (80–82) for container runtime integration. All values are unique and maintain room for future expansion.

Also applies to: 705-705, 707-711

protos.ErrCode_ERR_CRI_GENERIC: "CRI runtime returns error. Check logs for details.",
protos.ErrCode_ERR_CRI_DISABLED: "CRI support is disabled in the cluster.",
protos.ErrCode_ERR_CRI_CONTAINER_NOT_READY: "Task is pending or container is not ready.",
protos.ErrCode_ERR_INVALID_DEADLINE: "Invalid deadline",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

LGTM! Clean addition of deadline error mapping.

The error code mapping is correctly formatted and the message is clear and consistent with the existing error messages in the map.

Optionally verify that ERR_INVALID_DEADLINE is properly utilized in the deadline validation logic:


🏁 Script executed:

#!/bin/bash
# Description: Find usage of ERR_INVALID_DEADLINE to confirm it's wired into validation logic

# Search for where this error code is returned or used
rg -nP --type=go -C3 'ERR_INVALID_DEADLINE'

Length of output: 566


I need to verify whether the error code is actually being used or if this is an incomplete implementation. Let me search for deadline-related validation logic and usage patterns.


---

🏁 Script executed:

```shell
#!/bin/bash
# Search for deadline-related logic and error handling patterns
echo "=== Searching for deadline validation logic ==="
rg -nP --type=go -C2 'deadline|Deadline' | head -50

echo -e "\n=== Checking if error code is referenced by other means ==="
rg -nP --type=go -C2 'ERR_CRI_CONTAINER_NOT_READY|ERR_CRI_DISABLED' | head -30

Length of output: 3937


Let me verify if the proto error code constant is properly defined and check for any related context.


🏁 Script executed:

#!/bin/bash
# Search for proto definitions and any TODO/FIXME related to deadline errors
echo "=== Searching for ERR_INVALID_DEADLINE in proto files ==="
rg -nP --type=proto 'ERR_INVALID_DEADLINE'

echo -e "\n=== Searching for deadline-related TODOs or FIXMEs ==="
rg -nP --type=go -C2 'TODO|FIXME.*deadline|deadline.*TODO|deadline.*FIXME' 

echo -e "\n=== Check where util.ErrorCmdArg deadline error is used ==="
rg -nP --type=go -C3 'Invalid argument.*deadline'

Length of output: 3374


Error code added to map but not wired into deadline validation logic.

Verification found that ERR_INVALID_DEADLINE is defined in the error message map but is never actually used. Deadline validation in both internal/crun/crun.go (lines 1123-1127) and internal/calloc/calloc.go (lines 498-502) returns util.ErrorCmdArg instead of the new error code.

The error code mapping needs to be connected to the actual deadline validation error handling in those two locations for consistency.

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