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

Migrating from terraform.languageServer.rootModules to VSC workspaces #1543

Closed
1 task
Makeshift opened this issue Jul 20, 2023 · 3 comments
Closed
1 task
Labels
documentation Improvements or additions to documentation performance Gotta go fast

Comments

@Makeshift
Copy link

Makeshift commented Jul 20, 2023

Description

To try and help alleviate some issues with insanely high CPU usage and slow responses from the extension (#1328, #1355, #1516 etc), I switched to the pre-release version of the extension.

I noticed that in the pre-release, the terraform.languageServer.rootModules is marked as deprecated and is a no-op, probably due to hashicorp/terraform-ls#704 and similar PRs. Based on my experimentation, the only way I'm able to make the extension vaguely useable and not kill my machine is to specifically set my two root modules with this setting (on the current released version, 2.27.0 with terraform-ls 0.31.3).

Based on the Readme in this repository, it isn't clear how to migrate my project over to vscode workspaces in such a way that allows the extension to run correctly, and my workspace remaining easy to use. For reference, this is my approximate folder structure:

project/
  .vscode/
  otherstuff.ext
  terraform/
    folder1/
      terraform-module-root-dir-1/
      a-folder-with-modules-used-by-root-dir-1/
    folder2/
      terraform-module-root-dir-2/
      a-folder-with-modules-used-by-root-dir-2

With this layout, I open project in vscode, and that's it. This is in my workspaces settings.json:

  "terraform.languageServer.rootModules": [
    "/terraform/folder1/terraform-module-root-dir-1",
    "/terraform/folder2/terraform-module-root-dir-2"
  ],
  "terraform.experimentalFeatures.prefillRequiredFields": true,
  "terraform.experimentalFeatures.validateOnSave": true,
  "terraform.codelens.referenceCount": false,
  "terraform.languageServer.ignoreDirectoryNames": [
    "lambdas",
    "node_modules"
  ],

Is this layout insane, and therefore unsupported by the extension, or is there a migration path for removing rootModules and moving over to workspaces for this?

The extension is usable at the moment with the rootModules setting. It is completely unusable and streams continuous noise into the HashiCorp Terraform output log without the setting.

Links

https://github.com/hashicorp/vscode-terraform/blob/main/README.md

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@Makeshift Makeshift added the documentation Improvements or additions to documentation label Jul 20, 2023
@radeksimko radeksimko added the performance Gotta go fast label Aug 2, 2023
@radeksimko
Copy link
Member

Hi @Makeshift

I noticed that in the pre-release, the terraform.languageServer.rootModules is marked as deprecated and is a no-op

This setting became deprecated and no-op already in 2.24.0 (in LS 0.29.0) which was released in August last year (to both stable and pre-release).

Therefore I do not understand how the following is possible. 🤔

Based on my experimentation, the only way I'm able to make the extension vaguely useable ... is to specifically set my two root modules with this setting (on the current released version, 2.27.0 with terraform-ls 0.31.3)

In case you are in fact migrating from version older than 2.24.0, we do have a page describing the migration process at https://github.com/hashicorp/vscode-terraform/blob/main/docs/settings-migration.md


On the note of performance

In general, this option was never expected to do anything different to what workspaces achieve today - that is to let the user explicitly index a folder.

I recall that we have made other changes which are less related to the setting deprecation - specifically that we index not just the files within the given folder but recursively walk all nested folders and index any nested files. This may be what impacted the performance for some users.

Indexing nested modules comes with some trade-offs and we could consider making the depth configurable.


In terms of possible workarounds, before we find more permanent solutions to the performance issues, you could try to disable/enable the extension selectively for the individual workspaces and work across different workspaces. i.e. have one workspace for the root folder (where the extension remains disabled) + any number of separate ones for the individual Terraform modules (where the extension remains enabled).

You may notice these options in the Extensions sidebar:
Screenshot 2023-08-02 at 10 09 46

I hope that helps!

@Makeshift
Copy link
Author

@radeksimko Thank you for your detailed response! It sounds like I may have been at the mercy of some caching, which could have confused me into thinking one configuration was working better than another.

With some experimentation, I've gotten it to be seemingly stable, and I don't foresee anything quite as weird as my current heavily-nested project in the near future (I primarily use Terragrunt anyway, making interactions between stacks a lot simpler and making modules more... modular). I'll close this issue for the moment and if I encounter any more specific issues I'll open a new one with better detail.

@github-actions
Copy link

github-actions bot commented Sep 2, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation performance Gotta go fast
Projects
None yet
Development

No branches or pull requests

2 participants