Skip to content

Commit

Permalink
Merge branch 'master' into heal-do-not-quit
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana authored Nov 13, 2024
2 parents a57c076 + 63eb4a4 commit 7dc8fc4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
4 changes: 2 additions & 2 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ type Client interface {
GetObjectLockConfig(ctx context.Context) (status string, mode minio.RetentionMode, validity uint64, unit minio.ValidityUnit, perr *probe.Error)

// Access policy operations.
GetAccess(ctx context.Context) (access, policyJSON string, error *probe.Error)
GetAccessRules(ctx context.Context) (policyRules map[string]string, error *probe.Error)
GetAccess(ctx context.Context) (access, policyJSON string, err *probe.Error)
GetAccessRules(ctx context.Context) (policyRules map[string]string, err *probe.Error)
SetAccess(ctx context.Context, access string, isJSON bool) *probe.Error

// I/O operations
Expand Down
20 changes: 10 additions & 10 deletions cmd/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,22 +283,22 @@ func pad(s, p string, count int, left bool) string {
func pingStats(cliCtx *cli.Context, result madmin.AliveResult, serverMap map[string]serverStats) serverStats {
var errorString string
var sum, avg, dns uint64
min := uint64(math.MaxUint64)
var max uint64
minPing := uint64(math.MaxUint64)
var maxPing uint64
var counter, errorCount int

if result.Error != nil {
errorString = result.Error.Error()
if stat, ok := serverMap[result.Endpoint.Host]; ok {
min = stat.min
max = stat.max
minPing = stat.min
maxPing = stat.max
sum = stat.sum
counter = stat.counter
avg = stat.avg
errorCount = stat.errorCount + 1

} else {
min = 0
minPing = 0
errorCount = 1
}
if cliCtx.IsSet("error-count") && errorCount >= cliCtx.Int("error-count") {
Expand All @@ -315,21 +315,21 @@ func pingStats(cliCtx *cli.Context, result madmin.AliveResult, serverMap map[str
} else {
minVal = stat.min
}
min = uint64(math.Min(float64(minVal), float64(uint64(result.ResponseTime))))
max = uint64(math.Max(float64(stat.max), float64(uint64(result.ResponseTime))))
minPing = uint64(math.Min(float64(minVal), float64(uint64(result.ResponseTime))))
maxPing = uint64(math.Max(float64(stat.max), float64(uint64(result.ResponseTime))))
sum = stat.sum + uint64(result.ResponseTime.Nanoseconds())
counter = stat.counter + 1

} else {
min = uint64(math.Min(float64(min), float64(uint64(result.ResponseTime))))
max = uint64(math.Max(float64(max), float64(uint64(result.ResponseTime))))
minPing = uint64(math.Min(float64(minPing), float64(uint64(result.ResponseTime))))
maxPing = uint64(math.Max(float64(maxPing), float64(uint64(result.ResponseTime))))
sum = uint64(result.ResponseTime)
counter = 1
}
avg = sum / uint64(counter)
dns = uint64(result.DNSResolveTime.Nanoseconds())
}
return serverStats{min, max, sum, avg, dns, errorCount, errorString, counter}
return serverStats{minPing, maxPing, sum, avg, dns, errorCount, errorString, counter}
}

// mainPing is entry point for ping command.
Expand Down
6 changes: 3 additions & 3 deletions cmd/speedtest-spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ func (m *speedTestUI) View() string {
dres := m.result.DriveResult
cres := m.result.ClientResult

trailerIfGreaterThan := func(in string, max int) string {
if len(in) < max {
trailerIfGreaterThan := func(in string, maxIdx int) string {
if len(in) < maxIdx {
return in
}
return in[:max] + "..."
return in[:maxIdx] + "..."
}

// Print the spinner
Expand Down
7 changes: 0 additions & 7 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ func UTCNow() time.Time {
return time.Now().UTC()
}

func max(a, b int) int {
if a > b {
return a
}
return b
}

// randString generates random names and prepends them with a known prefix.
func randString(n int, src rand.Source, prefix string) string {
if n == 0 {
Expand Down

0 comments on commit 7dc8fc4

Please sign in to comment.