Skip to content

Commit

Permalink
deploy: fix concurrent map write on deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Sep 16, 2024
1 parent 4828e8b commit e469008
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/server/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/rpc"
"sync"

"github.com/sst/ion/pkg/project"
"github.com/sst/ion/pkg/project/provider"
Expand All @@ -12,14 +13,17 @@ import (
type aws struct {
project *project.Project
bootstrapCache map[string]*provider.AwsBootstrapData
lock sync.RWMutex
}

type BootstrapInput struct {
Region string `json:"region"`
}

func (a *aws) Bootstrap(input *BootstrapInput, output *provider.AwsBootstrapData) error {
a.lock.RLock()
cached, ok := a.bootstrapCache[input.Region]
a.lock.RUnlock()
if ok {
*output = *cached
return nil
Expand All @@ -35,7 +39,9 @@ func (a *aws) Bootstrap(input *BootstrapInput, output *provider.AwsBootstrapData
if err != nil {
return err
}
a.lock.Lock()
a.bootstrapCache[input.Region] = data
a.lock.Unlock()
*output = *data
return nil
}
Expand Down

0 comments on commit e469008

Please sign in to comment.