Skip to content

Allow setting of copy_settings in the HLRC #39752

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

Merged
merged 8 commits into from
Mar 8, 2019

Conversation

dliappis
Copy link
Contributor

@dliappis dliappis commented Mar 6, 2019

#30255 introduced the copy_settings parameter in 6.x.
This commit adds support for setting it via setCopySettings in the
HLRC.

elastic#30255 introduced the `copy_settings` parameter in 6.x.
This commit adds support for setting it via `setCopySettings` in the
HLRC.
@dliappis
Copy link
Contributor Author

dliappis commented Mar 6, 2019

AFAIU (e.g. in

if (rawCopySettings == null) {
copySettings = resizeRequest.getCopySettings();
} else {
if (rawCopySettings.isEmpty()) {
copySettings = true;
} else {
copySettings = Booleans.parseBoolean(rawCopySettings);
if (copySettings == false) {
throw new IllegalArgumentException("parameter [copy_settings] can not be explicitly set to [false]");
}
}
deprecationLogger.deprecated("parameter [copy_settings] is deprecated and will be removed in 8.0.0");
}
) we don't need to backport this to 7.x/7.0 as we don't emit special deprecation warnings when it is unset.

Will be happy to add PRs if this is incorrect though.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features

@dliappis
Copy link
Contributor Author

dliappis commented Mar 6, 2019

@elasticmachine run elasticsearch-ci/default-distro

@hub-cap
Copy link
Contributor

hub-cap commented Mar 6, 2019

@dliappis can you add some docs here as well pls?

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

The production code looks good. I left a comment about the deprecation Javadoc, and I agree with @hub-cap to update the documentation that he referenced too.

@@ -909,6 +909,17 @@ Params withWaitForActiveShards(ActiveShardCount activeShardCount) {
return withWaitForActiveShards(activeShardCount, ActiveShardCount.DEFAULT);
}

/**
* @deprecated <code>copy_settings</code> defaults to <code>true</code> and can not be set to false
Copy link
Member

Choose a reason for hiding this comment

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

Note that the default is unset and behaves as false, however false can not be set explicitly. copy_settings is either unset (default) or set to true (future behavior).

Copy link
Contributor Author

@dliappis dliappis Mar 7, 2019

Choose a reason for hiding this comment

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

Thanks great catch this got forgotten while I was looking at the behavior of other branches.
Addressed in ce68119 and e4b6cb4.

@@ -868,6 +868,12 @@ private void resizeTest(ResizeType resizeType, CheckedFunction<ResizeRequest, Re
ResizeRequest resizeRequest = new ResizeRequest(indices[0], indices[1]);
resizeRequest.setResizeType(resizeType);
Map<String, String> expectedParams = new HashMap<>();

if (ESTestCase.randomBoolean()) {
Copy link
Member

Choose a reason for hiding this comment

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

I see this is in the existing style in this class, but it is at odds with the rest of the codebase where we would simply write randomBoolean().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in ce68119; in a separate PR we can convert everything in this class to randomBoolean() for consistency.

@dliappis
Copy link
Contributor Author

dliappis commented Mar 7, 2019

Docs have been added in 5f05978

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

Looking good now, I left some minor feedback.

@@ -1683,9 +1683,13 @@ public void testShrinkIndex() throws Exception {
request.setWaitForActiveShards(2); // <1>
request.setWaitForActiveShards(ActiveShardCount.DEFAULT); // <2>
// end::shrink-index-request-waitForActiveShards
// tag::shrink-index-request-copySettings
request.setCopySettings(Boolean.TRUE); // <1>
Copy link
Member

Choose a reason for hiding this comment

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

true is more natural

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in de8ca18

--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request-copySettings]
--------------------------------------------------
<1> Use `Boolean.TRUE` to copy the settings from the source index to the target
Copy link
Member

Choose a reason for hiding this comment

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

Use true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in de8ca18

include-tagged::{doc-tests-file}[{api}-request-copySettings]
--------------------------------------------------
<1> Use `Boolean.TRUE` to copy the settings from the source index to the target
index. This cannot be `Boolean.FALSE`. If this method is not used, default behavior is not to copy.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in de8ca18

@@ -868,6 +868,12 @@ private void resizeTest(ResizeType resizeType, CheckedFunction<ResizeRequest, Re
ResizeRequest resizeRequest = new ResizeRequest(indices[0], indices[1]);
resizeRequest.setResizeType(resizeType);
Map<String, String> expectedParams = new HashMap<>();

if (randomBoolean()) {
resizeRequest.setCopySettings(Boolean.TRUE);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
resizeRequest.setCopySettings(Boolean.TRUE);
resizeRequest.setCopySettings(true);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in b20c245

include-tagged::{doc-tests-file}[{api}-request-copySettings]
--------------------------------------------------
<1> Use `true` to copy the settings from the source index to the target
index. This cannot be `false`. If this method is not used, default behavior is not to copy.
Copy link
Member

Choose a reason for hiding this comment

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

Can you wrap to 80 columns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in b20c245

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

I left two more minors, no need for another review round. LGTM. Fire at will.

@dliappis
Copy link
Contributor Author

dliappis commented Mar 8, 2019

I left two more minors, no need for another review round. LGTM. Fire at will.

Thanks a lot for the review effort here. Will merge after CI is green.

@dliappis dliappis merged commit bc689f7 into elastic:6.7 Mar 8, 2019
@dliappis dliappis deleted the hlrc-copy-settings branch March 8, 2019 10:03
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.

4 participants