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:"
)
// ---------------------------------------------------------------------------
// reasoners
// ---------------------------------------------------------------------------
func NewReason(
tenant, resource string,
service path.ServiceType,
@ -47,10 +51,11 @@ type reason struct {
// 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
// struct and relies on helper functions to get the information it needs.
tenant string
resource string
service path.ServiceType
category path.CategoryType
tenant string
serviceResources []path.ServiceResource
resource string
service path.ServiceType
category path.CategoryType
}
func (r reason) Tenant() string {
@ -94,6 +99,10 @@ func reasonKey(r identity.Reasoner) string {
return r.ProtectedResource() + r.Service().String() + r.Category().String()
}
// ---------------------------------------------------------------------------
// entries
// ---------------------------------------------------------------------------
type BackupEntry struct {
*backup.Backup
Reasons []identity.Reasoner
@ -108,7 +117,7 @@ type ManifestEntry struct {
// 1. backup user1 email,contacts -> B1
// 2. backup user1 contacts -> B2 (uses B1 as base)
// 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) {
@ -284,7 +293,7 @@ func (b *baseFinder) findBasesInSet(
}
assistSnap := ManifestEntry{
Manifest: man,
Reasons: []identity.Reasoner{reason},
Reasons: []identity.SubtreeReasoner{reason},
}
assistBase = &backupBase{
@ -310,7 +319,7 @@ func (b *baseFinder) findBasesInSet(
mergeSnap := ManifestEntry{
Manifest: man,
Reasons: []identity.Reasoner{reason},
Reasons: []identity.SubtreeReasoner{reason},
}
mergeModel := BackupEntry{

View File

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

View File

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

View File

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