forked from TrueCloudLab/frostfs-node
[#607] services/netmap: Support backward compatibility
Make Netmap service to return single network address on `LocalNodeInfo` RPC in order to older clients. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
81ddaeca16
commit
f8ee6b1164
1 changed files with 19 additions and 1 deletions
|
@ -45,12 +45,30 @@ func NewExecutionService(s NodeState, v *pkg.Version, netInfo NetworkInfo) Serve
|
||||||
|
|
||||||
func (s *executorSvc) LocalNodeInfo(
|
func (s *executorSvc) LocalNodeInfo(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
_ *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) {
|
req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) {
|
||||||
|
ver := pkg.NewVersionFromV2(req.GetMetaHeader().GetVersion())
|
||||||
|
if err := pkg.IsSupportedVersion(ver); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
ni, err := s.state.LocalNodeInfo()
|
ni, err := s.state.LocalNodeInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if addrNum := ni.NumberOfAddresses(); addrNum > 0 && ver.Minor() <= 7 {
|
||||||
|
ni2 := new(netmap.NodeInfo)
|
||||||
|
ni2.SetPublicKey(ni.GetPublicKey())
|
||||||
|
ni2.SetState(ni.GetState())
|
||||||
|
ni2.SetAttributes(ni.GetAttributes())
|
||||||
|
ni.IterateAddresses(func(s string) bool {
|
||||||
|
ni2.SetAddresses(s)
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
ni = ni2
|
||||||
|
}
|
||||||
|
|
||||||
body := new(netmap.LocalNodeInfoResponseBody)
|
body := new(netmap.LocalNodeInfoResponseBody)
|
||||||
body.SetVersion(s.version.ToV2())
|
body.SetVersion(s.version.ToV2())
|
||||||
body.SetNodeInfo(ni)
|
body.SetNodeInfo(ni)
|
||||||
|
|
Loading…
Reference in a new issue