You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On shutdown of the server (e.g. initiated by quitting the IDE) it should cancel any operations running on the root module, such as:
terraform version
obtaining schema via terraform providers schema -json
parsing module manifest
Actual Behavior
Terraform executions will get cancelled either way, because they either inherit the session context or watcher context, both of which get cancelled as part of the shutdown:
svc.logger.Println("Stopping watcher for session ...")
err:=svc.ww.Stop()
iferr!=nil {
svc.logger.Println("Unable to stop watcher for session:", err)
}
svc.stopSession()
A new challenge arises once we make walking asynchronous.
While the walker itself will be cancellable, the operations launched by the walker such as adding new root modules (and then performing any of the above) will retain context of the session and therefore can't be cancelled as part of walker cancellation.
This may result in multiple seconds of delay on shutdown while waiting for terraform to finish executing.
Further Context
Each root module gets its own non-cancellable context at the moment:
Generally the context-related logic in rootmodule needs some overhaul to avoid persisting context.
This may require some more explicit workflow management, explicit cancellation of each individual RootModule, and perhaps explicit cancellation of RootModuleManager (which will in turn cancel and remove any tracked root modules).
In other words we should only be persisting context.CancelFunc for each root module, but not the full context.
The text was updated successfully, but these errors were encountered:
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 context necessary to investigate further.
ghost
locked and limited conversation to collaborators
Aug 8, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Server Version
Expected Behavior
On shutdown of the server (e.g. initiated by quitting the IDE) it should cancel any operations running on the root module, such as:
terraform version
terraform providers schema -json
Actual Behavior
Terraform executions will get cancelled either way, because they either inherit the session context or watcher context, both of which get cancelled as part of the shutdown:
terraform-ls/langserver/handlers/service.go
Lines 224 to 230 in c3bdf23
A new challenge arises once we make walking asynchronous.
While the walker itself will be cancellable, the operations launched by the walker such as adding new root modules (and then performing any of the above) will retain context of the session and therefore can't be cancelled as part of walker cancellation.
This may result in multiple seconds of delay on shutdown while waiting for terraform to finish executing.
Further Context
Each root module gets its own non-cancellable context at the moment:
terraform-ls/internal/terraform/rootmodule/root_module_manager.go
Line 83 in c3bdf23
Generally the context-related logic in
rootmodule
needs some overhaul to avoid persisting context.This may require some more explicit workflow management, explicit cancellation of each individual
RootModule
, and perhaps explicit cancellation ofRootModuleManager
(which will in turn cancel and remove any tracked root modules).In other words we should only be persisting
context.CancelFunc
for each root module, but not the full context.The text was updated successfully, but these errors were encountered: