forked from TrueCloudLab/frostfs-node
[#872] services/container: Ignore passed routes in load router
Higher level solution for original issue with lost announcements from single node container. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
f08636c518
commit
e41e74b5fc
2 changed files with 26 additions and 2 deletions
|
@ -228,6 +228,16 @@ func (*morphLoadWriter) Close() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type nopLoadWriter struct{}
|
||||||
|
|
||||||
|
func (nopLoadWriter) Put(containerSDK.UsedSpaceAnnouncement) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nopLoadWriter) Close() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type remoteLoadAnnounceProvider struct {
|
type remoteLoadAnnounceProvider struct {
|
||||||
key *ecdsa.PrivateKey
|
key *ecdsa.PrivateKey
|
||||||
|
|
||||||
|
@ -241,10 +251,15 @@ type remoteLoadAnnounceProvider struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadcontroller.WriterProvider, error) {
|
func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadcontroller.WriterProvider, error) {
|
||||||
if srv == nil || r.netmapKeys.IsLocalKey(srv.PublicKey()) {
|
if srv == nil {
|
||||||
return r.deadEndProvider, nil
|
return r.deadEndProvider, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.netmapKeys.IsLocalKey(srv.PublicKey()) {
|
||||||
|
// if local => return no-op writer
|
||||||
|
return loadcontroller.SimpleWriterProvider(new(nopLoadWriter)), nil
|
||||||
|
}
|
||||||
|
|
||||||
var info client.NodeInfo
|
var info client.NodeInfo
|
||||||
|
|
||||||
err := client.NodeInfoFromRawNetmapElement(&info, srv)
|
err := client.NodeInfoFromRawNetmapElement(&info, srv)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package placementrouter
|
package placementrouter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||||
|
@ -30,7 +31,15 @@ func (b *Builder) NextStage(a container.UsedSpaceAnnouncement, passed []loadrout
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
res = append(res, placement[i][0])
|
target := placement[i][0]
|
||||||
|
|
||||||
|
if len(passed) == 1 && bytes.Equal(passed[0].PublicKey(), target.PublicKey()) {
|
||||||
|
// add nil element so the announcement will be saved in local memory
|
||||||
|
res = append(res, nil)
|
||||||
|
} else {
|
||||||
|
// add element with remote node to send announcement to
|
||||||
|
res = append(res, target)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
|
|
Loading…
Reference in a new issue