sr: add validation to disallow updating bandwidth limit on self (#19062)

This commit is contained in:
Poorna 2024-02-15 13:03:40 -08:00 committed by GitHub
parent 7405760f44
commit f9dbf41e27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3980,6 +3980,9 @@ func (c *SiteReplicationSys) EditPeerCluster(ctx context.Context, peer madmin.Pe
}
if peer.DefaultBandwidth.IsSet {
if peer.DeploymentID == globalDeploymentID() {
return madmin.ReplicateEditStatus{}, errSRInvalidRequest(fmt.Errorf("invalid deployment id specified: expecting a peer deployment-id to be specified for restricting bandwidth from %s, found self %s", peer.Name, globalDeploymentID()))
}
pi.DefaultBandwidth = peer.DefaultBandwidth
pi.DefaultBandwidth.UpdatedAt = UTCNow()
successMsg = fmt.Sprintf("%s\n- default bandwidth %v for peer %s", successMsg, peer.DefaultBandwidth.Limit, peer.Name)