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

Plugin FilePermission #74275

Closed
KennFalcon opened this issue Jun 18, 2021 · 6 comments
Closed

Plugin FilePermission #74275

KennFalcon opened this issue Jun 18, 2021 · 6 comments
Labels
:Core/Infra/Plugins Plugin API and infrastructure >enhancement Team:Core/Infra Meta label for core/infra team

Comments

@KennFalcon
Copy link

I learned that Elasticsearch does not allow plugins to have write and delete file permissions. As a result, the analysis plugin I developed cannot use the hot update dictionary. The old dictionary can not delete and the new can not write. Can the plugin have read and write permissions in the plugin directory?

@KennFalcon KennFalcon added >enhancement needs:triage Requires assignment of a team area label labels Jun 18, 2021
@matriv matriv added the :Core/Infra/Plugins Plugin API and infrastructure label Jun 18, 2021
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Jun 18, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@gwbrown gwbrown removed the needs:triage Requires assignment of a team area label label Jun 21, 2021
@stu-elastic
Copy link
Contributor

Hi @KennFalcon, thanks for the issue.

Why does the custom plugin need to hot update the dictionary? If you could elaborate your use-case, that'd be helpful. Is there another strategy without read/delete permission that would achieve the same ends?

To set expectations, we won't have time to address this issue for a few months. However, in the meantime, providing the use-case will help us with context.

@KennFalcon
Copy link
Author

My plugin is Chinese word segmentation plugin. Before 7.11.0, I created the new dictionary which had new Chinese word in my plugin's dictionary, then read it regularly. But if the dictionary had a great many words, the process would take a lot of time. So my plugin read the dictionary which had part of speech and build a binary file which adopt double array trie on the first load. When the elasticsearch restarted, the plugin would read the binary file and didn't need to read the original dictionary file again. This loading procedure was fast, and the analysis procedure used the double array trie directly. If the new dictionary added to the plugin directory, the binary file would deleted and rebuild.

@stu-elastic
Copy link
Contributor

It would take us a lot of work to add write permissions for plugins safely. Can you generate the trie from the dictionary beforehand and load them both?

@KennFalcon
Copy link
Author

The main reason is that the dictionary may change frequently, so I used the hot update method. Can only give the plugin write permission in its own plugin directory?

@rjernst
Copy link
Member

rjernst commented Jul 30, 2021

@KennFalcon Granting write permissions for the plugin installation directory is not something we plan to ever allow. The plugin directory is code, just like the lib and modules directories.

I have a couple suggestions for how you might go about updating your data. The first is to store the dictionary in your plugin's config directory. While this does not have write permissions at runtime, you could update the file outside of Elasticsearch, and watch for changes to the file within your plugin. This still requires pushing your dictionary to all nodes though. That brings up the second idea, which is to store your dictionary as a document (say a base64 encoded blob) in an ancillary index. You can periodically do a read of the special document, and thus all your nodes would get the update. The downside is you would not want the polling frequency to be too fast, so it would probably result in a slower update than pushing to every node's filesystem yourself.

Given that plugins lacking write permission to their own installation directory is by design, and we do not plan to change that, I hope you don't mind that I close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Plugins Plugin API and infrastructure >enhancement Team:Core/Infra Meta label for core/infra team
Projects
None yet
Development

No branches or pull requests

6 participants