-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Fix NPE when using deprecated Azure settings #28769
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
Conversation
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.
|
@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? |
rjernst
left a comment
There was a problem hiding this 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() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
@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. |
As we only test the `generateOperationContext` call, that makes a lot of sense to rename it.
|
Jenkins, test this please. (my apologies, I had to restart elasticsearch-ci to perform some upgrades, so this job never finished building) |
|
@dadoonet I would backport to 6.x and 6.2. |
* 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.
When someone migrates from 5.6 to 6.x with deprecated settings like:
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"
storageSettingswith:But in the context of deprecated settings, this returns
nullwhich causes the NPE just after.This commit adds a check and if no settings are found in the "normal"
storageSettings, we look at settings fromdeprecatedStorageSettings.The reason I missed it in the 7.0 version (master branch) is because actually
deprecatedStorageSettingshas been removed there already.Also I modified the
testGetSelectedClientDefaultmethod which was only doing exactly the same thing astestGetDefaultClientWithPrimaryAndSecondaries.Closes #28299.