satellite/overlay: update country code on every node check-in
We have a specific issue that a user uploaded a file to a bucket geo-fenced to EU and one of the pieces appeared to be on a node in the US. The country code of this node is set to SE (Sweden) in the satellite DB. It turns out that some time ago MaxMind changed the country code of this node's IP from Sweden to US, but this change hasn't been reflected in the satellite's database. So far the satellite updates the country code of a node only if its IP changes. It was assumed that if the IP does not change, its country code shouldn't change too. This turned to be a wrong assumption. With this change, the satellite will look up the MaxMindDB on every check-in to see if the country code of the node's IP has changed. Change-Id: Icdf659b09be9fc6ad14601902032b35ba5ea78c4
This commit is contained in:
parent
58f465c8d8
commit
98b82486bd
@ -16,6 +16,7 @@ import (
|
|||||||
"storj.io/common/testcontext"
|
"storj.io/common/testcontext"
|
||||||
"storj.io/storj/private/testplanet"
|
"storj.io/storj/private/testplanet"
|
||||||
"storj.io/storj/satellite"
|
"storj.io/storj/satellite"
|
||||||
|
"storj.io/storj/satellite/geoip"
|
||||||
"storj.io/storj/storagenode"
|
"storj.io/storj/storagenode"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,6 +55,24 @@ func TestGeoIPMock(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, countryCodes[i], dossier.CountryCode)
|
assert.Equal(t, countryCodes[i], dossier.CountryCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// change country in the mock GeoIP service from US to CA
|
||||||
|
planet.Satellites[0].Overlay.Service.GeoIP = geoip.NewMockIPToCountry([]string{"CA", "GB"})
|
||||||
|
|
||||||
|
// wait for storage nodes checked in again with satellite
|
||||||
|
for _, node := range planet.StorageNodes {
|
||||||
|
node.Contact.Chore.TriggerWait(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// adjust expected country codes for node 1
|
||||||
|
countryCodes[1] = location.Canada
|
||||||
|
|
||||||
|
// check the country code for each storage nodes
|
||||||
|
for i, node := range planet.StorageNodes {
|
||||||
|
dossier, err := planet.Satellites[0].API.Overlay.DB.Get(ctx, node.ID())
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, countryCodes[i], dossier.CountryCode)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -692,17 +692,13 @@ func (service *Service) UpdateCheckIn(ctx context.Context, node NodeCheckInInfo,
|
|||||||
spaceChanged := (node.Capacity == nil && oldInfo.Capacity.FreeDisk != 0) ||
|
spaceChanged := (node.Capacity == nil && oldInfo.Capacity.FreeDisk != 0) ||
|
||||||
(node.Capacity != nil && node.Capacity.FreeDisk != oldInfo.Capacity.FreeDisk)
|
(node.Capacity != nil && node.Capacity.FreeDisk != oldInfo.Capacity.FreeDisk)
|
||||||
|
|
||||||
if oldInfo.CountryCode == location.CountryCode(0) || oldInfo.LastIPPort != node.LastIPPort {
|
node.CountryCode, err = service.GeoIP.LookupISOCountryCode(node.LastIPPort)
|
||||||
node.CountryCode, err = service.GeoIP.LookupISOCountryCode(node.LastIPPort)
|
if err != nil {
|
||||||
if err != nil {
|
failureMeter.Mark(1)
|
||||||
failureMeter.Mark(1)
|
service.log.Debug("failed to resolve country code for node",
|
||||||
service.log.Debug("failed to resolve country code for node",
|
zap.String("node address", node.Address.Address),
|
||||||
zap.String("node address", node.Address.Address),
|
zap.Stringer("Node ID", node.NodeID),
|
||||||
zap.Stringer("Node ID", node.NodeID),
|
zap.Error(err))
|
||||||
zap.Error(err))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
node.CountryCode = oldInfo.CountryCode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if service.config.SendNodeEmails && service.config.Node.MinimumVersion != "" {
|
if service.config.SendNodeEmails && service.config.Node.MinimumVersion != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user