Skip to content

Commit

Permalink
Revert goroutine probing
Browse files Browse the repository at this point in the history
  • Loading branch information
falfaroc committed Dec 24, 2024
1 parent 8edc17b commit 1bb5392
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 38 deletions.
49 changes: 13 additions & 36 deletions service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2616,7 +2616,7 @@ func (s *service) getZoneFromZoneLabelKey(ctx context.Context, zoneLabelKey stri
func (s *service) systemProbeAll(ctx context.Context) error {
// probe all arrays
Log.Infoln("Probing all associated arrays")
errMap := new(sync.Map)
errMap := make(map[string]error)
zoneName := ""
usingZones := s.opts.zoneLabelKey != "" && s.isNodeMode()

Expand All @@ -2629,9 +2629,6 @@ func (s *service) systemProbeAll(ctx context.Context) error {
Log.Infof("probing zoneLabel '%s', zone value: '%s'", s.opts.zoneLabelKey, zoneName)
}

var wg sync.WaitGroup
errChan := make(chan error, len(s.opts.arrays))

newCtx, cancel := createProbeContextWithDeadline(ctx)
defer cancel()

Expand All @@ -2641,52 +2638,32 @@ func (s *service) systemProbeAll(ctx context.Context) error {
// Driver node containers should not probe arrays that exist outside their assigned zone
// Driver controller container should probe all arrays
Log.Infof("array %s zone %s does not match %s, not pinging this array\n", array.SystemID, array.AvailabilityZone.Name, zoneName)
errChan <- fmt.Errorf("array %s zone %s does not match %s, not pinging this array", array.SystemID, array.AvailabilityZone.Name, zoneName)
errMap[array.SystemID] = fmt.Errorf("array %s zone %s does not match %s, not pinging this array", array.SystemID, array.AvailabilityZone.Name, zoneName)
continue
}

wg.Add(1)

go func(array *ArrayConnectionData) {
defer wg.Done()

err := s.systemProbe(newCtx, array)
systemID := array.SystemID
if err != nil {
errMap.Store(systemID, err)
Log.Errorf("array %s probe failed: %v", array.SystemID, err)
errChan <- err
} else {
Log.Infof("array %s probed successfully", systemID)
}
}(array)
}

go func() {
wg.Wait()
close(errChan)
}()

var errs []error
for err := range errChan {
errs = append(errs, err)
err := s.systemProbe(newCtx, array)
systemID := array.SystemID
if err != nil {
errMap[systemID] = err
Log.Errorf("array %s probe failed: %v", array.SystemID, err)
} else {
Log.Infof("array %s probed successfully", systemID)
}
}

Log.Printf("[SystemProbeAll] Number of failed probes: %d", len(errs))
Log.Printf("[SystemProbeAll] Number of failed probes: %d", len(errMap))

if len(errs) == len(s.opts.arrays) {
if len(errMap) == len(s.opts.arrays) {
return status.Error(codes.FailedPrecondition,
fmt.Sprintf("All arrays are not working. Could not proceed further: %v", errs))
fmt.Sprintf("All arrays are not working. Could not proceed further: %v", errMap))
}

return nil
}

// systemProbe will probe the given array
func (s *service) systemProbe(ctx context.Context, array *ArrayConnectionData) error {
s.probeMutex.Lock()
defer s.probeMutex.Unlock()

// Check that we have the details needed to login to the Gateway
if array.Endpoint == "" {
return status.Error(codes.FailedPrecondition,
Expand Down
2 changes: 0 additions & 2 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ type service struct {
// maps the first 24 bits of a volume ID to the volume's systemID
volumePrefixToSystems map[string][]string
connectedSystemNameToID map[string]string

probeMutex sync.Mutex
}

type Config struct {
Expand Down

0 comments on commit 1bb5392

Please sign in to comment.