From c8442d4a0a0062e3f43459c856a01c0e2c9dbbcf Mon Sep 17 00:00:00 2001 From: Michal-Leszczynski <74614433+Michal-Leszczynski@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:21:18 +0100 Subject: [PATCH] chore(go.mod): bump SM submodules deps (#4099) --- go.mod | 6 +- go.sum | 12 ++-- .../v3/pkg/managerclient/model.go | 68 ++++++++++++++++++- .../v3/pkg/managerclient/sizesuffix.go | 14 ++-- .../v3/pkg/managerclient/utils.go | 6 +- vendor/modules.txt | 6 +- 6 files changed, 88 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index 4d9f668c4e..9a60b696b8 100644 --- a/go.mod +++ b/go.mod @@ -29,9 +29,9 @@ require ( github.com/scylladb/go-reflectx v1.0.1 github.com/scylladb/go-set v1.0.2 github.com/scylladb/gocqlx/v2 v2.8.0 - github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20241030073626-e409ae491c83 - github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20241030073626-e409ae491c83 - github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20241030073626-e409ae491c83 + github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20241104134613-aba35605c28b + github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20241104134613-aba35605c28b + github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20241104134613-aba35605c28b github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/stoewer/go-strcase v1.3.0 diff --git a/go.sum b/go.sum index b08afc90f6..e1d5ec998e 100644 --- a/go.sum +++ b/go.sum @@ -1053,12 +1053,12 @@ github.com/scylladb/google-api-go-client v0.34.1-patched h1:DW+T0HA+74o6FDr3TFzV github.com/scylladb/google-api-go-client v0.34.1-patched/go.mod h1:RriRmS2wJXH+2yd9PRTEcR380U9AXmurWwznqVhzsSc= github.com/scylladb/rclone v1.54.1-0.20240312172628-afe1fd2aa65e h1:lJRphCtu+nKd+mfo8whOTeFkgjMWvk8iCSlqgibKSa8= github.com/scylladb/rclone v1.54.1-0.20240312172628-afe1fd2aa65e/go.mod h1:JGZp4EvCUK+6AM1Fe1dye5xvihTc/Bk0WnHHSCJOePM= -github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20241030073626-e409ae491c83 h1:1E64zMOGQ1N3FFIpkAKKF/XVBo6WZEL3tuXHgluqDCk= -github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20241030073626-e409ae491c83/go.mod h1:CkiJ7/3IfAZekjx7dFltltVI7HS1e7k8QKsofX6uitM= -github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20241030073626-e409ae491c83 h1:6kyuL5XXRTPbBSUessmfz6TxhYgOiIHCwC63wvDExgQ= -github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20241030073626-e409ae491c83/go.mod h1:+sPCx2oaOXmMpy/ODNNEDGJ7vCghBeKP4S7xEfMI+eA= -github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20241030073626-e409ae491c83 h1:+2wvERSjYAhGushwWpqw8EemmntHOIcCjHCWzEdpXcM= -github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20241030073626-e409ae491c83/go.mod h1:Oxfuz1XcXi9iV4ggSGfQdn+p6gPz6djPOegRMMe/6/s= +github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20241104134613-aba35605c28b h1:JRDV1d1FIiH0TIyHVmTAILAjQ2f8O4t7ZtZ/S+fT2sY= +github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20241104134613-aba35605c28b/go.mod h1:Tss7a99vrgds+B70w8ZFG3Skxfr9Br3kAzrKP2b3CmQ= +github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20241104134613-aba35605c28b h1:7CHNmPrQqSdApaEh5nkRL+D52KFHaOHVBBVDvytHEOY= +github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20241104134613-aba35605c28b/go.mod h1:+sPCx2oaOXmMpy/ODNNEDGJ7vCghBeKP4S7xEfMI+eA= +github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20241104134613-aba35605c28b h1:kKMaQhh+ThnPRmCbcatvvfBtglYEFrs5bKaBRIKL/bM= +github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20241104134613-aba35605c28b/go.mod h1:Oxfuz1XcXi9iV4ggSGfQdn+p6gPz6djPOegRMMe/6/s= github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4 h1:8qmTC5ByIXO3GP/IzBkxcZ/99VITvnIETDhdFz/om7A= github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg= github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= diff --git a/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/model.go b/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/model.go index 68566846ad..bc594eb077 100644 --- a/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/model.go +++ b/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/model.go @@ -1021,6 +1021,9 @@ Duration: {{ FormatDuration .StartTime .EndTime }} {{ end -}} {{ with .Progress }}Progress: {{ if ne .Size 0 }}{{ FormatRestoreProgress .Size .Restored .Downloaded .Failed }}{{else}}-{{ end }} Snapshot Tag: {{ .SnapshotTag }} +Bandwidth: + - Download: {{ avgDownload .Hosts }} + - Load&stream: {{ avgStream .Hosts }} {{ else }}Progress: 0% {{ end }} {{- if .Errors -}} @@ -1038,6 +1041,8 @@ func (rp RestoreProgress) addHeader(w io.Writer) error { "FormatError": FormatError, "FormatRestoreProgress": FormatRestoreProgress, "status": rp.status, + "avgDownload": avgDownload, + "avgStream": avgStream, }).Parse(restoreProgressTemplate)) return temp.Execute(w, rp) } @@ -1055,6 +1060,37 @@ func (rp RestoreProgress) status() string { return s } +func avgDownload(hosts []*models.RestoreHostProgress) string { + var bytes, milliseconds, shards int64 + for _, hp := range hosts { + bytes += hp.DownloadedBytes + milliseconds += hp.DownloadDuration + shards += hp.ShardCnt + } + return formatBandwidth(bytes, milliseconds, shards) +} + +func avgStream(hosts []*models.RestoreHostProgress) string { + var bytes, milliseconds, shards int64 + for _, hp := range hosts { + bytes += hp.StreamedBytes + milliseconds += hp.StreamDuration + shards += hp.ShardCnt + } + return formatBandwidth(bytes, milliseconds, shards) +} + +func formatBandwidth(bytes, milliseconds, shards int64) string { + if milliseconds <= 0 { + return "unknown" + } + bs := bytes * 1000 / milliseconds + if shards <= 0 { + return FormatSizeSuffix(bs) + "/s" + } + return FormatSizeSuffix(bs/shards) + "/s/shard" +} + func (rp RestoreProgress) hideKeyspace(keyspace string) bool { if rp.KeyspaceFilter.Size() > 0 { return rp.KeyspaceFilter.FirstMatch(keyspace) == -1 @@ -1082,10 +1118,15 @@ func (rp RestoreProgress) Render(w io.Writer) error { } } - if rp.Detailed && rp.Progress.Size > 0 { - if err := rp.addTableProgress(w); err != nil { + if rp.Detailed { + if err := rp.addHostProgress(w); err != nil { return err } + if rp.Progress.Size > 0 { + if err := rp.addTableProgress(w); err != nil { + return err + } + } } // Check if there is repair progress to display @@ -1211,6 +1252,29 @@ func (rp RestoreProgress) addTableProgress(w io.Writer) error { return nil } +func (rp RestoreProgress) addHostProgress(w io.Writer) error { + _, _ = fmt.Fprintf(w, "\nHosts info\n") + t := table.New("Host", "Shards", "Download bandwidth", "Download duration", "Load&stream bandwidth", "Load&stream duration") + for i, hp := range rp.Progress.Hosts { + if i > 0 { + t.AddSeparator() + } + t.AddRow( + hp.Host, + hp.ShardCnt, + formatBandwidth(hp.DownloadedBytes, hp.DownloadDuration, hp.ShardCnt), + FormatMsDuration(hp.DownloadDuration), + formatBandwidth(hp.StreamedBytes, hp.StreamDuration, hp.ShardCnt), + FormatMsDuration(hp.StreamDuration), + ) + } + t.SetColumnAlignment(termtables.AlignRight, 1, 2, 3, 4, 5) + if _, err := w.Write([]byte(t.String())); err != nil { + return err + } + return nil +} + func (rp RestoreProgress) addViewProgress(w io.Writer) { if len(rp.Progress.Views) == 0 { return diff --git a/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/sizesuffix.go b/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/sizesuffix.go index 173e2b6513..49ada81e4a 100644 --- a/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/sizesuffix.go +++ b/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/sizesuffix.go @@ -37,25 +37,25 @@ func (x SizeSuffix) string() (string, string) { case x < 0: return "off", "" case x == 0: - return "0", "" + return "0", "B" case x < 1<<10: scaled = float64(x) - suffix = "" + suffix = "B" case x < 1<<20: scaled = float64(x) / (1 << 10) - suffix = "k" + suffix = "KiB" case x < 1<<30: scaled = float64(x) / (1 << 20) - suffix = "M" + suffix = "MiB" case x < 1<<40: scaled = float64(x) / (1 << 30) - suffix = "G" + suffix = "GiB" case x < 1<<50: scaled = float64(x) / (1 << 40) - suffix = "T" + suffix = "TiB" default: scaled = float64(x) / (1 << 50) - suffix = "P" + suffix = "PiB" } if math.Floor(scaled) == scaled { return fmt.Sprintf("%.0f", scaled), suffix diff --git a/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/utils.go b/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/utils.go index 4a5fe69f22..850c079d70 100644 --- a/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/utils.go +++ b/vendor/github.com/scylladb/scylla-manager/v3/pkg/managerclient/utils.go @@ -191,10 +191,10 @@ func FormatDuration(t0, t1 strfmt.DateTime) string { return d.Truncate(time.Second).String() } -// FormatMsDuration returns string representation of duration as number of -// milliseconds. +// FormatMsDuration returns string representation of given amount of milliseconds +// as duration rounded up to a full second. func FormatMsDuration(d int64) string { - return (time.Duration(d) * time.Millisecond).Truncate(time.Second).String() + return (time.Duration(d)*time.Millisecond + time.Second - 1).Truncate(time.Second).String() } func isZero(t strfmt.DateTime) bool { diff --git a/vendor/modules.txt b/vendor/modules.txt index 88b5b3f2b3..d95e1dfa51 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -395,11 +395,11 @@ github.com/scylladb/gocqlx/v2/dbutil github.com/scylladb/gocqlx/v2/migrate github.com/scylladb/gocqlx/v2/qb github.com/scylladb/gocqlx/v2/table -# github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20241030073626-e409ae491c83 +# github.com/scylladb/scylla-manager/v3/pkg/managerclient v0.0.0-20241104134613-aba35605c28b ## explicit; go 1.21.1 github.com/scylladb/scylla-manager/v3/pkg/managerclient github.com/scylladb/scylla-manager/v3/pkg/managerclient/table -# github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20241030073626-e409ae491c83 +# github.com/scylladb/scylla-manager/v3/pkg/util v0.0.0-20241104134613-aba35605c28b ## explicit; go 1.21.1 github.com/scylladb/scylla-manager/v3/pkg/util github.com/scylladb/scylla-manager/v3/pkg/util/certutil @@ -431,7 +431,7 @@ github.com/scylladb/scylla-manager/v3/pkg/util/timeutc github.com/scylladb/scylla-manager/v3/pkg/util/uuid github.com/scylladb/scylla-manager/v3/pkg/util/version github.com/scylladb/scylla-manager/v3/pkg/util/workerpool -# github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20241030073626-e409ae491c83 +# github.com/scylladb/scylla-manager/v3/swagger v0.0.0-20241104134613-aba35605c28b ## explicit; go 1.21.1 github.com/scylladb/scylla-manager/v3/swagger/gen/agent/client github.com/scylladb/scylla-manager/v3/swagger/gen/agent/client/operations