Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #131 from filecoin-saturn/feat/decouple-compliance…
Browse files Browse the repository at this point in the history
…-cids

Decouple sending compliance cids from sending mirrored traffic for main nodes
  • Loading branch information
aarshkshah1992 authored Aug 1, 2023
2 parents b14957f + 1c6b9eb commit c729b05
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,15 @@ func (p *pool) checkPool() {
go func(msg mirroredPoolRequest) {
defer func() { <-sem }()

// see if it is to a main-tier node - if so find appropriate test node to test against.
p.lk.RLock()
if p.th.NodeTier(msg.node) != tieredhashing.TierMain {
p.lk.RUnlock()
return
}
testNodes := p.th.GetNodes(tieredhashing.TierUnknown, msg.key, 1)
p.lk.RUnlock()
if len(testNodes) == 0 {
return
}
trialTimeout, cancel := context.WithTimeout(context.Background(), 30*time.Second)

node := testNodes[0]
err := p.fetchResourceAndUpdate(trialTimeout, node, msg.path, 0, p.mirrorValidator)

// Send compliance cid
rand := big.NewInt(1)
if p.config.ComplianceCidPeriod > 0 {
rand, _ = cryptoRand.Int(cryptoRand.Reader, big.NewInt(p.config.ComplianceCidPeriod))
Expand All @@ -258,6 +251,17 @@ func (p *pool) checkPool() {
complianceCidCallsTotalMetric.WithLabelValues("success").Add(1)
}

// see if it is to a main-tier node - if so find appropriate test node to test against.
// --- Mirroring
p.lk.RLock()
if p.th.NodeTier(msg.node) != tieredhashing.TierMain {
p.lk.RUnlock()
return
}
p.lk.RUnlock()
trialTimeout, cancel := context.WithTimeout(context.Background(), 30*time.Second)
err := p.fetchResourceAndUpdate(trialTimeout, node, msg.path, 0, p.mirrorValidator)

cancel()
if err != nil {
mirroredTrafficTotalMetric.WithLabelValues("error").Inc()
Expand Down

0 comments on commit c729b05

Please sign in to comment.