mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
improve error message for adding machine that already exists in the cluster
This commit is contained in:
@@ -110,11 +110,17 @@ func (c *Cluster) AddMachine(ctx context.Context, req *pb.AddMachineRequest) (*p
|
|||||||
}
|
}
|
||||||
if req.Network.ManagementIp != nil && req.Network.ManagementIp.Equal(m.Network.ManagementIp) {
|
if req.Network.ManagementIp != nil && req.Network.ManagementIp.Equal(m.Network.ManagementIp) {
|
||||||
manageIP, _ := req.Network.ManagementIp.ToAddr()
|
manageIP, _ := req.Network.ManagementIp.ToAddr()
|
||||||
return nil, status.Errorf(codes.AlreadyExists, "machine with management IP %q already exists", manageIP)
|
return nil, status.Errorf(
|
||||||
|
codes.AlreadyExists, "machine with management IP %q already exists under the name %q",
|
||||||
|
manageIP, m.Name,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if bytes.Equal(m.Network.PublicKey, req.Network.PublicKey) {
|
if bytes.Equal(m.Network.PublicKey, req.Network.PublicKey) {
|
||||||
publicKey := secret.Secret(m.Network.PublicKey)
|
publicKey := secret.Secret(m.Network.PublicKey)
|
||||||
return nil, status.Errorf(codes.AlreadyExists, "machine with public key %q already exists", publicKey)
|
return nil, status.Errorf(
|
||||||
|
codes.AlreadyExists, "machine with public key %q already exists under the name %q",
|
||||||
|
publicKey, m.Name,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
allocatedSubnets[i], _ = m.Network.Subnet.ToPrefix()
|
allocatedSubnets[i], _ = m.Network.Subnet.ToPrefix()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user