Skip to content

Update Rest status for DecommissioningFailedException#5283

Merged
dblock merged 11 commits intoopensearch-project:mainfrom
imRishN:fix-response-code
Nov 30, 2022
Merged

Update Rest status for DecommissioningFailedException#5283
dblock merged 11 commits intoopensearch-project:mainfrom
imRishN:fix-response-code

Conversation

@imRishN
Copy link
Copy Markdown
Member

@imRishN imRishN commented Nov 16, 2022

Signed-off-by: Rishab Nahata rnnahata@amazon.com

Description

This PR aims to update the RestStatus for DecommissioningFailedException to BadRequest

Issues Resolved

#5075

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@imRishN imRishN marked this pull request as ready for review November 16, 2022 17:12
@imRishN imRishN requested review from a team and reta as code owners November 16, 2022 17:12
@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 17, 2022

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.11%. Comparing base (0210b76) to head (6fc8773).
⚠️ Report is 4412 commits behind head on main.

Files with missing lines Patch % Lines
...r/decommission/DecommissioningFailedException.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5283      +/-   ##
============================================
+ Coverage     70.91%   71.11%   +0.20%     
- Complexity    58075    58203     +128     
============================================
  Files          4711     4711              
  Lines        277534   277535       +1     
  Branches      40169    40169              
============================================
+ Hits         196802   197374     +572     
+ Misses        64582    64046     -536     
+ Partials      16150    16115      -35     

☔ 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.

@dblock
Copy link
Copy Markdown
Member

dblock commented Nov 17, 2022

Did we ship the decommission feature (is this an API change)? Otherwise we can put a skip-changelog on it.

Copy link
Copy Markdown
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

Checking for .status(), especially by casting the exception, doesn't actually check that the end user is getting a 400. It's pretty obvious that DecommissioningFailedException will always have a status of BAD_REQUEST. I think you should write an actual REST test that makes an API call and gets a 400.


@Override
public RestStatus status() {
return RestStatus.BAD_REQUEST;
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.

Here https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/cluster/decommission/DecommissionService.java#L271 it seems its not a bad request due to which the exception is thrown. Should we use a different exception over here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm right. Will fix this in #5093 PR and would rather throw NodeClosedException

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.

Lets break down to use specific exceptions and use 400/403 as needed in those relevant cases

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This PR just attempts to change the status code for DecommissioningFailedException and here we are making it 400. Once case which Anshu mentioned where we could rather throw NodeClosedException will be fixed in a subsequent PR.

Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
@imRishN
Copy link
Copy Markdown
Member Author

imRishN commented Nov 18, 2022

Did we ship the decommission feature (is this an API change)? Otherwise we can put a skip-changelog on it.

Yes, decommission has 3 new APIs and is part of 2.4. We are still incrementally enhancing it. In this, we need to add a change log to this PR?

Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.index.ShardIndexingPressureConcurrentExecutionTests.testReplicaThreadedUpdateToShardLimitsAndRejections

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.cluster.allocation.AwarenessAllocationIT.testThreeZoneOneReplicaWithForceZoneValueAndLoadAwareness

@dblock
Copy link
Copy Markdown
Member

dblock commented Nov 18, 2022

Did we ship the decommission feature (is this an API change)? Otherwise we can put a skip-changelog on it.

Yes, decommission has 3 new APIs and is part of 2.4. We are still incrementally enhancing it. In this, we need to add a change log to this PR?

Well, 2.4 has shipped, and that feature is not experimental, or is it? Now you're changing the API in a backwards incompatible way, so I think this cannot go into 2.5 but I am not sure since before it would fail with a 500 which is generic. Either way it does need a CHANGELOG entry in the right version as part of this PR.

@imRishN
Copy link
Copy Markdown
Member Author

imRishN commented Nov 19, 2022

Well, 2.4 has shipped, and that feature is not experimental, or is it? Now you're changing the API in a backwards incompatible way, so I think this cannot go into 2.5 but I am not sure since before it would fail with a 500 which is generic. Either way it does need a CHANGELOG entry in the right version as part of this PR.

We have labelled it experimental in rest-api-spec and the documentation issue which is still in progress would also call that out, if that's what you mean by making the feature experimental? Please correct me if I am wrong. I didn't understand why these incremental changes cannot be part of 2.5? I'll add a change log for this PR

Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.index.ShardIndexingPressureConcurrentExecutionTests.testCoordinatingPrimaryThreadedUpdateToShardLimitsAndRejections
      1 org.opensearch.cluster.allocation.AwarenessAllocationIT.testThreeZoneOneReplicaWithForceZoneValueAndLoadAwareness

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@imRishN
Copy link
Copy Markdown
Member Author

imRishN commented Nov 27, 2022

@dblock @Bukhtawar can we merge this?

Copy link
Copy Markdown
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

Let's sweat the small stuff in the CHANGELOG, pls.

Comment thread CHANGELOG.md Outdated
- Fix 'org.apache.hc.core5.http.ParseException: Invalid protocol version' under JDK 16+ ([#4827](https://github.com/opensearch-project/OpenSearch/pull/4827))
- Fixed compression support for h2c protocol ([#4944](https://github.com/opensearch-project/OpenSearch/pull/4944))
- Reject bulk requests with invalid actions ([#5299](https://github.com/opensearch-project/OpenSearch/issues/5299))
- Update Rest status for DecommissioningFailedException([#5283](https://github.com/opensearch-project/OpenSearch/pull/5283))
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.

So this is not a fix, but a change. Move above and say "Changed htto code for ... from 500 to 400" similar to what we did for NotXContentException

Also add a space before ( like for all other lines, please.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

@github-actions
Copy link
Copy Markdown
Contributor

Gradle Check (Jenkins) Run Completed with:

@dblock dblock merged commit c7ba253 into opensearch-project:main Nov 30, 2022
@dblock dblock added the backport 2.x Backport to 2.x branch label Nov 30, 2022
@dblock
Copy link
Copy Markdown
Member

dblock commented Nov 30, 2022

Marked for backport 2.x since the feature is experimental in 2.4.

@opensearch-trigger-bot
Copy link
Copy Markdown
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-5283-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 c7ba2538e837507d0decc77aaba2fa21745fdac1
# Push it to GitHub
git push --set-upstream origin backport/backport-5283-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-5283-to-2.x.

@dblock
Copy link
Copy Markdown
Member

dblock commented Nov 30, 2022

@imRishN Needs manual backport pls :(

imRishN added a commit to imRishN/OpenSearch that referenced this pull request Dec 1, 2022
@imRishN
Copy link
Copy Markdown
Member Author

imRishN commented Dec 1, 2022

Created backport PR

Bukhtawar pushed a commit that referenced this pull request Dec 1, 2022
Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 2.x Backport to 2.x branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants