Skip to content

feat: rollout support inline batch strategy#159

Open
youngLiuHY wants to merge 5 commits intomainfrom
rollout-supportInlineBatchStrategy
Open

feat: rollout support inline batch strategy#159
youngLiuHY wants to merge 5 commits intomainfrom
rollout-supportInlineBatchStrategy

Conversation

@youngLiuHY
Copy link
Copy Markdown
Collaborator

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

2. What is the scope of this PR (e.g. component or file name):

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

6. Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Copy link
Copy Markdown

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

Adds support for defining batch rollout strategy inline in Rollout (in addition to existing StrategyRef), and wires it through RolloutRun construction + one-time strategy handling, with accompanying unit/integration tests and CRD schema updates.

Changes:

  • Add inline batch strategy (spec.batchStrategy) support and prefer inline configuration when present.
  • Extend one-time strategy representation to carry inline batch strategy and apply it to in-flight RolloutRuns.
  • Add validation + new tests (unit and envtest/Ginkgo) and regenerate Rollout CRD schema.

Reviewed changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
pkg/workload/info.go Tighten strict readiness check to also fail when terminating replicas exist.
pkg/features/ontimestrategy/ontimestrategy.go Extend one-time strategy struct to support inline batch strategy.
pkg/controllers/rollout/utils.go Prefer constructing RolloutRun from inline strategy before StrategyRef.
pkg/controllers/rollout/inline_strategy.go New helper to build RolloutRun spec from inline canary/batch strategy.
pkg/controllers/rollout/rollout_controller.go Skip fetching RolloutStrategy for inline batch; apply one-time strategy from either StrategyRef or inline batch.
apis/rollout/v1alpha1/validation/rollout.go Add RolloutSpec validation for strategy selection/mutual exclusion and validate inline strategies.
apis/rollout/v1alpha1/validation/rollout_test.go Add validation tests for inline batch and mutual exclusion.
pkg/controllers/rollout/utils_test.go Add unit tests for RolloutRun construction precedence.
pkg/controllers/rollout/suite_test.go New envtest/Ginkgo suite bootstrap for rollout controller integration tests.
pkg/controllers/rollout/rollout_controller_test.go New integration tests around StrategyRef, inline strategy, triggers, and status behavior.
config/crd/bases/rollout.kusionstack.io_rollouts.yaml Regenerated CRD OpenAPI schema including inline canary/batch strategy fields.
go.mod / go.sum Bump kube-api dependency to a newer pseudo-version.
CLAUDE.md + pkg/controllers/**/CLAUDE.md + .claude/rules/* Add developer workflow/docs (non-runtime).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

zoumo commented Apr 9, 2026

Review findings:

  1. [P1] pkg/controllers/rollout/inline_strategy.go
    If an inline target does not exist, the code silently skips it. This can make the rollout run on only part of the user’s target list. Missing targets should return an error instead of being ignored.

  2. [P2] apis/rollout/v1alpha1/validation/rollout.go
    Inline targets are not checked against workloadRef.match. As a result, rollout trigger logic may use one workload set, while the real rollout executes on another. These two parts should be kept consistent.

@zoumo
Copy link
Copy Markdown
Collaborator

zoumo commented Apr 9, 2026

Code Review: feat: rollout support inline batch strategy

Critical Issues

1. Unrelated files committed to PR

  • .claude/rules/01-coding-conventions.md, .claude/rules/02-testing.md, pkg/controllers/rollout/CLAUDE.md
  • These are AI assistant config files with Chinese text referencing a different project (code.alipay.com/paas-core/kox). Should be removed from this PR.

2. Silent target dropping in validateAndCopyBatchStrategy (pkg/controllers/rollout/inline_strategy.go)

  • When a target's workload doesn't exist in workloadMap, it's silently skipped with continue. This could cause an entire batch to be silently emptied without any warning or error, leading to confusing behavior in production.
key := workloadKey(target.Cluster, target.Name)
if _, exists := workloadMap[key]; !exists {
    continue // SILENT DROP — should at least log a warning or return an error
}

3. panic() in controller code (pkg/controllers/rollout/utils.goconstructRolloutRunBatches)

  • panic("no valid batches found in strategy") is still present. A panic in a controller will crash the entire process. Should return an error instead.

Medium Issues

4. Batch vs InlineBatch mutual exclusion not enforced in OneTimeStrategy (pkg/features/ontimestrategy/ontimestrategy.go)

  • The struct documents that Batch and InlineBatch are mutually exclusive, but there's no validation. If both are set, the code silently prefers one over the other.

5. CanaryStrategy + StrategyRef mutual exclusion not validated (apis/rollout/v1alpha1/validation/rollout.go)

  • Validation checks strategyRef vs batchStrategy mutual exclusion, and requires batchStrategy when canaryStrategy is set. But it doesn't block canaryStrategy + strategyRef being set simultaneously.

6. Wrong validation field path for batch items (apis/rollout/v1alpha1/validation/rollout.go)

  • Uses fldPath.Index(i) which produces paths like [0] instead of spec.batchStrategy.batches[0], making error messages harder to interpret.

7. Hardcoded empty Webhooks (pkg/controllers/rollout/inline_strategy.go)

  • Webhooks: []rolloutv1alpha1.RolloutWebhook{} is hardcoded empty in constructRolloutRunFromInlineStrategy. If webhooks need to be supported with inline strategy in the future, this will be a hidden limitation. Should at least add a TODO comment.

8. Wrong assertion message in test (pkg/controllers/rollout/rollout_controller_test.go)

s.Require().True(run.Spec.Batch.Batches[1].Breakpoint, "Second batch should not have breakpoint")

The message says "should not have breakpoint" but True asserts it IS true. Either the assertion or the message is wrong.

9. Duplicate defer cleanup (pkg/controllers/rollout/rollout_controller_test.go)

  • Some test cases have duplicate defer calls to clean up the same run object.

10. Test coverage regression

  • The rewrite from ginkgo to testify/suite removed tests for: manual trigger policy, auto trigger, observed generation updates. These should be preserved or explicitly noted as moved elsewhere.

Low Issues

11. Typo (pkg/controllers/rollout/rollout_controller.go)

  • "failed to apply one time stratey" → should be "failed to apply one time strategy"

12. Reimplemented strings.Contains (apis/rollout/v1alpha1/validation/rollout_test.go)

  • Custom containsString function does exactly what strings.Contains does. Use the stdlib.

13. Empty PR description

  • For a feature this size, proper documentation of the design decisions, API changes, and migration notes is important.

Design Note

Inline strategies use RolloutRunBatchStrategy (the resolved/concrete type) directly in RolloutSpec, meaning users must specify concrete workload targets (cluster+name+replicas) upfront. This is a fundamentally different UX from StrategyRef which uses the abstract BatchStrategy with Match-based selection. This design choice should be documented.

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.

3 participants