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

Expand snapshot repository types #2255

Merged
merged 13 commits into from
Mar 6, 2024
Merged

Expand snapshot repository types #2255

merged 13 commits into from
Mar 6, 2024

Conversation

JoshMock
Copy link
Member

Use a different type definition for each repository type since differences are significant.

A community member noted that some types were missing for S3 snapshot repositories, and inspecting the spec made it clear that it was an issue beyond just S3.

Use a different type definition for each repository type since
differences are significant.
settings: SourceOnlyRepositorySettings
}

export type RepositorySettings =
Copy link
Member

Choose a reason for hiding this comment

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

Seems like we don't need this type.

Copy link
Member Author

Choose a reason for hiding this comment

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

It gets imported and used here. I'm not sure why the request body accepts both repository and settings keys when repository.settings also exists. 🤷

Copy link
Member

Choose a reason for hiding this comment

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

Hmm... I'll look at the ES source code to understand if this is needed. Now @variants internal tag='type' won't work here since the union members don't have a type property.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch on the type property. Fixed that.

Hmm... I'll look at the ES source code to understand if this is needed.

I am still not great at navigating the Java codebase, but if this is the request, it certainly does not seem like it supports an optional repository property. I scrolled through a lot of the repository creation tests, too, and didn't see it. Feel free to correct my reading of it if I'm totally in the wrong place.

Copy link
Member

Choose a reason for hiding this comment

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

We have to look a the parsing or the request body - the request just has type and settings. So it's actually a plain Repository object.

And when we look at the docs there's no type attribute inside the settings.

So we need to remove the type field in all repository settings, and also this RepositorySettings enumeration.

And SnapshotRepositoryCreateRequest should be updated to have body: Repository.

Once this is done, we're good to go!

So we can get a repository's uuid without having to cast to its exact
type.
@JoshMock JoshMock requested a review from swallez August 30, 2023 19:50
@DesAWSume
Copy link

For interface SnapshotRepositorySettings , it has read_only and readonly, any way we can make it clearer what each individual behave?

@JoshMock
Copy link
Member Author

@DesAWSume readonly is an alias for read_only in the spec, I presume for some backward compatibility. I'm not sure if there's a clear way in TypeScript or TSDoc/JSDoc to annotate that fact, but I can take a look. I get that it can be confusing.

@JoshMock
Copy link
Member Author

@DesAWSume I did discover JSDoc has an @alias tag, but its usefulness likely depends on how your IDE uses it. In mine (Neovim with language server support) it just adds an @alias to the type definition popup, but still allows you to use both.

2023-08-31T16:12:52,740847821-05:00

@JoshMock
Copy link
Member Author

JoshMock commented Sep 8, 2023

@swallez could I get a final review on this? only outstanding thing is this concern, but it was already in there like this so maybe we can address separately.

settings: SourceOnlyRepositorySettings
}

export type RepositorySettings =
Copy link
Member

Choose a reason for hiding this comment

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

We have to look a the parsing or the request body - the request just has type and settings. So it's actually a plain Repository object.

And when we look at the docs there's no type attribute inside the settings.

So we need to remove the type field in all repository settings, and also this RepositorySettings enumeration.

And SnapshotRepositoryCreateRequest should be updated to have body: Repository.

Once this is done, we're good to go!

@JoshMock
Copy link
Member Author

@swallez One month and a parental leave later... I think I got the last of this sorted out. 😆 Please take a look and let me know if I addressed what you were saying properly.

@JoshMock JoshMock requested a review from a team as a code owner March 6, 2024 12:33
Copy link
Contributor

github-actions bot commented Mar 6, 2024

Following you can find the validation results for the APIs you have changed.

API Status Request Response
snapshot.cleanup_repository 🟢 3/3 3/3
snapshot.clone 🟢 5/5 5/5
snapshot.create_repository 🔴 24/29 29/29
snapshot.create 🔴 26/26 25/26
snapshot.delete_repository 🟢 10/10 10/10
snapshot.delete 🟢 20/20 20/20
snapshot.get_repository 🔴 19/19 7/19
snapshot.get 🟢 13/13 13/13
snapshot.repository_analyze 🟠 Missing type Missing type
snapshot.restore 🔴 5/5 3/5
snapshot.status 🟢 2/2 2/2
snapshot.verify_repository 🟢 2/2 2/2

You can validate these APIs yourself by using the make validate target.

Copy link
Member

@swallez swallez left a comment

Choose a reason for hiding this comment

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

@JoshMock I added a few commits:

  • fix a bug/limitation of compiler validations so that conflicting identifiers check include the codegen_name annotation...
  • ... which allows to use repository instead of repository_settings for the body name (repository was used in the original code, this will avoid breaking changes in some languages)
  • removed the type attribute in settings class
  • only kept readonly and removed read_only as I couldn't find read_only in the source code or in the docs.

@swallez swallez merged commit c45e69e into main Mar 6, 2024
10 checks passed
@swallez swallez deleted the snapshot-repos branch March 6, 2024 16:53
Copy link
Contributor

github-actions bot commented Mar 6, 2024

The backport to 7.17 failed:

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

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-7.17 7.17
# Navigate to the new working tree
cd .worktrees/backport-7.17
# Create a new branch
git switch --create backport-2255-to-7.17
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 c45e69e81dc10e95176638cb415c2c3143faccfa
# Push it to GitHub
git push --set-upstream origin backport-2255-to-7.17
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-7.17

Then, create a pull request where the base branch is 7.17 and the compare/head branch is backport-2255-to-7.17.

github-actions bot pushed a commit that referenced this pull request Mar 6, 2024
swallez pushed a commit that referenced this pull request Mar 6, 2024
(cherry picked from commit c45e69e)

Co-authored-by: Josh Mock <[email protected]>
swallez pushed a commit that referenced this pull request Mar 6, 2024
swallez added a commit that referenced this pull request Mar 6, 2024
@JoshMock
Copy link
Member Author

JoshMock commented Mar 6, 2024

thanks so much @swallez! ❤️

untergeek added a commit to untergeek/curator that referenced this pull request Apr 3, 2024
**Announcement**

  * A long awaited feature has been added, stealthily. It's fully in the documentation, but I do
    not yet plan to make a big announcement about it. In actions that search through indices, you
    can now specify a ``search_pattern`` to limit the number of indices that will be filtered. If
    no search pattern is specified, the behavior will be the same as it ever was: it will search
    through ``_all`` indices. The actions that support this option are: allocation, close,
    cold2frozen, delete_indices, forcemerge, index_settings, open, replicas, shrink, and snapshot.

**Bugfix**

  * A mixup with naming conventions from the PII redacter tool got in the way of the cold2frozen
    action completing properly.

**Changes**

  * Version bump: ``es_client==8.13.0``
      * With the version bump to ``es_client`` comes a necessary change to calls to create a
        repository. In elastic/elasticsearch-specification#2255 it became
        clear that using ``type`` and ``settings`` as it has been was insufficient for repository
        settings, so we go back to using a request ``body`` as in older times. This change affects
        ``esrepomgr`` in one place, and otherwise only in snapshot/restore testing.
  * Added the curator.helpers.getters.meta_getter to reduce near duplicate functions.
  * Changed curator.helpers.getters.get_indices to use the _cat API to pull indices. The primary
    driver for this is that it avoids pulling in the full mapping and index settings when all we
    really need to return is a list of index names. This should help keep memory from ballooning
    quite as much. The function also now allows for a search_pattern kwarg to search only for
    indices matching a pattern. This will also potentially make the initial index return list much
    smaller, and the list of indices needing to be filtered that much smaller.
  * Tests were added to ensure that the changes for ``get_indices`` work everywhere.
  * Tests were added to ensure that the new ``search_pattern`` did not break anything, and does
    behave as expected.
untergeek added a commit to elastic/curator that referenced this pull request Apr 3, 2024
* WIP branch for debugging cold2frozen weirdness

* Release prep for 8.0.14

**Announcement**

  * A long awaited feature has been added, stealthily. It's fully in the documentation, but I do
    not yet plan to make a big announcement about it. In actions that search through indices, you
    can now specify a ``search_pattern`` to limit the number of indices that will be filtered. If
    no search pattern is specified, the behavior will be the same as it ever was: it will search
    through ``_all`` indices. The actions that support this option are: allocation, close,
    cold2frozen, delete_indices, forcemerge, index_settings, open, replicas, shrink, and snapshot.

**Bugfix**

  * A mixup with naming conventions from the PII redacter tool got in the way of the cold2frozen
    action completing properly.

**Changes**

  * Version bump: ``es_client==8.13.0``
      * With the version bump to ``es_client`` comes a necessary change to calls to create a
        repository. In elastic/elasticsearch-specification#2255 it became
        clear that using ``type`` and ``settings`` as it has been was insufficient for repository
        settings, so we go back to using a request ``body`` as in older times. This change affects
        ``esrepomgr`` in one place, and otherwise only in snapshot/restore testing.
  * Added the curator.helpers.getters.meta_getter to reduce near duplicate functions.
  * Changed curator.helpers.getters.get_indices to use the _cat API to pull indices. The primary
    driver for this is that it avoids pulling in the full mapping and index settings when all we
    really need to return is a list of index names. This should help keep memory from ballooning
    quite as much. The function also now allows for a search_pattern kwarg to search only for
    indices matching a pattern. This will also potentially make the initial index return list much
    smaller, and the list of indices needing to be filtered that much smaller.
  * Tests were added to ensure that the changes for ``get_indices`` work everywhere.
  * Tests were added to ensure that the new ``search_pattern`` did not break anything, and does
    behave as expected.
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.

3 participants