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

[BUG] S3 snapshot repositories without settings fail to deserialize #573

Closed
drewfead opened this issue Mar 28, 2024 · 1 comment · Fixed by #587
Closed

[BUG] S3 snapshot repositories without settings fail to deserialize #573

drewfead opened this issue Mar 28, 2024 · 1 comment · Fixed by #587
Labels
bug Something isn't working

Comments

@drewfead
Copy link

drewfead commented Mar 28, 2024

What is the bug?

When listing snapshot repositories using Snapshot.GetRepositoryAsync(), s3 repositories without settings can't be deserialized.

How can one reproduce the bug?

Using an AWS opensearch domain (not serverless) running version OpenSearch_2_11_R20231113-P3, when I send this request:

GET ***.es.amazonaws.com/_snapshot/_all?pretty

I get a response like this (some data redacted):

{
    "cs-automated": {
        "type": "s3"
    },
    "authoring-service-snapshots": {
        "type": "s3",
        "settings": {
            "bucket": "...",
            "region": "us-west-2",
            "role_arn": "..."
        }
    }
}

The cs-automated snapshot repository seems to have been created on my behalf by AWS, and is therefore presumably valid.

Using this call defined by the IOpenSearchClient, using version 1.7.0:

GetRepositoryResponse? listRepositories = await _client.Snapshot.GetRepositoryAsync(
    ct: cancel
);

The call fails with the exception message Cannot create an instance of OpenSearch.Client.S3Repository because it has no constructor taking 0 arguments.

What is the expected behavior?

A GetRepositoryResponse would be returned successfully containing two S3Repositorys in its Repositories dictionary, one with either null or empty settings, and the other with appropriately populated settings.

What is your host/environment?

I have seen the same issue locally using macOS and in the deployed environment running on x86 and arm ec2 instances (in a container).

Do you have any screenshots?

N/A

Do you have any additional context?

It seems to hit this condition:

if (settings == default)
return typeof(TRepository).CreateInstance<TRepository>();

and attempts to invoke a constructor by reflection that doesn't exist.

As a workaround I've tried listing all of the repositories besides cs-automated using the documented support for exclude pattern, but it doesn't work as expected on the server-side. I.e.

GET ***.es.amazonaws.com/_snapshot/*,-cs-automated?pretty

results in the following response

{
    "error": {
        "root_cause": [
            {
                "type": "repository_missing_exception",
                "reason": "[-cs-automated] missing"
            }
        ],
        "type": "repository_missing_exception",
        "reason": "[-cs-automated] missing"
    },
    "status": 404
}

Since this area in the opensearch documentation is sparse, please advise if my query format expectations are wrong (there are no relevant examples of using exclude patterns in the official docs).

@Xtansia
Copy link
Collaborator

Xtansia commented Apr 17, 2024

@drewfead A fix for this has now been released as v1.7.1, it'd be great if you could confirm if this solves your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants