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

SnapshotDeleteRequest use []string instead of string #237

Merged
merged 6 commits into from
Mar 23, 2023

Conversation

Jakob3xD
Copy link
Collaborator

@Jakob3xD Jakob3xD commented Feb 21, 2023

Description

SnapshotDeleteRequest use []string instead of string

Issues Resolved

Closes 236

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.

@Jakob3xD Jakob3xD force-pushed the snapshotDeleteRequest-slice branch 2 times, most recently from aba54d3 to 51631fc Compare February 21, 2023 17:20
Copy link
Collaborator

@VachaShah VachaShah left a comment

Choose a reason for hiding this comment

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

Thank you for this fix @Jakob3xD! Can you also add a test for the same?

@Jakob3xD
Copy link
Collaborator Author

@VachaShah Are there any existing tests I can orientate on that handle snapshots or maybe something else, so I can see how you want the tests to look like and what structure they should have?

@VachaShah
Copy link
Collaborator

@VachaShah Are there any existing tests I can orientate on that handle snapshots or maybe something else, so I can see how you want the tests to look like and what structure they should have?

@Jakob3xD All the API tests currently exist in opensearchapi_integration_test.go.

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.

This is a breaking change for the client. Can we avoid it and have both versions of string and string[] and implement the former using the latter everywhere one may want to pass a single item?

@Jakob3xD
Copy link
Collaborator Author

Jakob3xD commented Mar 1, 2023

This is a breaking change but only because this was wrong in the first place. I should have opened my issue as bug and not as feature. IMO it is also easier to convert a string to []string by just doing []string{"Hello"} instead of converting a []string to string by doing strings.Join(stringvar, ",") which needs to import the strings lib.

@dblock
Copy link
Member

dblock commented Mar 1, 2023

@Jakob3xD You're right, still before I merge, is there a way to make the change backwards compatible? Does it make any sense to have two fields Snapshot and Shapshots for example and two functions?

Rebase please, I'm ok merging this otherwise.

Do we have the same problem elsewhere?

@Jakob3xD Jakob3xD force-pushed the snapshotDeleteRequest-slice branch from 51631fc to d08fffd Compare March 2, 2023 15:32
@Jakob3xD
Copy link
Collaborator Author

Jakob3xD commented Mar 2, 2023

@dblock IMO it does not make sense to have both fields as it add unneeded overhead.
Other snapshot requests are snapshot specific and are therefore only a string.

I did't find more problems with wrong types.

@VachaShah to add integration tests for snapshots, I need to create a snapshot repository which would require setting path.repo in Opensearch and I am not sure how this is done in the github workflows. If you can help me enabling this in the CI I would add integration tests for:

  • snapshotRepo create/delete
  • Snapshot create,delete,restore,clone

@dblock
Copy link
Member

dblock commented Mar 2, 2023

Thanks @Jakob3xD for hanging in here with me. FYI, I am not trying to be difficult, I just want to make sure we are doing the right thing.

  1. There's one important reason: you're introducing a breaking change. Every breaking change per semver requires a major version increment, that's a promise we have made - someone may be using the wrong type today and we will break them with this change. Or am I incorrect and the API doesn't work at all today? I would rather not major-increment the version for this.
  2. I would be ok with any test that exercises this code. Something that mocks the server response is acceptable. But integration tests would be better. If you can't figure out how to do it I can try looking into it or maybe @VachaShah knows too.

@Jakob3xD
Copy link
Collaborator Author

Jakob3xD commented Mar 3, 2023

I understand your point. It wouldn´t make sens to do a mayor release for this. Maybe we keep this PR back until the next mayor release?

As sad I am happy to write the tests. The only thing I need help with is setting the path.repo in the Opensearch config so I can create the snapshot repository.

@dblock
Copy link
Member

dblock commented Mar 6, 2023

I understand your point. It wouldn´t make sens to do a mayor release for this. Maybe we keep this PR back until the next mayor release?

Sure, but what's the reason not to add a backwards compatible version, and marking the wrong interface deprecated?

As sad I am happy to write the tests. The only thing I need help with is setting the path.repo in the Opensearch config so I can create the snapshot repository.

I am not sure how this works, give something a try and we'll help you when you get blocked?

@wbeckler
Copy link

Today, people might be sending in a comma-joined string like "snapshot1,snapshot2,snapshot3" as the parameter, since the function is just comma-joining the array.

Maybe we create a v3 branch of the client today and add this there, while marking the current type declaration as deprecated in the v2 client.

I kind of agree with @Jakob3xD that adding an alternative function with the new type is a bit of overhead. We would carry around SnapshotsDeleteRequest until it was deprecated, forcing a change on devs who would be scratching their heads about the repeat declaration. I think it's a better dev experience to let people use the comma-join workaround and add arrays to v3.

@VachaShah
Copy link
Collaborator

Hi @Jakob3xD sorry for the delay! As @dblock mentioned, atleast unit testing would be good to add where it mocks the server. For integration tests, how about adding the path.repo to the docker file which spins up OpenSearch cluster in the CI?

Signed-off-by: Jakob Hahn <jakob.hahn@hetzner.com>
Signed-off-by: Jakob Hahn <jakob.hahn@hetzner.com>
@Jakob3xD Jakob3xD force-pushed the snapshotDeleteRequest-slice branch from 5cc4697 to 1921267 Compare March 17, 2023 13:58
@Jakob3xD
Copy link
Collaborator Author

@VachaShah I added some integration tests for Snapshot functions and added the setting to the docker file.
Works when testing locally.

@dblock
Copy link
Member

dblock commented Mar 17, 2023

Assuming the new integration tests work, I think we should make this as a breaking change and take #246 along the way and major increment the client version. I don't think we need to maintain and continue releasing the old line either.

@dblock
Copy link
Member

dblock commented Mar 17, 2023

I think we should introduce an UPGRADING.md in this project similar to https://github.com/opensearch-project/opensearch-py/blob/main/UPGRADING.md that will spell breaking changes. Want to add one as part of this PR @Jakob3xD?

@Jakob3xD
Copy link
Collaborator Author

The integration test with unrelased Opensearch fails, as the path setting is missing. If i see it correctly it builds opensearch from source and starts without any given settings. The normal Integration tests with docker works fine. Should I try adding the setting to the workflow https://github.com/opensearch-project/opensearch-go/blob/main/.github/workflows/test-integration-unreleased.yml#L52 ?

@dblock Yes, I will add the file.

@dblock
Copy link
Member

dblock commented Mar 17, 2023

The integration test with unrelased Opensearch fails, as the path setting is missing. If i see it correctly it builds opensearch from source and starts without any given settings. The normal Integration tests with docker works fine. Should I try adding the setting to the workflow https://github.com/opensearch-project/opensearch-go/blob/main/.github/workflows/test-integration-unreleased.yml#L52 ?

@dblock Yes, I will add the file.

Yes, do whatever you need to do to get a green build!

Signed-off-by: Jakob Hahn <jakob.hahn@hetzner.com>
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.

UPGRADING.md Outdated Show resolved Hide resolved
dblock
dblock previously approved these changes Mar 20, 2023
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.

I am good with this change!

@wbeckler This is the first time we're diverging a client version per semver with the server. Any concerns?

Signed-off-by: Jakob Hahn <jakob.hahn@hetzner.com>
dblock
dblock previously approved these changes Mar 21, 2023
dblock
dblock previously approved these changes Mar 22, 2023
@dblock
Copy link
Member

dblock commented Mar 22, 2023

@Jakob3xD looks like integration tests are failing :( care to take a look please?

Signed-off-by: Jakob Hahn <jakob.hahn@hetzner.com>
@Jakob3xD Jakob3xD force-pushed the snapshotDeleteRequest-slice branch from 9b51d13 to 8825feb Compare March 23, 2023 09:01
@dblock dblock merged commit 2d469d4 into opensearch-project:main Mar 23, 2023
@Jakob3xD Jakob3xD deleted the snapshotDeleteRequest-slice branch March 24, 2023 15:46
VachaShah added a commit to VachaShah/opensearch-go that referenced this pull request May 18, 2023
VachaShah added a commit to VachaShah/opensearch-go that referenced this pull request May 18, 2023
dblock pushed a commit that referenced this pull request May 22, 2023
#322)

* Revert "Draft: Add Err() function to Response for detailed errors (#246)"

This reverts commit 8d3cf4d.

Signed-off-by: Vacha Shah <vachshah@amazon.com>

* Fixing PIT APIs introduced in PR #253 since they use response.Err()

Signed-off-by: Vacha Shah <vachshah@amazon.com>

* Removing opensearchapi.Error usage from snapshot tests introduced in PR #237

Signed-off-by: Vacha Shah <vachshah@amazon.com>

* Resolve Changelog conflicts

Signed-off-by: Vacha Shah <vachshah@amazon.com>

---------

Signed-off-by: Vacha Shah <vachshah@amazon.com>
VachaShah added a commit to VachaShah/opensearch-go that referenced this pull request Oct 3, 2023
opensearch-project#322)

* Revert "Draft: Add Err() function to Response for detailed errors (opensearch-project#246)"

This reverts commit 8d3cf4d.

Signed-off-by: Vacha Shah <vachshah@amazon.com>

* Fixing PIT APIs introduced in PR opensearch-project#253 since they use response.Err()

Signed-off-by: Vacha Shah <vachshah@amazon.com>

* Removing opensearchapi.Error usage from snapshot tests introduced in PR opensearch-project#237

Signed-off-by: Vacha Shah <vachshah@amazon.com>

* Resolve Changelog conflicts

Signed-off-by: Vacha Shah <vachshah@amazon.com>

---------

Signed-off-by: Vacha Shah <vachshah@amazon.com>
dblock pushed a commit that referenced this pull request Oct 4, 2023
#322) (#384)

* Revert "Draft: Add Err() function to Response for detailed errors (#246)"

This reverts commit 8d3cf4d.



* Fixing PIT APIs introduced in PR #253 since they use response.Err()



* Removing opensearchapi.Error usage from snapshot tests introduced in PR #237



* Resolve Changelog conflicts



---------

Signed-off-by: Vacha Shah <vachshah@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] SnapshotDelete use []string
4 participants