parent
223f6501eb
commit
df8f01dba7
|
@ -2,7 +2,9 @@ CHANGELOG
|
|||
=========
|
||||
|
||||
## HEAD (Unreleased)
|
||||
_(none)_
|
||||
|
||||
- Fix errors when running `pulumi` in Windows-based CI environments.
|
||||
[#5879](https://github.com/pulumi/pulumi/issues/5879)
|
||||
|
||||
## 2.15.2 (2020-12-07)
|
||||
|
||||
|
@ -11,7 +13,7 @@ _(none)_
|
|||
|
||||
## 2.15.1 (2020-12-04)
|
||||
|
||||
- [sdk/python] Address potential issues when running multiple `pulumi` processes concurrently.
|
||||
- Address potential issues when running multiple `pulumi` processes concurrently.
|
||||
[#5857](https://github.com/pulumi/pulumi/pull/5857)
|
||||
|
||||
- Automatically install missing Python dependencies.
|
||||
|
|
|
@ -18,13 +18,11 @@ import (
|
|||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v2/go/common/util/contract"
|
||||
"github.com/pulumi/pulumi/sdk/v2/go/common/util/logging"
|
||||
)
|
||||
|
||||
|
@ -215,26 +213,5 @@ func StoreCredentials(creds Credentials) error {
|
|||
if err != nil {
|
||||
return errors.Wrapf(err, "marshalling credentials object")
|
||||
}
|
||||
|
||||
// Use a temporary file and atomic os.Rename to ensure the file contents are
|
||||
// updated atomically to ensure concurrent `pulumi` CLI operations are safe.
|
||||
tempCredsFile, err := ioutil.TempFile(path.Dir(credsFile), "credentials-*.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tempCredsFile.Write(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = tempCredsFile.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Rename(tempCredsFile.Name(), credsFile)
|
||||
if err != nil {
|
||||
contract.IgnoreError(os.Remove(tempCredsFile.Name()))
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return ioutil.WriteFile(credsFile, raw, 0600)
|
||||
}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
package workspace
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestConcurrentCredentialsWrites(t *testing.T) {
|
||||
creds, err := GetStoredCredentials()
|
||||
assert.NoError(t, err)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
for i := 0; i < 1000; i++ {
|
||||
wg.Add(2)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
err := StoreCredentials(creds)
|
||||
assert.NoError(t, err)
|
||||
}()
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
_, err := GetStoredCredentials()
|
||||
assert.NoError(t, err)
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
Loading…
Reference in a new issue