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

Watch provider changes to cache schema #16

Closed
radeksimko opened this issue Feb 23, 2020 · 1 comment
Closed

Watch provider changes to cache schema #16

radeksimko opened this issue Feb 23, 2020 · 1 comment
Assignees
Milestone

Comments

@radeksimko
Copy link
Member

radeksimko commented Feb 23, 2020

Obtaining schema is expensive and can take ~1 second even on a smaller provider such as github.

We should consider caching the schema as part of initialize and invalidating the cache whenever the provider changes (as the schema it would output may changed).

Possibly related to https://github.com/radeksimko/terraform-ls/issues/15 - we might be able to watch for .terraform directory changes, but we need to reflect the reality of LSP clients not supporting workspace/didChangeWatchedFiles, such as Sublime Text

We also might want to account for users storing providers outside of current work directory - i.e. we can just error out if there is no .terraform repository and no TF_PLUGIN_DIR ENV variable

@radeksimko radeksimko changed the title Detect provider changes to cache schema Watch provider changes to cache schema Mar 6, 2020
@radeksimko radeksimko self-assigned this Mar 9, 2020
radeksimko added a commit that referenced this issue Mar 11, 2020
The (currently simple) discovery *and* checking currently happens
during textDocument/completion, which is suboptimal from performance
and responsibility perspective, but it is an acceptable technical debt
as #16 will address that.

Closes #7
@radeksimko
Copy link
Member Author

Possibly related to #15 - we might be able to watch for .terraform directory changes, but we need to reflect the reality of LSP clients not supporting workspace/didChangeWatchedFiles, such as Sublime Text

The reason we should consider implementing this method is because under certain conditions it would limit the number of file-watchers running alongside each other, potentially even monitoring the same files, which is suboptimal. The LSP's assumption is that there will usually be less clients than servers and so centralisation of such logic can save resources.

I decided not to implement it initially though, because we can't afford just having invalid cache when the client doesn't implement that method, so having a built-in watcher seems like a necessary baseline to start with.

We can however add this later to provide some resource relief to those who use clients that support this.

We also might want to account for users storing providers outside of current work directory - i.e. we can just error out if there is no .terraform repository and no TF_PLUGIN_CACHE_DIR ENV variable

There are actually two things I mixed up.

Firstly there is path for custom provider binaries - which seems to be always ~/.terraform.d/plugins / %APPDATA%\terraform.d\plugins with no way of overriding via any ENV variable.

The second one, which is the one LS should actually be interested in is the path to the plugin cache which can be set via CLI config file or ENV variable TF_PLUGIN_CACHE_DIR.

We can revisit this later.

Importantly this does NOT mean we wouldn't support third party plugins - these can be installed into the appropriate location and will get picked up by terraform providers schema -json automatically and hashes will be stored in a lock file under the usual location (<workspace-dir>/.terraform/plugins/) after terraform init.

@radeksimko radeksimko added this to the v0.1.0 milestone Mar 20, 2020
@ghost ghost locked and limited conversation to collaborators Jun 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant