Skip to content

Conversation

@CharlesQQ
Copy link
Member

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@karmada-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign xishanyongye-chang for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 25, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @CharlesQQ, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

本 PR 提出了一个关于增强 Karmada 调度器可扩展性的设计提案。该提案旨在通过引入插件化机制和扩展 API,解决当前调度器在满足企业级定制化需求方面的局限性。核心思想是在不修改调度器核心代码的前提下,允许用户灵活地定义和实现复杂的调度策略,从而提升 Karmada 在多集群环境下的适应性和功能性。

Highlights

  • 调度器可扩展性增强: 提出增强 Karmada 调度器的可扩展性架构,以支持企业定制化调度需求,解决现有 API 灵活性不足、打分算法不满足需求、高级调度约束和框架层特定需求等问题。
  • 插件化调度框架: 引入一个通用的、可扩展的调度框架增强方案,允许用户通过标准化的插件机制扩展调度器能力,而无需修改核心调度器代码。
  • 新增 ReplicaScheduling 阶段: 在调度流程中新增一个核心扩展点 ReplicaScheduling 阶段,位于 Filter 和 Score 阶段之后,用于自定义副本分配逻辑、集成外部系统和实现复杂副本分配策略。
  • API 扩展: 扩展 PropagationPolicy API,新增 AdvancedScheduling 字段(map[string]runtime.RawExtension),提供高级调度配置能力,以键值对形式支持灵活的策略配置,并支持从现有注解平滑迁移。
  • 用户场景支持: 通过多个用户故事(如指定机房/集群副本数、CronHPA 动态调度集成、NodeLabels 插件过滤)展示了新框架如何满足多样化的定制调度需求。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

本提案为增强 Karmada 调度器的可扩展性提供了一个清晰的设计,通过引入 AdvancedScheduling 字段和新的 ReplicaSchedulingPlugin 扩展点,使得用户可以更灵活地定制调度策略。文档结构清晰,用户故事丰富。

我发现了一些可以改进的地方:

  • “背景问题”部分内容缺失,建议补充以提供更完整的上下文。
  • 故事5中的 PropagationPolicy 示例缺少 spec.replicas 字段,并且其调度结果与描述不一致,可能会引起混淆。
  • 从注解迁移到新API字段时,键名的命名规范发生了变化,建议在文档中明确说明,以提高清晰度。

这些修改将有助于提高提案的准确性和可读性。

Comment on lines 300 to 303
- **促销期间(50 副本)**:
- idc-self-cluster-1: 15 副本
- idc-self-cluster-2: 15 副本
- mixed-cloud-cluster: 50 副本(自动分配到 mixed 集群, 由子集群控制该副本数)

Choose a reason for hiding this comment

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

high

故事5中的调度结果示例似乎存在矛盾。根据描述,促销期间的总副本数应为50,但示例结果中各集群副本数之和为 15 + 15 + 50 = 80,与预期不符。为了清晰起见,请检查并修正此处的调度结果,使其与场景描述保持一致。例如,如果 idc-self 集群共分配30个副本,那么 mixed-cloud-cluster 应该分配 50 - 30 = 20 个副本。


## 动机 (Motivation)

### 背景问题

Choose a reason for hiding this comment

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

medium

“背景问题”部分目前是空的。为了让读者更好地理解本提案的动机和背景,建议在此处详细描述当前 Karmada 调度器在满足定制化需求方面遇到的具体问题和挑战。

Comment on lines +270 to +411
# PropagationPolicy 配置
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
name: ecommerce-policy
annotations:
scheduler.karmada.io/replica-scheduling-strategy: |
{
"specifiedIdcs": [
{"name": "idc-self", "replicas": 30}
]
}
spec:
resourceSelectors:
- apiVersion: apps/v1
kind: Deployment
name: ecommerce-app
placement:
clusterAffinity:
labelSelector:
matchLabels:
env: production
replicaScheduling:
replicaSchedulingType: Divided
```

Choose a reason for hiding this comment

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

medium

在故事5的 PropagationPolicy 配置示例中,缺少了 spec.replicas 字段。当 replicaSchedulingType 设置为 Divided 时,此字段通常是必需的。如果此处是有意省略,建议在文档中加以说明,以避免使用者产生困惑。

Comment on lines +408 to +1002
#### 示例 1:指定机房及副本数(specified-idcs)

```yaml
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
name: core-service-policy
spec:
resourceSelectors:
- apiVersion: apps/v1
kind: Deployment
name: core-service
placement:
clusterAffinity:
labelSelector:
matchLabels:
env: production
advancedScheduling:
specified-idcs:
- name: "idc-east"
replicas: 20
- name: "idc-north"
replicas: 10
```

#### 示例 2:指定集群及副本数(specified-clusters)

```yaml
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
name: precise-allocation-policy
spec:
resourceSelectors:
- apiVersion: apps/v1
kind: Deployment
name: my-app
advancedScheduling:
specified-clusters:
- name: "cluster-1"
replicas: 15
- name: "cluster-2"
replicas: 10
- name: "cluster-3"
replicas: 5
```

Choose a reason for hiding this comment

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

medium

在从注解迁移到新的 advancedScheduling API 字段的设计中,策略的键名(key)命名规范似乎发生了变化(例如,从 specifiedIdcs 变为 specified-idcs)。这是一个很好的实践,但在文档中没有明确说明。为了保持清晰和一致,建议在“设计细节”部分明确指出新的命名约定(例如,推荐使用kebab-case),或者在示例中保持一致的命名。

@codecov-commenter
Copy link

codecov-commenter commented Dec 25, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.55%. Comparing base (4c62630) to head (a35b3bb).
⚠️ Report is 45 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7044      +/-   ##
==========================================
- Coverage   46.62%   46.55%   -0.07%     
==========================================
  Files         699      700       +1     
  Lines       48151    48091      -60     
==========================================
- Hits        22450    22389      -61     
- Misses      24013    24019       +6     
+ Partials     1688     1683       -5     
Flag Coverage Δ
unittests 46.55% <ø> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RainbowMango
Copy link
Member

I can see a lot of interesting use cases. Will give it another look later.

@CharlesQQ CharlesQQ force-pushed the scheduler-extend-new branch from b4a4108 to 3be7291 Compare December 30, 2025 02:26
@karmada-bot karmada-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 30, 2025
@CharlesQQ CharlesQQ force-pushed the scheduler-extend-new branch 4 times, most recently from a9e6f2b to 1d8dea9 Compare January 5, 2026 07:37
@CharlesQQ CharlesQQ force-pushed the scheduler-extend-new branch from 1d8dea9 to a35b3bb Compare January 5, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants