Skip to content

HDDS-16813. Reject external CompleteFinalizeUpgrade requests - #11455

Draft
smengcl wants to merge 1 commit into
apache:masterfrom
smengcl:HDDS-16813
Draft

smengcl wants to merge 1 commit into
apache:masterfrom
smengcl:HDDS-16813

Conversation

@smengcl

@smengcl smengcl commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

CompleteFinalizeUpgrade is intended for OMUpgradeFinalizeService, but normal client dispatch also accepts it. Reject external submissions in preExecute() with INVALID_REQUEST.

Internal completion continues through direct Ratis submission, which bypasses preExecute(). Update the handler tests accordingly and extend the existing upgrade integration test to cover external rejection followed by normal finalization.

What is the link to the Apache JIRA?

https://issues.apache.org/jira/browse/HDDS-16813

How was this patch tested?

  • All 52 related OM unit tests passed.
  • TestOMUpgradeFinalization#testOmFinalizationStatusTransitions passed with real RPCs. It verifies rejection without advancing OM's version, followed by successful normal finalization. It fails without the guard.
  • Checkstyle and git diff --check passed.

Local validation used JDK 21, Maven 3.9.11, and a non-secure MiniOzoneCluster.

Generated-by: Codex (GPT-6)

Copilot AI balanced review requested due to automatic review settings October 9, 2026 09:09
@smengcl smengcl added the AI-gen label Oct 9, 2026
@github-actions github-actions Bot added the om label Oct 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open findings
What changed in this PR

Rejects externally-submitted CompleteFinalizeUpgrade OM requests (intended to be internal-only) by failing them during preExecute() with INVALID_REQUEST, while preserving the internal (Ratis-applied) finalize path and updating tests accordingly.

Changes:

  • Added a preExecute() guard in OMCompleteFinalizeUpgradeRequest that throws OMException(INVALID_REQUEST) for external submissions.
  • Updated unit tests to reflect that internal requests bypass preExecute() and to assert finalizeUpgrade() invocation on the internal path.
  • Extended the OM upgrade finalization integration test to verify external rejection and that state/metadata remains unchanged.
File Description
hadoop-ozone/​ozone-manager/​src/​main/​java/​org/​apache/​hadoop/​ozone/​om/​request/​upgrade/​OMCompleteFinalizeUpgradeRequest.java Adds preExecute() rejection for external CompleteFinalizeUpgrade requests via OMException(INVALID_REQUEST).
hadoop-ozone/​ozone-manager/​src/​test/​java/​org/​apache/​hadoop/​ozone/​om/​request/​upgrade/​TestOMCompleteFinalizeUpgradeRequest.java Adjusts unit tests for the new preExecute() behavior and adds a regression test ensuring external rejection happens before Ratis submission.
hadoop-ozone/​integration-test/​src/​test/​java/​org/​apache/​hadoop/​ozone/​om/​TestOMUpgradeFinalization.java Adds integration coverage asserting external rejection doesn’t advance OM version or write the in-progress marker, then normal finalization proceeds.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +59 to +60
final OMRequest omRequest = super.preExecute(ozoneManager);
throw new OMException(omRequest.getCmdType() + " is an internal request", OMException.ResultCodes.INVALID_REQUEST);
Comment on lines +75 to +78
assertFalse(response.getSuccess());
assertEquals(Status.INVALID_REQUEST, response.getStatus());
verifyNoInteractions(ratisServer);
verify(ozoneManager, never()).finalizeUpgrade();
@Override
public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
final OMRequest omRequest = super.preExecute(ozoneManager);
throw new OMException(omRequest.getCmdType() + " is an internal request", OMException.ResultCodes.INVALID_REQUEST);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants