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

Removed NOT_FOUND for empty results. #6544

Merged
merged 8 commits into from
Mar 9, 2023
Merged

Removed NOT_FOUND for empty results. #6544

merged 8 commits into from
Mar 9, 2023

Conversation

harshjain2
Copy link
Contributor

@harshjain2 harshjain2 commented Mar 5, 2023

Description

Fix for the issue due to which 404 was returned when no PITs were present.

Issues Resolved

#5938

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.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2023

Gradle Check (Jenkins) Run Completed with:

@@ -57,7 +56,6 @@ public List<DeletePitInfo> getDeletePitResults() {
*/
@Override
public RestStatus status() {
if (deletePitResults.isEmpty()) return NOT_FOUND;
Copy link
Collaborator

Choose a reason for hiding this comment

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

So what would be the payload returned from the method? Empty list of PITs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The server returns 200 StatusCode with { "pits": [] } as the body when there are no PITs to delete.

Copy link
Collaborator

@reta reta left a comment

Choose a reason for hiding this comment

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

Please add the test cases

@harshjain2
Copy link
Contributor Author

@reta I have fixed integration tests. By this comment, do you mean unit tests?

@reta
Copy link
Collaborator

reta commented Mar 5, 2023

@reta I have fixed integration tests. By this comment, do you mean unit tests?

The rest-api-spec is fine, thank you

@reta
Copy link
Collaborator

reta commented Mar 5, 2023

Also, please fix DCO check, it is failing

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2023

Gradle Check (Jenkins) Run Completed with:

@harshjain2
Copy link
Contributor Author

Wht is the criteria to merge this PR. All the feedback providers must approve this PR?

@reta
Copy link
Collaborator

reta commented Mar 6, 2023

Wht is the criteria to merge this PR. All the feedback providers must approve this PR?

Yes

@dreamer-89
Copy link
Member

@reta @harshjain2 : Anything pending for merge ?

@harshjain2
Copy link
Contributor Author

@dreamer-89 @reta I have addressed all the feedback provided on the PR. Nothing pending from my side on this PR.

@reta
Copy link
Collaborator

reta commented Mar 6, 2023

@dreamer-89 @reta I have addressed all the feedback provided on the PR. Nothing pending from my side on this PR.

I also approved, @Arpit-Bandejiya your concerns were cleared out?

CHANGELOG.md Outdated
@@ -73,6 +73,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add GeoTile and GeoHash Grid aggregations on GeoShapes. ([#5589](https://github.com/opensearch-project/OpenSearch/pull/5589))
- Disallow multiple data paths for search nodes ([#6427](https://github.com/opensearch-project/OpenSearch/pull/6427))
- [Segment Replication] Allocation and rebalancing based on average primary shard count per index ([#6422](https://github.com/opensearch-project/OpenSearch/pull/6422))
- Removed NOT_FOUND for empty results. ([#6544](https://github.com/opensearch-project/OpenSearch/pull/6544))
Copy link
Member

@andrross andrross Mar 7, 2023

Choose a reason for hiding this comment

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

Check out the contributing doc for more details, but this entry isn't super helpful as a release note because it doesn't provide any context about what this change means. I'd suggest something like "Return success on DeletePits when nothing is deleted" or "Return success on DeletePits when no PITs exist".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -138,5 +138,7 @@
- match: {pits.0.successful: true }

- do:
catch: missing
delete_all_pits: { }
delete_all_pits: {}
Copy link
Member

Choose a reason for hiding this comment

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

Does this change the behavior of deleting a single PIT or a list of PITs? Should there be a test for those cases as well?

Copy link
Contributor Author

@harshjain2 harshjain2 Mar 8, 2023

Choose a reason for hiding this comment

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

@andrross I don't think it will result in any change in the behaviour of deleting a single PIT or a list of PITs using DELETE localhost:9200/_search/point_in_time/ API.

Request Delete PIT with empty array results in validation exception.

DELETE localhost:9200/_search/point_in_time/
Request Body

{
    "pit_id": []
}

Response

{
	"error": {
		"root_cause": [
			{
				"type": "action_request_validation_exception",
				"reason": "Validation Failed: 1: no pit ids specified;"
			}
		],
		"type": "action_request_validation_exception",
		"reason": "Validation Failed: 1: no pit ids specified;"
	},
	"status": 400
}

Request with incorrect pits results in failure with failure message associated with every pit id

DELETE localhost:9200/_search/point_in_time/
Request Body

{
    "pit_id": [
        "o463QQEPbXktaW5kZXgtMDAwMDAxFkhGN09fMVlPUkVPLXh6MUExZ1hpaEEAFjBGbmVEZHdGU1EtaFhhUFc4ZkR5cWcAAAAAAAAAAAEWaXBPNVJtZEhTZDZXTWFFR05waXdWZwEWSEY3T18xWU9SRU8teHoxQTFnWGloQQAA",
        "o463QQEPbXktaW5kZXgtMDAwMDAxFkhGN09fMVlPUkVPLXh6MUExZ1hpaEEAFjBGbmVEZHdGU1EtaFhhUFc4ZkR5cWcAAAAAAAAAAAIWaXBPNVJtZEhTZDZXTWFFR05waXdWZwEWSEY3T18xWU9SRU8teHoxQTFnWGloQQAA"
    ]
}

Response

{
	"pits": [
		{
			"successful": false,
			"pit_id": "o463QQEPbXktaW5kZXgtMDAwMDAxFkhGN09fMVlPUkVPLXh6MUExZ1hpaEEAFjBGbmVEZHdGU1EtaFhhUFc4ZkR5cWcAAAAAAAAAAAEWaXBPNVJtZEhTZDZXTWFFR05waXdWZwEWSEY3T18xWU9SRU8teHoxQTFnWGloQQAA"
		},
		{
			"successful": false,
			"pit_id": "o463QQEPbXktaW5kZXgtMDAwMDAxFkhGN09fMVlPUkVPLXh6MUExZ1hpaEEAFjBGbmVEZHdGU1EtaFhhUFc4ZkR5cWcAAAAAAAAAAAIWaXBPNVJtZEhTZDZXTWFFR05waXdWZwEWSEY3T18xWU9SRU8teHoxQTFnWGloQQAA"
		}
	]
}

Copy link
Contributor Author

@harshjain2 harshjain2 Mar 8, 2023

Choose a reason for hiding this comment

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

@andrross Should there be a test for those cases as well?
Few tests cases already exist for the DELETE PIT(s). But I couldn't find test case for the use case where empty pit array is passed in the body.

DELETE localhost:9200/_search/point_in_time/
Request Body:
{
    "pit_id": []
}

I believe this should be tracked through a separate issue.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2023

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2023

Gradle Check (Jenkins) Run Completed with:

@andrross
Copy link
Member

andrross commented Mar 9, 2023

@harshjain2 Can you rebase and fix the conflicts?

Harsh Jain added 8 commits March 9, 2023 11:08
Signed-off-by: Harsh Jain <harshjai@amazon.com>
Signed-off-by: Harsh Jain <harshjai@amazon.com>
Signed-off-by: Harsh Jain <harshjai@amazon.com>

Signed-off-by: Harsh Jain <harshjai@amazon.com>
Signed-off-by: Harsh Jain <harshjai@amazon.com>
Signed-off-by: Harsh Jain <harshjai@amazon.com>
Signed-off-by: Harsh Jain <harshjai@amazon.com>
Signed-off-by: Harsh Jain <harshjai@amazon.com>
Signed-off-by: Harsh Jain <harshjai@amazon.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2023

Gradle Check (Jenkins) Run Completed with:

@reta reta merged commit 67a9b43 into opensearch-project:main Mar 9, 2023
@reta reta added bug Something isn't working backport 2.x Backport to 2.x branch labels Mar 9, 2023
@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-6544-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 67a9b439db79f2782a3fd071004e3ff02c59ba13
# Push it to GitHub
git push --set-upstream origin backport/backport-6544-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-6544-to-2.x.

@reta
Copy link
Collaborator

reta commented Mar 9, 2023

@harshjain2 the backport to 2.x failed :( could you please do a manual one? thank you

@harshjain2
Copy link
Contributor Author

Backport PR to 2.x : #6614

reta pushed a commit that referenced this pull request Mar 10, 2023
* Removed NOT_FOUND for empty results.

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Fixed failing tests.

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Removed unnecessary semi-colon.
Signed-off-by: Harsh Jain <harshjai@amazon.com>

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Added change log.
Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Fixed formatting issues

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Backported to 2.x branch

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Removed duplicate entry as this entry is present under [Unrelease 2.x].

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Updated changelog to make it more meaningful.

Signed-off-by: Harsh Jain <harshjai@amazon.com>

---------

Signed-off-by: Harsh Jain <harshjai@amazon.com>
Co-authored-by: Harsh Jain <harshjai@amazon.com>
(cherry picked from commit 67a9b43)
mingshl pushed a commit to mingshl/OpenSearch-Mingshl that referenced this pull request Mar 24, 2023
* Removed NOT_FOUND for empty results.

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Fixed failing tests.

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Removed unnecessary semi-colon.
Signed-off-by: Harsh Jain <harshjai@amazon.com>

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Added change log.
Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Fixed formatting issues

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Backported to 2.x branch

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Removed duplicate entry as this entry is present under [Unrelease 2.x].

Signed-off-by: Harsh Jain <harshjai@amazon.com>

* Updated changelog to make it more meaningful.

Signed-off-by: Harsh Jain <harshjai@amazon.com>

---------

Signed-off-by: Harsh Jain <harshjai@amazon.com>
Co-authored-by: Harsh Jain <harshjai@amazon.com>
Signed-off-by: Mingshi Liu <mingshl@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 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants