Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Parse kopia snapshot restore progress output. #2776

Merged
merged 10 commits into from
May 21, 2024

Conversation

e-sumin
Copy link
Contributor

@e-sumin e-sumin commented Mar 21, 2024

Change Overview

Kopia does have progress reporting for restore operation (when using CLI), which is slightly different from snapshotting progress. This PR contains logic for parsing this progress. It will be used for parsing snapshot restore progress and will be propagated to progress stored in ActionSet status.

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test

Issues

  • fixes #issue-number

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

@infraq infraq added this to In Progress in Kanister Mar 21, 2024
@pavannd1 pavannd1 requested review from ankitjain235 and redgoat650 and removed request for viveksinghggits and hairyhum March 26, 2024 22:31
pkg/kopia/command/parse_command_output.go Outdated Show resolved Hide resolved
pkg/kopia/command/parse_command_output.go Outdated Show resolved Hide resolved
pkg/kopia/command/parse_command_output.go Outdated Show resolved Hide resolved
Reformat comments

Co-authored-by: Pavan Navarathna <6504783+pavannd1@users.noreply.github.com>
@e-sumin e-sumin requested a review from pavannd1 May 15, 2024 23:20
@e-sumin e-sumin changed the title Parse kopia snapshot restore progress output. feat: Parse kopia snapshot restore progress output. May 16, 2024
Comment on lines 344 to 345
// SnapshotStatsFromSnapshotRestore parses the output of a `kopia snapshot
// restore` execution for a log of the stats for that execution.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I was not able to understand this comment properly, especially the part execution for a log of the stats for that execution..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment was done in same styling (wording) as in similar function:
https://github.com/kanisterio/kanister/pull/2776/files#diff-00217f95488de292da931fcdc8bdc46e611d503b26e17e13119cb4ce04548892R214-R215

In both cases it means that we have output of some command, we are parsing it and trying to find stats logged by command.

Possible rephrasing (for both cases) :
// XXX parses the output of 'ZZZZZ' line-by-line in search of progress statistics.
// It returns nil if no statistics are found, or the most recent statistic if multiple are encountered.

WDYT ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced for both SnapshotStatsFromSnapshotCreate and RestoreStatsFromRestoreOutput

@@ -327,6 +331,93 @@ func parseKopiaProgressLine(line string, matchOnlyFinished bool) (stats *Snapsho
}
}

// SnapshotRestoreStats is a container for stats parsed from the output of a
// `kopia snapshot restore` command.
type SnapshotRestoreStats struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it just be called RestoreStats? i quickly checked what kopia restore command is called and its kopia restore so I think just RestoreStats should also be ok.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But please feel free to disagree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I was always using kopia snapshot restore but I've just checked documentation, and you are right. Seems that snapshot restore is an alias to restore. So your suggestion makes sense.


// SnapshotStatsFromSnapshotRestore parses the output of a `kopia snapshot
// restore` execution for a log of the stats for that execution.
func SnapshotStatsFromSnapshotRestore(snapRestoreStderrOutput string) (stats *SnapshotRestoreStats) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func SnapshotStatsFromSnapshotRestore(snapRestoreStderrOutput string) (stats *SnapshotRestoreStats) {
func RestoreStatsFromRestoreOP(snapRestoreStderrOutput string) (stats *SnapshotRestoreStats) {

maybe this or similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've renamed it to RestoreStatsFromRestoreOutput to make it as straightforward as possible.

}

func parseKopiaSnapshotRestoreProgressLine(line string) (stats *SnapshotRestoreStats) {
match := kopiaSnapshotRestorePattern.FindStringSubmatch(line)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be a good idea if we can also share (in comments) how exactly this line looks like.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@viveksinghggits viveksinghggits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be merged after addressing small nits.

}

// RestoreStatsFromRestoreOutput parses the output of a `kopia restore`
// execution for a log of the stats for that execution.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// execution for a log of the stats for that execution.
// and figures out the progress stats for that operation.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've rephrased it according to my previous suggestion: #2776 (comment)

// parseKopiaSnapshotRestoreProgressLine parses restore stats from line
// which expected to be in the following format:
// Processed 5 (1.4 GB) of 5 (1.8 GB) 291.1 MB/s (75.2%) remaining 1s.
func parseKopiaSnapshotRestoreProgressLine(line string) (stats *RestoreStats) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is snapshotrestore required here? or just kopiarestore would be enough?

Comment on lines 362 to 364
// parseKopiaSnapshotRestoreProgressLine parses restore stats from line
// which expected to be in the following format:
// Processed 5 (1.4 GB) of 5 (1.8 GB) 291.1 MB/s (75.2%) remaining 1s.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// parseKopiaSnapshotRestoreProgressLine parses restore stats from line
// which expected to be in the following format:
// Processed 5 (1.4 GB) of 5 (1.8 GB) 291.1 MB/s (75.2%) remaining 1s.
// parseKopiaSnapshotRestoreProgressLine parses restore stats from the output log line,
// which is expected to be in the following format:
// Processed 5 (1.4 GB) of 5 (1.8 GB) 291.1 MB/s (75.2%) remaining 1s.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted, but due to renamed function, in a separate commit

pkg/kopia/command/parse_command_output.go Outdated Show resolved Hide resolved
pkg/kopia/command/parse_command_output.go Outdated Show resolved Hide resolved
Kanister automation moved this from In Progress to Reviewer approved May 20, 2024
@mergify mergify bot merged commit 05db153 into master May 21, 2024
15 checks passed
Kanister automation moved this from Reviewer approved to Done May 21, 2024
@mergify mergify bot deleted the kopia_progress_parsing branch May 21, 2024 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants