-
Notifications
You must be signed in to change notification settings - Fork 158
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
Conversation
Reformat comments Co-authored-by: Pavan Navarathna <[email protected]>
kopia snapshot restore
progress output.kopia snapshot restore
progress output.
// SnapshotStatsFromSnapshotRestore parses the output of a `kopia snapshot | ||
// restore` execution for a log of the stats for that execution. |
There was a problem hiding this comment.
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.
.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func SnapshotStatsFromSnapshotRestore(snapRestoreStderrOutput string) (stats *SnapshotRestoreStats) { | |
func RestoreStatsFromRestoreOP(snapRestoreStderrOutput string) (stats *SnapshotRestoreStats) { |
maybe this or similar?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// execution for a log of the stats for that execution. | |
// and figures out the progress stats for that operation. |
?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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. |
There was a problem hiding this comment.
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
Co-authored-by: Vivek Singh <[email protected]>
4d5aff7
to
92c4a3a
Compare
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:
Issues
Test Plan