Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/provider/aws/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package aws

import (
"context"
"errors"
"fmt"
"sync"
"time"
Expand Down Expand Up @@ -419,6 +420,10 @@ func (p *Provider) createInstances(
instancesChan := make(chan InstanceInfo, count)
errorsChan := make(chan error, count)

// Copy tags to avoid data race if p.Tags is modified during creation
tagsCopy := make([]types.Tag, len(p.Tags))
copy(tagsCopy, p.Tags)

for i := 0; i < count; i++ {
wg.Add(1)
go func(index int) {
Expand All @@ -427,7 +432,7 @@ func (p *Provider) createInstances(
instanceName := fmt.Sprintf("%s-%s-%d", p.ObjectMeta.Name, role, index)
// Filter out the Name tag from p.Tags to avoid duplicates
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says it filters out the Name tag from p.Tags, but the loop now iterates over tagsCopy. Update the comment to match the code so it stays accurate for future maintenance.

Suggested change
// Filter out the Name tag from p.Tags to avoid duplicates
// Filter out the Name tag from tagsCopy to avoid duplicates

Copilot uses AI. Check for mistakes.
var tags []types.Tag
for _, tag := range p.Tags {
for _, tag := range tagsCopy {
if aws.ToString(tag.Key) != "Name" {
tags = append(tags, tag)
}
Expand Down Expand Up @@ -550,7 +555,7 @@ func (p *Provider) createInstances(
errs = append(errs, err)
}
if len(errs) > 0 {
return nil, fmt.Errorf("errors creating instances: %v", errs)
return nil, fmt.Errorf("errors creating instances: %w", errors.Join(errs...))
}

// Collect instances
Expand Down
Loading