Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hashicorp/terraform-ls into hcinsta…
Browse files Browse the repository at this point in the history
…ll-switch
  • Loading branch information
rtim75 committed Jan 5, 2022
2 parents 776157c + 4cf9ee9 commit 119fa04
Show file tree
Hide file tree
Showing 7 changed files with 315 additions and 80 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 0.25.1 (Unreleased)

BUG FIXES:

- Reduce parallelism for background operations to flatten CPU spikes triggered by workspaces with many modules on machines w/ >2 CPUs (which would previously had higher parallelism) ([#752](https://github.com/hashicorp/terraform-ls/pull/752))

INTERNAL:

- build(deps): bump github.com/creachadair/jrpc2 from 0.32.0 to 0.35.2 ([#748](https://github.com/hashicorp/terraform-ls/pull/748))
- build(deps): bump github.com/spf13/afero from 1.6.0 to 1.7.1 ([#747](https://github.com/hashicorp/terraform-ls/pull/747))
- build(deps): bump github.com/mitchellh/mapstructure from 1.4.2 to 1.4.3 ([#732](https://github.com/hashicorp/terraform-ls/pull/732))
- build(deps): bump github.com/hashicorp/hcl/v2 from 2.10.1 to 2.11.1 ([#731](https://github.com/hashicorp/terraform-ls/pull/731))

## 0.25.0 (2 December 2021)

ENHANCEMENTS:
Expand Down
11 changes: 5 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ go 1.13
require (
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg v1.0.0
github.com/creachadair/jrpc2 v0.32.0
github.com/creachadair/jrpc2 v0.35.2
github.com/fsnotify/fsnotify v1.5.1
github.com/google/go-cmp v0.5.6
github.com/google/uuid v1.2.0 // indirect
github.com/hashicorp/go-getter v1.5.9
github.com/hashicorp/go-getter v1.5.10
github.com/hashicorp/go-memdb v1.3.2
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-uuid v1.0.2
github.com/hashicorp/go-version v1.3.0
github.com/hashicorp/hc-install v0.3.1
github.com/hashicorp/hcl-lang v0.0.0-20211123142056-191cd51dec5b
github.com/hashicorp/hcl/v2 v2.10.1
github.com/hashicorp/hcl/v2 v2.11.1
github.com/hashicorp/terraform-exec v0.15.0
github.com/hashicorp/terraform-json v0.13.0
github.com/hashicorp/terraform-registry-address v0.0.0-20210816115301-cb2034eba045
Expand All @@ -26,15 +26,14 @@ require (
github.com/mitchellh/cli v1.1.2
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.2
github.com/mitchellh/mapstructure v1.4.3
github.com/pmezard/go-difflib v1.0.0
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546
github.com/spf13/afero v1.6.0
github.com/spf13/afero v1.7.1
github.com/stretchr/testify v1.7.0
github.com/vektra/mockery/v2 v2.9.4
github.com/zclconf/go-cty v1.10.0
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b
golang.org/x/tools v0.1.8-0.20211014194737-fc98fb2abd48
honnef.co/go/tools v0.2.0 // indirect
)
310 changes: 280 additions & 30 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/langserver/langserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (ls *langServer) StartTCP(address string) error {

go func() {
ls.logger.Println("Starting loop server ...")
err = server.Loop(accepter, ls.newService, &server.LoopOptions{
err = server.Loop(context.TODO(), accepter, ls.newService, &server.LoopOptions{
ServerOptions: ls.srvOptions,
})
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions internal/state/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,19 +431,19 @@ provider "blah" {
"test.tf": {
{
Severity: hcl.DiagError,
Summary: "Argument or block definition required",
Detail: "An argument or block definition is required here.",
Summary: "Unclosed configuration block",
Detail: "There is no closing brace for this block before the end of the file. This may be caused by incorrect brace nesting elsewhere in this file.",
Subject: &hcl.Range{
Filename: "test.tf",
Start: hcl.Pos{
Line: 4,
Column: 1,
Byte: 39,
Line: 2,
Column: 17,
Byte: 17,
},
End: hcl.Pos{
Line: 4,
Column: 1,
Byte: 39,
Line: 2,
Column: 18,
Byte: 18,
},
},
},
Expand Down Expand Up @@ -485,8 +485,8 @@ dev = {
"test.tfvars": {
{
Severity: hcl.DiagError,
Summary: "Invalid expression",
Detail: "Expected the start of an expression, but found an invalid expression token.",
Summary: "Missing expression",
Detail: "Expected the start of an expression, but found the end of the file.",
Subject: &hcl.Range{
Filename: "test.tfvars",
Start: hcl.Pos{
Expand Down
31 changes: 2 additions & 29 deletions internal/terraform/module/module_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package module
import (
"context"
"log"
"runtime"
"sync/atomic"
"time"

Expand All @@ -30,13 +29,12 @@ type moduleLoader struct {
}

func newModuleLoader(fs filesystem.Filesystem, modStore *state.ModuleStore, schemaStore *state.ProviderSchemaStore) *moduleLoader {
p := loaderParallelism(runtime.NumCPU())
plc, lc := int64(0), int64(0)
ml := &moduleLoader{
queue: newModuleOpsQueue(fs),
logger: defaultLogger,
nonPrioParallelism: p.NonPriority,
prioParallelism: p.Priority,
nonPrioParallelism: 1,
prioParallelism: 1,
opsToDispatch: make(chan ModuleOperation, 1),
loadingCount: &lc,
prioLoadingCount: &plc,
Expand All @@ -48,31 +46,6 @@ func newModuleLoader(fs filesystem.Filesystem, modStore *state.ModuleStore, sche
return ml
}

type parallelism struct {
NonPriority, Priority int64
}

func loaderParallelism(cpu int) parallelism {
// Cap utilization for powerful machines
if cpu >= 4 {
return parallelism{
NonPriority: int64(3),
Priority: int64(1),
}
}
if cpu == 3 {
return parallelism{
NonPriority: int64(2),
Priority: int64(1),
}
}

return parallelism{
NonPriority: 1,
Priority: 1,
}
}

func (ml *moduleLoader) SetLogger(logger *log.Logger) {
ml.logger = logger
}
Expand Down
8 changes: 4 additions & 4 deletions internal/terraform/parser/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ func TestParseModuleFiles(t *testing.T) {
"missing-brace.tf": {
{
Severity: hcl.DiagError,
Summary: "Argument or block definition required",
Detail: "An argument or block definition is required here.",
Summary: "Unclosed configuration block",
Detail: "There is no closing brace for this block before the end of the file. This may be caused by incorrect brace nesting elsewhere in this file.",
Subject: &hcl.Range{
Filename: "missing-brace.tf",
Start: hcl.Pos{Line: 10, Column: 1, Byte: 207},
End: hcl.Pos{Line: 10, Column: 1, Byte: 207},
Start: hcl.Pos{Line: 1, Column: 40, Byte: 39},
End: hcl.Pos{Line: 1, Column: 41, Byte: 40},
},
},
},
Expand Down

0 comments on commit 119fa04

Please sign in to comment.