-
Notifications
You must be signed in to change notification settings - Fork 61
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
Validate analyzer path when starting/resuming replication #64
Conversation
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.
Looks good overall.
Can we please add Integ Tests as per your manual tests as well ?
private fun validateAnalyzerSettings(settings: Settings) { | ||
val analyserSettings = settings.filter{ k: String? -> k!!.matches(Regex("index.analysis.*path"))} | ||
for (analyserSetting in analyserSettings.keySet()) { | ||
val settingValue = analyserSettings.get(analyserSetting) | ||
val path: Path = environment.configFile().resolve(settingValue) | ||
if (!Files.exists(path)) { | ||
val message = "IOException while reading ${analyserSetting}: ${path.toString()}" | ||
log.error(message) | ||
throw ResourceNotFoundException(message) | ||
} | ||
} | ||
} | ||
|
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.
Can we remove the duplication of this method ?
3b071c7
to
2ef3106
Compare
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.
Thanks for making the changes. LGTM.
} | ||
} | ||
|
||
fun `test that replication starts successfully when custom analyser is present in follower`() { |
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.
Can we include one where mapping uses it as well?
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.
The validation is only on whether the analyzer setting is present or not. Whether the replication starts will only depend on the presence of the analyser file and the presence of mapping makes no change.
Why do think there should be a test for the case the mapping uses the analyser ?
Signed-off-by: Sooraj Sinha <[email protected]>
2ef3106
to
3373e6f
Compare
Made some changes in the approach. Along with the validation on the analyzer settings, I am now passing the settings supplied by the user in the replication request to the restore request so that the follower index is bootstrappped with the overridden settings. |
val replMetadata = replicationMetadataManager.getIndexReplicationMetadata(this.followerIndexName) | ||
restoreRequest.indexSettings(replMetadata.settings) |
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.
Where are we overriding the setting
provided from Start
API ?
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.
Yes this is the line where it is done.
replMetadata.settings
provides the settings
input by the user in the request.
Signed-off-by: Sooraj Sinha [email protected]
Description
If a custom analyzer is present in the leader index, then the replication would silently fail if the same analyzer is not present in the follower cluster as well.
So this change validates the presence of analyzer on the follower cluster before starting or resuming the replication. If the analyzer is not present, the we will fail the replication upfront.
Also, the user input settings in the replication request are now set to the restore request so that the follower index is created with the bootstrapped settings.
Testing
Normal IT are passing.
Manual testing as below:
synonyms.txt
on leader then placedsynonyms1.txt
and follower. Then while starting the replication, overrode the setting withsynonyms1.txt
and the replication was successfulIssues Resolved
#63
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.