Skip to content

Commit

Permalink
[Snapshot] get rid of non-valuable but possibly buggy optimization wh…
Browse files Browse the repository at this point in the history
…ich saves 1 task update when dataplane task is almost finished; better logging (#1958)
  • Loading branch information
SvartMetal authored Sep 5, 2024
1 parent 1d6bf33 commit e1a12c0
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,12 @@ func (t *createSnapshotFromDiskTask) saveProgress(
execCtx tasks.ExecutionContext,
) error {

if t.state.Progress == 1 {
return nil
}

if t.state.ChunkCount != 0 {
t.state.Progress =
float64(t.state.MilestoneChunkIndex) / float64(t.state.ChunkCount)
}

logging.Debug(ctx, "saving state %+v", t.state)
return execCtx.SaveState(ctx)
}

Expand All @@ -146,7 +143,7 @@ func (t *createSnapshotFromDiskTask) lockBaseSnapshot(
if diskParams.IsDiskRegistryBasedDisk {
logging.Info(
ctx,
"Performing full snapshot %v of disk %v because it is registry based",
"Performing full snapshot %v of disk %v because it is Disk Registry based",
snapshotMeta.ID,
t.request.SrcDisk.DiskId,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/ydb-platform/nbs/cloud/disk_manager/internal/pkg/dataplane/snapshot"
"github.com/ydb-platform/nbs/cloud/disk_manager/internal/pkg/dataplane/snapshot/storage"
"github.com/ydb-platform/nbs/cloud/tasks"
"github.com/ydb-platform/nbs/cloud/tasks/logging"
)

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -183,14 +184,11 @@ func (t *createSnapshotFromLegacySnapshotTask) saveProgress(
execCtx tasks.ExecutionContext,
) error {

if t.state.Progress == 1 {
return nil
}

if t.state.ChunkCount != 0 {
t.state.Progress =
float64(t.state.MilestoneChunkIndex) / float64(t.state.ChunkCount)
}

logging.Debug(ctx, "saving state %+v", t.state)
return execCtx.SaveState(ctx)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/ydb-platform/nbs/cloud/disk_manager/internal/pkg/dataplane/protos"
"github.com/ydb-platform/nbs/cloud/disk_manager/internal/pkg/dataplane/snapshot/storage"
"github.com/ydb-platform/nbs/cloud/tasks"
"github.com/ydb-platform/nbs/cloud/tasks/logging"
)

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -127,14 +128,11 @@ func (t *createSnapshotFromSnapshotTask) saveProgress(
execCtx tasks.ExecutionContext,
) error {

if t.state.Progress == 1 {
return nil
}

if t.state.ChunkCount != 0 {
t.state.Progress =
float64(t.state.MilestoneChunkIndex) / float64(t.state.ChunkCount)
}

logging.Debug(ctx, "saving state %+v", t.state)
return execCtx.SaveState(ctx)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/ydb-platform/nbs/cloud/disk_manager/internal/pkg/dataplane/url"
"github.com/ydb-platform/nbs/cloud/tasks"
"github.com/ydb-platform/nbs/cloud/tasks/errors"
"github.com/ydb-platform/nbs/cloud/tasks/logging"
)

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -204,14 +205,11 @@ func (t *createSnapshotFromURLTask) saveProgress(
execCtx tasks.ExecutionContext,
) error {

if t.state.Progress == 1 {
return nil
}

if t.state.ChunkCount != 0 {
t.state.Progress =
float64(t.state.MilestoneChunkIndex) / float64(t.state.ChunkCount)
}

logging.Debug(ctx, "saving state %+v", t.state)
return execCtx.SaveState(ctx)
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func (t *replicateDiskTask) saveProgress(
t.state.SecondsRemaining = int64(bytesToReplicate / bytesPerSecond)
t.state.UpdatedAt = timestamppb.Now()

logging.Debug(ctx, "saving state %+v", t.state)
return execCtx.SaveState(ctx)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ydb-platform/nbs/cloud/disk_manager/internal/pkg/dataplane/nbs"
"github.com/ydb-platform/nbs/cloud/disk_manager/internal/pkg/dataplane/protos"
"github.com/ydb-platform/nbs/cloud/tasks"
"github.com/ydb-platform/nbs/cloud/tasks/logging"
)

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -150,14 +151,11 @@ func (t *transferFromDiskToDiskTask) saveProgress(
execCtx tasks.ExecutionContext,
) error {

if t.state.Progress == 1 {
return nil
}

if t.state.ChunkCount != 0 {
t.state.Progress =
float64(t.state.MilestoneChunkIndex) / float64(t.state.ChunkCount)
}

logging.Debug(ctx, "saving state %+v", t.state)
return execCtx.SaveState(ctx)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ydb-platform/nbs/cloud/disk_manager/internal/pkg/dataplane/snapshot"
"github.com/ydb-platform/nbs/cloud/disk_manager/internal/pkg/dataplane/snapshot/storage"
"github.com/ydb-platform/nbs/cloud/tasks"
"github.com/ydb-platform/nbs/cloud/tasks/logging"
)

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -131,14 +132,11 @@ func (t *transferFromSnapshotToDiskTask) saveProgress(
execCtx tasks.ExecutionContext,
) error {

if t.state.Progress == 1 {
return nil
}

if t.state.ChunkCount != 0 {
t.state.Progress =
float64(t.state.MilestoneChunkIndex) / float64(t.state.ChunkCount)
}

logging.Debug(ctx, "saving state %+v", t.state)
return execCtx.SaveState(ctx)
}

0 comments on commit e1a12c0

Please sign in to comment.