Skip to content

Commit 4fc3ee9

Browse files
cml: resolve deadlock when cloning amis (#404) (#405)
* Each goroutine must call wg.Done() otherwise wg.Wait() forever
1 parent af2082e commit 4fc3ee9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cml/clone-amis.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ func main() {
6969
ami := imagesRes.Images[0]
7070

7171
var wg sync.WaitGroup
72+
wg.Add(len(regions))
7273
for _, destination := range regions {
73-
wg.Add(1)
7474
go func(destinationRegion string) {
75+
defer wg.Done()
7576
fmt.Printf("Cloning image to region %s...\n", destinationRegion)
7677
if err := cloneImage(region, destinationRegion, *ami.ImageId, *ami.Name, *ami.Description); err != nil {
7778
fmt.Printf("Error cloning image to region %s\n", destinationRegion)

0 commit comments

Comments
 (0)