setting aside

This commit is contained in:
ryanfkeepers 2023-08-16 11:06:22 -06:00
parent f5400f9e31
commit 7b926524b1
4 changed files with 34 additions and 17 deletions

View File

@ -30,6 +30,10 @@ const (
userTagPrefix = "tag:" userTagPrefix = "tag:"
) )
// ---------------------------------------------------------------------------
// reasoners
// ---------------------------------------------------------------------------
func NewReason( func NewReason(
tenant, resource string, tenant, resource string,
service path.ServiceType, service path.ServiceType,
@ -47,10 +51,11 @@ type reason struct {
// tenant appears here so that when this is moved to an inject package nothing // tenant appears here so that when this is moved to an inject package nothing
// needs changed. However, kopia itself is blind to the fields in the reason // needs changed. However, kopia itself is blind to the fields in the reason
// struct and relies on helper functions to get the information it needs. // struct and relies on helper functions to get the information it needs.
tenant string tenant string
resource string serviceResources []path.ServiceResource
service path.ServiceType resource string
category path.CategoryType service path.ServiceType
category path.CategoryType
} }
func (r reason) Tenant() string { func (r reason) Tenant() string {
@ -94,6 +99,10 @@ func reasonKey(r identity.Reasoner) string {
return r.ProtectedResource() + r.Service().String() + r.Category().String() return r.ProtectedResource() + r.Service().String() + r.Category().String()
} }
// ---------------------------------------------------------------------------
// entries
// ---------------------------------------------------------------------------
type BackupEntry struct { type BackupEntry struct {
*backup.Backup *backup.Backup
Reasons []identity.Reasoner Reasons []identity.Reasoner
@ -108,7 +117,7 @@ type ManifestEntry struct {
// 1. backup user1 email,contacts -> B1 // 1. backup user1 email,contacts -> B1
// 2. backup user1 contacts -> B2 (uses B1 as base) // 2. backup user1 contacts -> B2 (uses B1 as base)
// 3. backup user1 email,contacts,events (uses B1 for email, B2 for contacts) // 3. backup user1 email,contacts,events (uses B1 for email, B2 for contacts)
Reasons []identity.Reasoner Reasons []identity.SubtreeReasoner
} }
func (me ManifestEntry) GetTag(key string) (string, bool) { func (me ManifestEntry) GetTag(key string) (string, bool) {
@ -284,7 +293,7 @@ func (b *baseFinder) findBasesInSet(
} }
assistSnap := ManifestEntry{ assistSnap := ManifestEntry{
Manifest: man, Manifest: man,
Reasons: []identity.Reasoner{reason}, Reasons: []identity.SubtreeReasoner{reason},
} }
assistBase = &backupBase{ assistBase = &backupBase{
@ -310,7 +319,7 @@ func (b *baseFinder) findBasesInSet(
mergeSnap := ManifestEntry{ mergeSnap := ManifestEntry{
Manifest: man, Manifest: man,
Reasons: []identity.Reasoner{reason}, Reasons: []identity.SubtreeReasoner{reason},
} }
mergeModel := BackupEntry{ mergeModel := BackupEntry{

View File

@ -1070,20 +1070,20 @@ const (
func inflateBaseTree( func inflateBaseTree(
ctx context.Context, ctx context.Context,
loader snapshotLoader, loader snapshotLoader,
snap ManifestEntry, snapshot ManifestEntry,
updatedPaths map[string]path.Path, updatedPaths map[string]path.Path,
roots map[string]*treeMap, roots map[string]*treeMap,
) error { ) error {
// Only complete snapshots should be used to source base information. // Only complete snapshots should be used to source base information.
// Snapshots for checkpoints will rely on kopia-assisted dedupe to efficiently // Snapshots for checkpoints will rely on kopia-assisted dedupe to efficiently
// handle items that were completely uploaded before Corso crashed. // handle items that were completely uploaded before Corso crashed.
if len(snap.IncompleteReason) > 0 { if len(snapshot.IncompleteReason) > 0 {
return nil return nil
} }
ctx = clues.Add(ctx, "snapshot_base_id", snap.ID) ctx = clues.Add(ctx, "snapshot_base_id", snapshot.ID)
root, err := loader.SnapshotRoot(snap.Manifest) root, err := loader.SnapshotRoot(snapshot.Manifest)
if err != nil { if err != nil {
return clues.Wrap(err, "getting snapshot root directory").WithClues(ctx) return clues.Wrap(err, "getting snapshot root directory").WithClues(ctx)
} }
@ -1094,12 +1094,12 @@ func inflateBaseTree(
} }
// Some logging to help track things. // Some logging to help track things.
logBaseInfo(ctx, snap) logBaseInfo(ctx, snapshot)
// For each subtree corresponding to the tuple // For each subtree corresponding to the tuple
// (resource owner, service, category) merge the directories in the base with // (resource owner, service, category) merge the directories in the base with
// what has been reported in the collections we got. // what has been reported in the collections we got.
for _, r := range snap.Reasons { for _, r := range snapshot.Reasons {
ictx := clues.Add( ictx := clues.Add(
ctx, ctx,
"subtree_service", r.Service().String(), "subtree_service", r.Service().String(),

View File

@ -351,7 +351,7 @@ func (op *BackupOperation) do(
return nil, clues.Stack(err) return nil, clues.Stack(err)
} }
mans, mdColls, canUseMetadata, err := produceManifestsAndMetadata( bases, mdColls, canUseMetadata, err := produceManifestsAndMetadata(
ctx, ctx,
kbf, kbf,
op.kopia, op.kopia,
@ -366,7 +366,7 @@ func (op *BackupOperation) do(
ctx = clues.Add(ctx, "can_use_metadata", canUseMetadata) ctx = clues.Add(ctx, "can_use_metadata", canUseMetadata)
if canUseMetadata { if canUseMetadata {
lastBackupVersion = mans.MinBackupVersion() lastBackupVersion = bases.MinBackupVersion()
} }
// TODO(ashmrtn): This should probably just return a collection that deletes // TODO(ashmrtn): This should probably just return a collection that deletes
@ -396,7 +396,7 @@ func (op *BackupOperation) do(
op.kopia, op.kopia,
op.account.ID(), op.account.ID(),
reasons, reasons,
mans, bases,
cs, cs,
ssmb, ssmb,
backupID, backupID,
@ -413,7 +413,7 @@ func (op *BackupOperation) do(
err = mergeDetails( err = mergeDetails(
ctx, ctx,
detailsStore, detailsStore,
mans, bases,
toMerge, toMerge,
deets, deets,
writeStats, writeStats,

View File

@ -2,6 +2,11 @@ package identity
import "github.com/alcionai/corso/src/pkg/path" import "github.com/alcionai/corso/src/pkg/path"
type SubtreeReasoner interface {
Reasoner
SubtreePather
}
// Reasoner describes the parts of the backup that make up its // Reasoner describes the parts of the backup that make up its
// data identity: the tenant, protected resources, services, and // data identity: the tenant, protected resources, services, and
// categories which are held within the backup. // categories which are held within the backup.
@ -21,6 +26,9 @@ type Reasoner interface {
// should only provide the first service; not a subservice. // should only provide the first service; not a subservice.
Service() path.ServiceType Service() path.ServiceType
Category() path.CategoryType Category() path.CategoryType
}
type SubtreePather interface {
// SubtreePath returns the path prefix for data in existing backups that have // SubtreePath returns the path prefix for data in existing backups that have
// parameters (tenant, protected resourced, etc) that match this Reasoner. // parameters (tenant, protected resourced, etc) that match this Reasoner.
SubtreePath() (path.Path, error) SubtreePath() (path.Path, error)