Skip to content

Conversation

@dadoonet
Copy link
Contributor

When someone migrates from 5.6 to 6.x with deprecated settings like:

cloud:
    azure:
        storage:
            foo:
                account: <my_account>
                key: <my_key>

It produces a NPE anytime someone wants to use a repository which name is not default.

This has been introduced by #23518 when I backported it to 6.x branch.
In this case, when we generate an OperationContext, we only try to get azure settings from "normal" storageSettings with:

this.storageSettings.get(clientName)

But in the context of deprecated settings, this returns null which causes the NPE just after.

This commit adds a check and if no settings are found in the "normal" storageSettings, we look at settings from deprecatedStorageSettings.
The reason I missed it in the 7.0 version (master branch) is because actually deprecatedStorageSettings has been removed there already.

Also I modified the testGetSelectedClientDefault method which was only doing exactly the same thing as testGetDefaultClientWithPrimaryAndSecondaries.

Closes #28299.

When someone migrates from 5.6 to 6.x with deprecated settings like:

```
cloud:
    azure:
        storage:
            foo:
                account: <my_account>
                key: <my_key>
```

It produces a NPE anytime someone wants to use a repository which name is not `default`.

This has been introduced by elastic#23518 when I backported it to 6.x branch.
In this case, when we generate an OperationContext, we only try to get azure settings from "normal" `storageSettings` with:

```java
this.storageSettings.get(clientName)
```

But in the context of deprecated settings, this returns `null` which causes the NPE just after.

This commit adds a check and if no settings are found in the "normal" `storageSettings`, we look at settings from `deprecatedStorageSettings`.
The reason I missed it in the 7.0 version (master branch) is because actually `deprecatedStorageSettings` has been removed there already.

Also I modified the `testGetSelectedClientDefault` method which was only doing exactly the same thing as `testGetDefaultClientWithPrimaryAndSecondaries`.

Closes elastic#28299.
@dadoonet dadoonet added >bug :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v6.3.0 labels Feb 21, 2018
@dadoonet dadoonet self-assigned this Feb 21, 2018
@dadoonet dadoonet requested a review from rjernst February 21, 2018 16:11
@dadoonet
Copy link
Contributor Author

@rjernst I set the target for now to 6.x (6.3.0) but I believe that it should also go in 6.2 and may be 6.1. WDYT?

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

}

@Deprecated
public void testGetSelectedClientDefault() {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this test still be calling getSelectedClient (which in turn calls generateOperationContext)? Otherwise the name should be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. Because getSelectedClient never calls generateOperationContext where the NPE happened.
I'm going to rename the method indeed to make that more obvious.

@dadoonet
Copy link
Contributor Author

dadoonet commented Feb 22, 2018

@rjernst Thanks for the fast review! What is your opinion about backporting? I think it's a bad bug for people upgrading from 5.x to 6.x so I believe we should backport to 6.2.
I don't think we will release another 6.1 or 6.0 version so backporting to 6.1 and 6.0 is useless?

As we only test the `generateOperationContext` call, that makes a lot of sense to rename it.
@elasticdog
Copy link
Contributor

Jenkins, test this please. (my apologies, I had to restart elasticsearch-ci to perform some upgrades, so this job never finished building)

@rjernst
Copy link
Member

rjernst commented Feb 25, 2018

@dadoonet I would backport to 6.x and 6.2.

@dadoonet dadoonet merged commit b91e2d5 into elastic:6.x Feb 26, 2018
@dadoonet dadoonet deleted the pr/28299-azure-npe branch February 26, 2018 23:56
dadoonet added a commit that referenced this pull request Feb 27, 2018
* Fix NPE when using deprecated Azure settings

When someone migrates from 5.6 to 6.x with deprecated settings like:

```
cloud:
    azure:
        storage:
            foo:
                account: <my_account>
                key: <my_key>
```

It produces a NPE anytime someone wants to use a repository which name is not `default`.

This has been introduced by #23518 when I backported it to 6.x branch.
In this case, when we generate an OperationContext, we only try to get azure settings from "normal" `storageSettings` with:

```java
this.storageSettings.get(clientName)
```

But in the context of deprecated settings, this returns `null` which causes the NPE just after.

This commit adds a check and if no settings are found in the "normal" `storageSettings`, we look at settings from `deprecatedStorageSettings`.
The reason I missed it in the 7.0 version (master branch) is because actually `deprecatedStorageSettings` has been removed there already.

Also I renamed the `testGetSelectedClientDefault` method to `testGenerateOperationContext`
as it was only doing exactly the same thing as `testGetDefaultClientWithPrimaryAndSecondaries`.

Closes #28299.

Backport of #28769 in 6.2 branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v6.2.3 v6.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants