← Back to Pull requests

feat(inkless:controller): add the SetClassicPrefixInRemoteStorage RPC [KC-582] #827

Closed
unknown closed this pull request without merging on Oct 16, 2026 09:31 UTC
View on GitHub
unknown unknown commented on Oct 14, 2026 19:17 UTC
Author

Phase 2 of the classic-to-diskless switch starts when the controller sets classicPrefixInRemoteStorage (tag 103, added in #824) on a partition. This PR adds the controller side: a broker-to-controller RPC that the partition leader sends once it proves that the classic prefix below the committed seal is in remote storage, and the controller commit that sets the flag. Nothing sends the RPC yet; the broker side follows in KC-588.

The commit goes through PartitionChangeBuilder, not through a raw record like the seal. The same record sets the ISR to the active assigned replicas, so it can complete a reassignment and elect a new leader.

Commits

  • chore(inkless): mark ReplicationControlManager and PartitionChangeBuilder as interleaved upstream files in INKLESS_OWNERSHIP.

  • feat(inkless:controller): add the switch flag to PartitionChangeBuilder. The setter adds tag 103, forces a leader epoch increase when nothing else changes the leader, and writes tag 102.

  • feat(inkless:controller): add the SetClassicPrefixInRemoteStorage RPC (API key 503, controller listener only, CLUSTER_ACTION), the controller checks, the entry points, and the flag in the DescribeTopicPartitions response and the topic switch tool output.
  • See the commit messages for the reasoning behind each step, including the order of the controller checks.

    Operator impact

  • kafka-topic-switch.sh state prints classicPrefixInRemoteStorage for each partition. When the seal is committed, it adds the phase: false (phase 1) or true (phase 2).

  • The DescribeTopicPartitions response carries tag 103 only for partitions where the flag is set.
  • Testing

  • PartitionChangeBuilderTest: the flag alone increases the leader epoch once and keeps the leader; an election or a reassignment that removes the leader keeps the new leader; tag 102 equals the new leader epoch, also when it replaces an earlier diskless leader epoch, and the seal stays unchanged.

  • ReplicationControlManagerInklessTest (SetClassicPrefixInRemoteStorageTests, 19 cases): success; a retry after the commit with the old leader epoch succeeds without a record; a different seal after the commit, a seal mismatch, a pending seal, and no seal get INVALID_REQUEST; epoch and leader checks; a fenced leader, a leader in controlled shutdown, and a leaderless partition never reach the builder; the commit adds active replicas to the ISR and keeps fenced ones out; a commit that completes a reassignment elects a new leader; one bad partition in a request does not fail the others.

  • QuorumControllerTest.testSetClassicPrefixInRemoteStorageCommitsFlag: the commit and a retry through a real QuorumController write event.

  • ControllerApisTest: authorization (CLUSTER_ACTION) and NOT_CONTROLLER for every partition when the controller future fails.

  • DescribeTopicPartitionsRequestHandlerTest and TopicSwitchCommandTest: the flag in the describe response and the phase in the tool output.

  • RequestResponseTest: serialization of the new request and response.
  • Diskless leader epoch

    This PR moves the point where the controller sets the diskless leader epoch (tag 102), from the seal commit to the flag commit. The flag commit writes tag 102 equal to the leader epoch that the record produces. No leader used that epoch before the flag, so it is greater than every classic and phase 1 epoch.

    The seal commit sets tag 102 to the leader epoch at the seal. That value can be lower than a phase 1 epoch: if the leader changes while the seal is pending, the new leader adds an epoch cache entry at the seal with a higher epoch. The first consolidated batch carries the lower label, so appending it removes that entry from the epoch cache.

    The seal commit still writes tag 102, because today consolidation starts after the seal commit, in phase 1, and stamps batches with that value. If the flag commit overwrote it while those batches exist, the diskless leader endpoint would answer their epoch with the seal, and followers would truncate [seal, LEO). This can't happen yet: nothing sends the RPC until KC-588. KC-589 gates consolidation on the flag and stops the seal commit from writing tag 102, so no batch carries a label from before the flag. KC-588 and KC-589 ship together for this reason.

    Follow-ups

  • KC-588: the leader detects the upload and sends the RPC, with a cluster test for the whole flow. The broker starts phase 2 from the metadata record, not from the response.

  • KC-586: reject every seal request after the flag, and stop the forced seal from writing tag 102. On a switching topic, a reassignment takes the diskless path and finishes at once, so the reassignment path needs the gate too.

  • KC-589: gate consolidation on the flag, and stop writing tag 102 at the seal commit. It ships together with KC-588.
  • Diff: 608 lines (+456 / -152) across 7 files Reviewer: viktorsomogyi Review duration: 2293m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 608 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.384
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #827"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.1% (MEDIUM) · Higher = larger blast radius
    50.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.8% · Safe to merge
    19.8%
    Repository