Compare commits

...

3 commits

Author SHA1 Message Date
Anton Tayanovskyy af808421c1 Apply go mod tidy after local pkgs are linked 2021-08-11 14:33:27 -04:00
Anton Tayanovskyy 4957bea8c9 Apply go mod tidy 2021-08-10 20:42:59 -04:00
Anton Tayanovskyy 6101da4cbe Fix corruption of workspace files under heavy contention 2021-08-10 20:36:08 -04:00
8 changed files with 80 additions and 341 deletions

View file

@ -511,6 +511,8 @@ github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7P
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mxschmitt/golang-combinations v1.0.0 h1:NFoO7CSP8MUcFlHpe1YdewKwMa15dgDbaqkVLC5DUPI=
github.com/mxschmitt/golang-combinations v1.0.0/go.mod h1:RbMhWvfCelHR6WROvT2bVfxJvZHoEvBj71SKe+H0MYU=
github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A=
github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM=
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d h1:AREM5mwr4u1ORQBMvzfzBgpsctsbQikCVpvC+tX285E=
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=

View file

@ -1933,12 +1933,6 @@ func (pt *ProgramTester) prepareGoProject(projinfo *engine.Projinfo) error {
}
}
// initial tidy to resolve dependencies
err = pt.runCommand("go-mod-tidy", []string{goBin, "mod", "tidy"}, cwd)
if err != nil {
return err
}
// link local dependencies
for _, pkg := range pt.opts.Dependencies {
@ -1950,6 +1944,13 @@ func (pt *ProgramTester) prepareGoProject(projinfo *engine.Projinfo) error {
return err
}
}
// initial tidy to resolve dependencies
err = pt.runCommand("go-mod-tidy", []string{goBin, "mod", "tidy"}, cwd)
if err != nil {
return err
}
// resolve dependencies
err = pt.runCommand("go-mod-download", []string{goBin, "mod", "download"}, cwd)
if err != nil {

View file

@ -22,6 +22,7 @@ require (
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-runewidth v0.0.8 // indirect
github.com/mitchellh/go-ps v1.0.0
github.com/natefinch/atomic v1.0.1
github.com/nxadm/tail v1.4.8
github.com/opentracing/basictracer-go v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.1.0

View file

@ -139,6 +139,8 @@ github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A=
github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=

View file

@ -1,4 +1,4 @@
// Copyright 2016-2018, Pulumi Corporation.
// Copyright 2016-2021, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -15,6 +15,7 @@
package workspace
import (
"bytes"
// nolint: gosec
"crypto/sha1"
"encoding/hex"
@ -25,6 +26,7 @@ import (
"strings"
"sync"
"github.com/natefinch/atomic"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
@ -140,7 +142,7 @@ func (pw *projectWorkspace) Save() error {
return err
}
return ioutil.WriteFile(settingsFile, b, 0600)
return atomic.WriteFile(settingsFile, bytes.NewReader(b))
}
func (pw *projectWorkspace) readSettings() error {

View file

@ -0,0 +1,61 @@
// Copyright 2016-2021, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package workspace
import (
"fmt"
"strings"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestWorkspaceReadWriteUnderContention(t *testing.T) {
n := 100
wg := &sync.WaitGroup{}
wg.Add(n)
var error error
for j := 0; j < n; j++ {
go func(i int) {
defer wg.Done()
time.Sleep(1 * time.Millisecond)
w, err := NewFrom("../../auto/test/testproj")
if err != nil {
error = err
return
}
se := w.Settings()
if se != nil {
se.Stack = strings.Repeat(fmt.Sprintf("abra-cadabra-i-%d", i), 1024*16)
err := w.Save()
if err != nil {
error = err
return
}
}
}(j)
}
wg.Wait()
assert.NoError(t, error)
}

View file

@ -12,11 +12,9 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/golang/protobuf v1.5.2
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/pkg/errors v0.9.1
github.com/pulumi/pulumi/pkg/v3 v3.3.0
github.com/pulumi/pulumi/sdk/v3 v3.3.1
github.com/stretchr/testify v1.7.0
go.opencensus.io v0.23.0 // indirect
google.golang.org/grpc v1.37.0
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 // indirect
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
)

File diff suppressed because it is too large Load diff