-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
libcontainer: intelrdt: fix a GetStats() issue #1615
libcontainer: intelrdt: fix a GetStats() issue #1615
Conversation
This fixes a GetStats() issue introduced in opencontainers#1590: If Intel RDT is enabled by hardware and kernel, but intelRdt is not specified in original config, GetStats() will return error unexpectedly because we haven't called Apply() to create intelrdt group or attach tasks for this container. As a result, runc events command will have no output. Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
@@ -443,6 +443,11 @@ func (m *IntelRdtManager) GetPath() string { | |||
|
|||
// Returns statistics for Intel RDT | |||
func (m *IntelRdtManager) GetStats() (*Stats, error) { | |||
// If intelRdt is not specified in config | |||
if m.Config.IntelRdt == nil { | |||
return nil, nil |
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.
Does the calling code handle a nil, nil
return or will it panic?
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.
Does the calling code handle a nil, nil return or will it panic?
It will not panic. In caller linuxContainer.Stats(): libcontainer.Stats.IntelRdtStats will be assigned to nil when intelRdtManager.GetStats() returns nil, nil.
And in events command, the caller convertLibcontainerStats() will handle the case when libcontainer.Stats.IntelRdtStats = nil
libcontainer: intelrdt: fix a GetStats() issue LGTMs: @crosbymichael @cyphar Closes #1615
This fixes a GetStats() issue introduced in #1590:
If Intel RDT is enabled by hardware and kernel, but intelRdt is not
specified in original config, GetStats() will return error unexpectedly
because we haven't called Apply() to create intelrdt group or attach
tasks for this container. As a result, runc events command will have no
output.
Signed-off-by: Xiaochen Shen xiaochen.shen@intel.com