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

refactor: container stats command #2306

Merged
merged 1 commit into from
Jun 27, 2023

Conversation

ningziwen
Copy link
Contributor

@ningziwen ningziwen marked this pull request as ready for review June 22, 2023 04:57
}

noStream, err := cmd.Flags().GetBool("no-stream")
if err != nil {
return err
return types.ContainerStatsOptions{}, err
}

format, err := cmd.Flags().GetString("format")
Copy link
Member

Choose a reason for hiding this comment

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

Lint is failing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Signed-off-by: Ziwen Ning <ningziwe@amazon.com>
}

// when (firstSet == true), we only set container stats without rendering stat entry
statsEntry, err := setContainerStatsAndRenderStatsEntry(previousStats, firstSet, anydata, int(task.Pid()), netNS.Interfaces)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
statsEntry, err := setContainerStatsAndRenderStatsEntry(previousStats, firstSet, anydata, int(task.Pid()), netNS.Interfaces)
statsEntry, err := setContainerStatsThenRenderStatsEntry(previousStats, firstSet, anydata, int(task.Pid()), netNS.Interfaces)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"And" seems more common to me than "Then" in my impression. Any specific reasons of preferring "Then"?

(This is out of the scope of the current refactoring goal but I'm good to quickly include it if it makes sense)

Copy link
Member

@fahedouch fahedouch Jun 26, 2023

Choose a reason for hiding this comment

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

what happens behind the scenes: in the first iteration we only set ContainerStats, then in the second iteration we set a new ContainerStats and render the statistics by making diff. My idea was to reflect this strategy in the title of the function but we can keep it if you don't feel the need @AkihiroSuda @ningziwen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me, for the meanings, "and" and "then" should be interchangable in Go naming.

Even In daily usage, they seem very similar in most scenarios.
"I opened the door, and entered the room"
"I opened the door, then entered the room"

I'm leaning to keeping the more common one "and" but don't have strong preference.

@fahedouch
Copy link
Member

I left small comment, Globally LGTM , Thanks

@ningziwen ningziwen requested a review from fahedouch June 24, 2023 20:38
Copy link
Member

@fahedouch fahedouch left a comment

Choose a reason for hiding this comment

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

Thanks

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit 5195b20 into containerd:main Jun 27, 2023
@ningziwen ningziwen deleted the refactorstats branch June 27, 2023 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants