Skip to content

Commit

Permalink
Merge pull request docker#4934 from thaJeztah/stats_improve
Browse files Browse the repository at this point in the history
cli/command/container: use ping-result for OS-version
  • Loading branch information
thaJeztah authored Mar 11, 2024
2 parents b55cf2f + 5c54f75 commit d06f137
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions cli/command/container/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,6 @@ var acceptedStatsFilters = map[string]bool{
func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions) error {
apiClient := dockerCLI.Client()

// Get the daemonOSType if not set already
if daemonOSType == "" {
sv, err := apiClient.ServerVersion(ctx)
if err != nil {
return err
}
daemonOSType = sv.Os
}

// waitFirst is a WaitGroup to wait first stat data's reach for each container
waitFirst := &sync.WaitGroup{}
// closeChan is a non-buffered channel used to collect errors from goroutines.
Expand Down Expand Up @@ -267,6 +258,12 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
format = formatter.TableFormatKey
}
}
if daemonOSType == "" {
// Get the daemonOSType if not set already. The daemonOSType variable
// should already be set when collecting stats as part of "collect()",
// so we unlikely hit this code in practice.
daemonOSType = dockerCLI.ServerInfo().OSType
}
statsCtx := formatter.Context{
Output: dockerCLI.Out(),
Format: NewStatsFormat(format, daemonOSType),
Expand Down

0 comments on commit d06f137

Please sign in to comment.