diff --git a/.gitignore b/.gitignore index 59402d8ae..2adb3be24 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ bin/ .DS_Store go.work -go.work.sum \ No newline at end of file +go.work.sum +.tool-versions \ No newline at end of file diff --git a/pkg/nsx/services/subnet/subnet.go b/pkg/nsx/services/subnet/subnet.go index f53c91ab0..230818c86 100644 --- a/pkg/nsx/services/subnet/subnet.go +++ b/pkg/nsx/services/subnet/subnet.go @@ -73,12 +73,17 @@ func InitializeSubnetService(service common.Service) (*SubnetService, error) { }() select { case <-wgDone: - break + close(fatalErrors) // Clean up fatalErrors channel + return subnetService, nil case err := <-fatalErrors: + // Wait for any pending operations to complete + go func() { + wg.Wait() // Ensure all goroutines complete + close(wgDone) + }() close(fatalErrors) return subnetService, err } - return subnetService, nil } func (service *SubnetService) CreateOrUpdateSubnet(obj client.Object, vpcInfo common.VPCResourceInfo, tags []model.Tag) (string, error) {