Skip to content

feat(api): add PodGroup safeToDisrupt to opt out of consolidation - #22

Open
sam-huang1223 wants to merge 1 commit into
kai-scheduler:mainfrom
sam-huang1223:feat/podgroup-safe-to-disrupt
Open

sam-huang1223 wants to merge 1 commit into
kai-scheduler:mainfrom
sam-huang1223:feat/podgroup-safe-to-disrupt

Conversation

@sam-huang1223

Copy link
Copy Markdown

Description

Adds an optional PodGroupSpec.SafeToDisrupt (*bool) and the kai.scheduler/safe-to-disrupt annotation key, so a workload can opt out of evictions that are not driven by fairness or priority. Today that is the consolidation action, which evicts pods to repack nodes for a pending workload. A workload that does not survive a restart (for example replicas with restartPolicy: Never, or bare pods) can set it to false. Preempt and reclaim are unaffected. Unset means true, so existing PodGroups behave as before.

  • PodGroupSpec.SafeToDisrupt (protobuf tag 11), with the regenerated deepcopy and CRD.
  • ParseSafeToDisrupt, which the pod-grouper uses to read the annotation, as it does ParsePreemptionDelay and ParseStalenessGracePeriod.
  • SafeToDisruptAnnotationKey, next to the preemption-delay and staleness-grace-period keys.

The pod-grouper and scheduler changes that use these are in kai-scheduler/KAI-Scheduler#2284. Following review there, the field is named safeToDisrupt rather than safeToConsolidate, so it is not tied to one action. Following kai-scheduler/KAI-Scheduler#1928, the API part lands here first.

Related Issues

Part of kai-scheduler/KAI-Scheduler#2283; needed by kai-scheduler/KAI-Scheduler#2284.

Checklist

  • Self-reviewed
  • Added/updated tests (if needed): TestParseSafeToDisrupt
  • Updated documentation (if needed): field GoDoc, which is also the CRD description
  • Added a changelog fragment via make changelog

Breaking Changes

None. The field is optional and defaults to true.

Additional Notes

make generate manifests build test lint is clean. The only generated changes are the new field in zz_generated.deepcopy.go and in config/crd/scheduling.run.ai_podgroups.yaml.

🤖 Generated with Claude Code

Add the optional PodGroupSpec.SafeToDisrupt field, ParseSafeToDisrupt, and the kai.scheduler/safe-to-disrupt annotation key. A PodGroup with safeToDisrupt false is not evicted for reasons other than fairness or priority, which today means consolidation; preempt and reclaim are unaffected. Unset means true.

Needed by kai-scheduler/KAI-Scheduler#2284.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Sam Huang <sam@Sams-MacBook-Pro-2.local>
sam-huang1223 added a commit to sam-huang1223/KAI-Scheduler that referenced this pull request Oct 12, 2026
… kai-scheduler/api

Review feedback: safeToConsolidate tied the field to one action. safeToDisrupt (annotation kai.scheduler/safe-to-disrupt) is whether the scheduler may evict a PodGroup for reasons other than fairness or priority; today that is consolidation, and preempt and reclaim are unaffected, as before.

Main reads PodGroup types, parsers and annotation keys from github.com/kai-scheduler/api (kai-scheduler#1917), so the field, ParseSafeToDisrupt and the annotation key move to kai-scheduler/api#22. go.mod temporarily replaces the module with that PR's commit; it becomes a plain version bump once the api module releases. The in-tree pkg/apis copy keeps only the field, so that make manifests still renders it into the chart CRD until kai-scheduler#1928 switches the chart to the api module's CRDs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Sam Huang <19882250+sam-huang1223@users.noreply.github.com>
sam-huang1223 added a commit to sam-huang1223/KAI-Scheduler that referenced this pull request Oct 16, 2026
Per CONTRIBUTING, the replace is local-only. This builds once
kai-scheduler/api#22 is released and go.mod is bumped to that version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@gshaibi gshaibi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

// restartPolicy Never, or bare pods) can set it to false. It does not affect preempt or reclaim.
// Defaults to true.
// +optional
SafeToDisrupt *bool `json:"safeToDisrupt,omitempty" protobuf:"varint,11,opt,name=safeToDisrupt"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @sam-huang1223, we discussed this as a team and decided to start with an annotation only. If it gets wide adoption, we can later promote it to a PodGroup field.

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