tka: keep the CompactionDefaults alongside the other limits
Updates #cleanup Change-Id: Ib5e481d5a9c7ec7ac3e6b3913909ab1bf21d7a4d Signed-off-by: Alex Chan <alexc@tailscale.com>
This commit is contained in:
@@ -45,11 +45,6 @@ import (
|
|||||||
var (
|
var (
|
||||||
errMissingNetmap = errors.New("missing netmap: verify that you are logged in")
|
errMissingNetmap = errors.New("missing netmap: verify that you are logged in")
|
||||||
errNetworkLockNotActive = errors.New("tailnet-lock is not active")
|
errNetworkLockNotActive = errors.New("tailnet-lock is not active")
|
||||||
|
|
||||||
tkaCompactionDefaults = tka.CompactionOptions{
|
|
||||||
MinChain: 24, // Keep at minimum 24 AUMs since head.
|
|
||||||
MinAge: 14 * 24 * time.Hour, // Keep 2 weeks of AUMs.
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type tkaState struct {
|
type tkaState struct {
|
||||||
@@ -92,7 +87,7 @@ func (b *LocalBackend) initTKALocked() error {
|
|||||||
return fmt.Errorf("initializing tka: %v", err)
|
return fmt.Errorf("initializing tka: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := authority.Compact(storage, tkaCompactionDefaults); err != nil {
|
if err := authority.Compact(storage, tka.CompactionDefaults); err != nil {
|
||||||
b.logf("tka compaction failed: %v", err)
|
b.logf("tka compaction failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +355,7 @@ func (b *LocalBackend) tkaSyncIfNeeded(nm *netmap.NetworkMap, prefs ipn.PrefsVie
|
|||||||
//
|
//
|
||||||
// We run this on every sync so that clients compact consistently. In many
|
// We run this on every sync so that clients compact consistently. In many
|
||||||
// cases this will be a no-op.
|
// cases this will be a no-op.
|
||||||
if err := b.tka.authority.Compact(b.tka.storage, tkaCompactionDefaults); err != nil {
|
if err := b.tka.authority.Compact(b.tka.storage, tka.CompactionDefaults); err != nil {
|
||||||
return fmt.Errorf("tka compact: %w", err)
|
return fmt.Errorf("tka compact: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package tka
|
|||||||
import (
|
import (
|
||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
"errors"
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
"tailscale.com/types/key"
|
"tailscale.com/types/key"
|
||||||
"tailscale.com/types/logger"
|
"tailscale.com/types/logger"
|
||||||
@@ -158,3 +159,8 @@ func SignByCredential(privKey []byte, wrapped *NodeKeySignature, nodeKey key.Nod
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s NodeKeySignature) String() string { return "" }
|
func (s NodeKeySignature) String() string { return "" }
|
||||||
|
|
||||||
|
type CompactionOptions struct {
|
||||||
|
MinChain int
|
||||||
|
MinAge time.Duration
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
package tka
|
package tka
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Upper bound on checkpoint elements, chosen arbitrarily. Intended
|
// Upper bound on checkpoint elements, chosen arbitrarily. Intended
|
||||||
// to cap the size of large AUMs.
|
// to cap the size of large AUMs.
|
||||||
@@ -22,3 +26,10 @@ const (
|
|||||||
// Limit on scanning AUM trees, chosen arbitrarily.
|
// Limit on scanning AUM trees, chosen arbitrarily.
|
||||||
maxScanIterations = 2000
|
maxScanIterations = 2000
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
CompactionDefaults = CompactionOptions{
|
||||||
|
MinChain: 24, // Keep at minimum 24 AUMs since head.
|
||||||
|
MinAge: 14 * 24 * time.Hour, // Keep 2 weeks of AUMs.
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user