Browse Source

fix: OnPeerUpdate should only process updates for matching FilerGroup

Critical bug: The OnPeerUpdate callback was incorrectly moved outside the
FilerGroup check when restoring observability instrumentation. This caused
clients to process peer updates for ALL filer groups, not just their own.

Problem:
  Before: mc.OnPeerUpdate only called for update.FilerGroup == mc.FilerGroup
  Bug:    mc.OnPeerUpdate called for ALL updates regardless of FilerGroup

Impact:
- Multi-tenant deployments with separate filer groups would see cross-group
  updates (e.g., group A clients processing group B updates)
- Could cause incorrect cluster membership tracking
- OnPeerUpdate handlers (like Filer's DLM ring updates) would receive
  irrelevant updates from other groups

Example scenario:
  Cluster has two filer groups: "production" and "staging"
  Production filer connects with FilerGroup="production"

  Incorrect behavior (bug):
    - Receives "staging" group updates
    - Incorrectly adds staging filers to production DLM ring
    - Cross-tenant data access issues

  Correct behavior (fixed):
    - Only receives "production" group updates
    - Only adds production filers to production DLM ring
    - Proper isolation between groups

Fix:
  Moved mc.OnPeerUpdate(update, time.Now()) back INSIDE the FilerGroup check
  where it belongs, matching the original implementation.

The logging and stats counter were already correctly scoped to matching
FilerGroup, so they remain inside the if block as intended.
pull/7518/head
chrislu 2 weeks ago
parent
commit
99ae38339d
  1. 2
      weed/wdclient/masterclient.go

2
weed/wdclient/masterclient.go

@ -238,9 +238,9 @@ func (mc *MasterClient) tryConnectToMaster(ctx context.Context, master pb.Server
glog.V(0).Infof("- %s@%s noticed %s.%s %s\n", mc.clientType, mc.clientHost, update.FilerGroup, update.NodeType, update.Address) glog.V(0).Infof("- %s@%s noticed %s.%s %s\n", mc.clientType, mc.clientHost, update.FilerGroup, update.NodeType, update.Address)
} }
stats.MasterClientConnectCounter.WithLabelValues(stats.OnPeerUpdate).Inc() stats.MasterClientConnectCounter.WithLabelValues(stats.OnPeerUpdate).Inc()
}
mc.OnPeerUpdate(update, time.Now()) mc.OnPeerUpdate(update, time.Now())
} }
}
mc.OnPeerUpdateLock.RUnlock() mc.OnPeerUpdateLock.RUnlock()
} }
if err := ctx.Err(); err != nil { if err := ctx.Err(); err != nil {

Loading…
Cancel
Save