Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rest status for DecommissioningFailedException #5283

Merged
merged 11 commits into from
Nov 30, 2022

Conversation

imRishN
Copy link
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
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
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

codecov-commenter commented Nov 17, 2022

Codecov Report

Merging #5283 (f9fc976) into main (f7ba51e) will increase coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff            @@
##               main    #5283   +/-   ##
=========================================
  Coverage     70.95%   70.95%           
- Complexity    58156    58172   +16     
=========================================
  Files          4711     4711           
  Lines        277533   277534    +1     
  Branches      40169    40169           
=========================================
+ Hits         196924   196926    +2     
+ Misses        64510    64497   -13     
- Partials      16099    16111   +12     
Impacted Files Coverage Δ
...r/decommission/DecommissioningFailedException.java 30.76% <0.00%> (-2.57%) ⬇️
...n/indices/forcemerge/ForceMergeRequestBuilder.java 0.00% <0.00%> (-75.00%) ⬇️
...ch/transport/ReceiveTimeoutTransportException.java 50.00% <0.00%> (-50.00%) ⬇️
.../admin/cluster/reroute/ClusterRerouteResponse.java 60.00% <0.00%> (-40.00%) ⬇️
...ava/org/opensearch/search/dfs/DfsSearchResult.java 47.87% <0.00%> (-39.37%) ⬇️
.../java/org/opensearch/search/dfs/AggregatedDfs.java 54.83% <0.00%> (-38.71%) ⬇️
...luster/routing/allocation/RoutingExplanations.java 62.06% <0.00%> (-37.94%) ⬇️
...java/org/opensearch/threadpool/ThreadPoolInfo.java 56.25% <0.00%> (-37.50%) ⬇️
.../indices/forcemerge/TransportForceMergeAction.java 25.00% <0.00%> (-33.34%) ⬇️
...cluster/routing/allocation/RerouteExplanation.java 70.00% <0.00%> (-30.00%) ⬇️
... and 488 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@dblock
Copy link
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
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
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
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
Collaborator

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
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
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
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

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

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

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

@dblock
Copy link
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
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
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
Contributor

Gradle Check (Jenkins) Run Completed with:

@imRishN
Copy link
Member Author

imRishN commented Nov 27, 2022

@dblock @Bukhtawar can we merge this?

Copy link
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.

CHANGELOG.md Outdated
@@ -77,6 +77,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- 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
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
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
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
Member

dblock commented Nov 30, 2022

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

@opensearch-trigger-bot
Copy link
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
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
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