Add partial backup tag

This commit is contained in:
Abhishek Pandey 2023-07-21 00:54:04 -07:00
parent 5aedd7e3ed
commit 58f5556f1a
3 changed files with 11 additions and 5 deletions

View File

@ -32,7 +32,8 @@ const (
// common tags for filtering // common tags for filtering
const ( const (
ServiceTag = "service" ServiceTag = "service"
PartialBackupTag = "partialBackup"
) )
// Valid returns true if the ModelType value fits within the iota range. // Valid returns true if the ModelType value fits within the iota range.

View File

@ -236,7 +236,6 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
// Persistence // Persistence
// ----- // -----
// TODO(pandeyabs): Move createBackupModel before these
err = op.persistResults(startTime, &opStats) err = op.persistResults(startTime, &opStats)
if err != nil && !isAtleastPartialBackup { if err != nil && !isAtleastPartialBackup {
op.Errors.Fail(clues.Wrap(err, "persisting backup results")) op.Errors.Fail(clues.Wrap(err, "persisting backup results"))
@ -259,13 +258,15 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
} }
} }
// TODO(pandeyabs): Pass a flag to mark the backup as partial
err = op.createBackupModels( err = op.createBackupModels(
ctx, ctx,
sstore, sstore,
opStats.k.SnapshotID, opStats.k.SnapshotID,
op.Results.BackupID, op.Results.BackupID,
op.BackupVersion, op.BackupVersion,
deets.Details()) deets.Details(),
isAtleastPartialBackup)
if err != nil { if err != nil {
op.Errors.Fail(clues.Wrap(err, "persisting backup")) op.Errors.Fail(clues.Wrap(err, "persisting backup"))
return op.Errors.Failure() return op.Errors.Failure()
@ -856,6 +857,7 @@ func (op *BackupOperation) createBackupModels(
backupID model.StableID, backupID model.StableID,
backupVersion int, backupVersion int,
deets *details.Details, deets *details.Details,
isPartialBackup bool,
) error { ) error {
ctx = clues.Add(ctx, "snapshot_id", snapID, "backup_id", backupID) ctx = clues.Add(ctx, "snapshot_id", snapID, "backup_id", backupID)
// generate a new fault bus so that we can maintain clean // generate a new fault bus so that we can maintain clean
@ -896,7 +898,8 @@ func (op *BackupOperation) createBackupModels(
op.ResourceOwner.Name(), op.ResourceOwner.Name(),
op.Results.ReadWrites, op.Results.ReadWrites,
op.Results.StartAndEndTime, op.Results.StartAndEndTime,
op.Errors.Errors()) op.Errors.Errors(),
isPartialBackup)
logger.Ctx(ctx).Info("creating new backup") logger.Ctx(ctx).Info("creating new backup")

View File

@ -79,6 +79,7 @@ func New(
rw stats.ReadWrites, rw stats.ReadWrites,
se stats.StartAndEndTime, se stats.StartAndEndTime,
fe *fault.Errors, fe *fault.Errors,
isPartialBackup bool,
) *Backup { ) *Backup {
if fe == nil { if fe == nil {
fe = &fault.Errors{} fe = &fault.Errors{}
@ -115,7 +116,8 @@ func New(
BaseModel: model.BaseModel{ BaseModel: model.BaseModel{
ID: id, ID: id,
Tags: map[string]string{ Tags: map[string]string{
model.ServiceTag: selector.PathService().String(), model.ServiceTag: selector.PathService().String(),
model.PartialBackupTag: strconv.FormatBool(isPartialBackup),
}, },
}, },