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
const (
ServiceTag = "service"
ServiceTag = "service"
PartialBackupTag = "partialBackup"
)
// 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
// -----
// TODO(pandeyabs): Move createBackupModel before these
err = op.persistResults(startTime, &opStats)
if err != nil && !isAtleastPartialBackup {
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(
ctx,
sstore,
opStats.k.SnapshotID,
op.Results.BackupID,
op.BackupVersion,
deets.Details())
deets.Details(),
isAtleastPartialBackup)
if err != nil {
op.Errors.Fail(clues.Wrap(err, "persisting backup"))
return op.Errors.Failure()
@ -856,6 +857,7 @@ func (op *BackupOperation) createBackupModels(
backupID model.StableID,
backupVersion int,
deets *details.Details,
isPartialBackup bool,
) error {
ctx = clues.Add(ctx, "snapshot_id", snapID, "backup_id", backupID)
// generate a new fault bus so that we can maintain clean
@ -896,7 +898,8 @@ func (op *BackupOperation) createBackupModels(
op.ResourceOwner.Name(),
op.Results.ReadWrites,
op.Results.StartAndEndTime,
op.Errors.Errors())
op.Errors.Errors(),
isPartialBackup)
logger.Ctx(ctx).Info("creating new backup")

View File

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