Skip to content

Conversation

Ethereal-O
Copy link
Contributor

Purpose of the PR

  • Design a new scheduler

Main Changes

  • Support priority/elder/depends based scheduling.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows.

I have write some scripts in /test folder.

Does this PR potentially affect the following parts?

  • Nope
  • Dependencies (add/update license info)
  • Modify configurations
  • The public API
  • Other affects (typed here)

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. feature New feature labels Sep 26, 2025
@imbajin imbajin requested a review from Copilot September 26, 2025 10:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a comprehensive scheduler system with priority, dependency, and cron-based scheduling capabilities. The new scheduler replaces the previous simple queue-based system with a sophisticated task management framework supporting advanced scheduling algorithms.

Key changes:

  • New scheduler architecture with modular components for algorithm, resource, task, and cron management
  • Priority-based scheduling with support for task dependencies (preorders)
  • Cron expression support for recurring tasks
  • Worker group management and resource allocation improvements

Reviewed Changes

Copilot reviewed 40 out of 41 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
vermeer/test/scheduler/*.go Test framework for scheduler functionality including priority, dependency, and cron testing
vermeer/apps/master/schedules/*.go Core scheduler implementation with algorithm, resource, task, and cron managers
vermeer/client/*.go Client API extensions for batch operations and task sequence tracking
vermeer/apps/structure/task.go Task structure enhancements for scheduler fields
vermeer/apps/master/bl/*.go Business logic updates to integrate with new scheduler
vermeer/config/*.ini Configuration additions for scheduler parameters

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +55 to +57
if num <= 10 {
num = 30
}
Copy link
Preview

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

Magic numbers 10 and 30 should be defined as named constants to improve code maintainability and explain why these specific values are chosen.

Copilot uses AI. Check for mistakes.

if graph == nil {
resourceCost = resourceParam // if graph not found, use max resource cost
} else {
resourceCost = resourceParam / max(1, graph.VertexCount+graph.EdgeCount) // Avoid division by zero, ensure at least 1
Copy link
Preview

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

The calculation logic for resourceCost is complex and should be extracted into a separate method with proper documentation explaining the algorithm.

Copilot uses AI. Check for mistakes.

for _, preorder := range preorderList {
if pid, err := strconv.ParseInt(preorder, 10, 32); err == nil {
if taskMgr.GetTaskByID(int32(pid)) == nil {
return nil, fmt.Errorf("preorder task id %d not exists", pid)
Copy link
Preview

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

The error message 'preorder task id %d not exists' has incorrect grammar. It should be 'preorder task with ID %d does not exist'.

Suggested change
return nil, fmt.Errorf("preorder task id %d not exists", pid)
return nil, fmt.Errorf("preorder task with ID %d does not exist", pid)

Copilot uses AI. Check for mistakes.

return tasks
}

func (t *SchedulerTaskManager) GetAllTasksWaitng() []*structure.TaskInfo {
Copy link
Preview

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

The function name has a typo: 'GetAllTasksWaitng' should be 'GetAllTasksWaiting'.

Suggested change
func (t *SchedulerTaskManager) GetAllTasksWaitng() []*structure.TaskInfo {
func (t *SchedulerTaskManager) GetAllTasksWaiting() []*structure.TaskInfo {

Copilot uses AI. Check for mistakes.

func (s *ScheduleBl) waitingStartedTask() {
for taskInfo := range s.startChan {
if taskInfo == nil {
logrus.Warnf("recieved a nil task from startChan")
Copy link
Preview

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

Spelling error: 'recieved' should be 'received'.

Suggested change
logrus.Warnf("recieved a nil task from startChan")
logrus.Warnf("received a nil task from startChan")

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant