mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
site replication edit: validate endpoint belongs to deployment (#16000)
This commit is contained in:
parent
7e73fc2870
commit
4f5d38a4b1
@ -3477,6 +3477,9 @@ func (c *SiteReplicationSys) EditPeerCluster(ctx context.Context, peer madmin.Pe
|
|||||||
)
|
)
|
||||||
|
|
||||||
for _, v := range sites.Sites {
|
for _, v := range sites.Sites {
|
||||||
|
if peer.Endpoint == v.Endpoint {
|
||||||
|
return madmin.ReplicateEditStatus{}, errSRInvalidRequest(fmt.Errorf("Endpoint %s entered for deployment id %s already configured in site replication", v.Endpoint, v.DeploymentID))
|
||||||
|
}
|
||||||
if peer.DeploymentID == v.DeploymentID {
|
if peer.DeploymentID == v.DeploymentID {
|
||||||
found = true
|
found = true
|
||||||
if peer.Endpoint == v.Endpoint {
|
if peer.Endpoint == v.Endpoint {
|
||||||
@ -3487,8 +3490,12 @@ func (c *SiteReplicationSys) EditPeerCluster(ctx context.Context, peer madmin.Pe
|
|||||||
return madmin.ReplicateEditStatus{}, errSRPeerResp(fmt.Errorf("unable to create admin client for %s: %w", v.Name, err))
|
return madmin.ReplicateEditStatus{}, errSRPeerResp(fmt.Errorf("unable to create admin client for %s: %w", v.Name, err))
|
||||||
}
|
}
|
||||||
// check if endpoint is reachable
|
// check if endpoint is reachable
|
||||||
if _, err = admClient.ServerInfo(ctx); err != nil {
|
info, err := admClient.ServerInfo(ctx)
|
||||||
return madmin.ReplicateEditStatus{}, errSRPeerResp(fmt.Errorf("Endpoint %s not reachable: %w", peer.Endpoint, err))
|
if err != nil {
|
||||||
|
return madmin.ReplicateEditStatus{}, errSRInvalidRequest(fmt.Errorf("Endpoint %s not reachable: %w", peer.Endpoint, err))
|
||||||
|
}
|
||||||
|
if info.DeploymentID != v.DeploymentID {
|
||||||
|
return madmin.ReplicateEditStatus{}, errSRInvalidRequest(fmt.Errorf("Endpoint %s does not belong to deployment expected: %s (found %s) ", v.Endpoint, v.DeploymentID, info.DeploymentID))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user