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
CNF-9173: e2e: cgroups: introduce cgroup package #906
Conversation
/cc @mrniranjan |
This PR was part of #892 which we decide to extract in order merge it more quickly since it needed for the cgroupv2 testing |
@Tal-or: This pull request references CNF-9173 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.16.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
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.
looks nice, but we need some form of testing, at least partial
Period string | ||
} | ||
|
||
type Getter interface { |
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.
I'd actually get rid of this interface entirely.
Plus, in golang better to define interface on the consumer side: https://www.thoughtworks.com/insights/blog/programming-languages/mistakes-to-avoid-when-coming-from-an-object-oriented-language
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.
Thank you for the useful information, it really helps understand the principles better.
So in our case it means the interface would be implemented in the test files themselves, i.e. 11_mixedcpus/mixedcpus.go
and optionally 7_performance_kubelet_node/cgroups.go
.
But what if both packages want to use the exact interface? should both declare it?
And my second questions is how do you suggest the BuildGetter
to return a struct, while it suppose to return an abstraction for getting the cgroup information.
Of course we can implement the BuildGetter
on the consumer side (where there it would make sense to expect interface), but again it's a duplication of code, since at least two packages (from what I know of) would need to implement it to retrieve the existing cgroup configuration on the node.
0891e79
to
b42c534
Compare
CPUSet string | ||
Quota string | ||
Period string | ||
} |
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.
Can we define structure in a more hierarchial fashion i.e: Controllers->Controller-interfacefiles
type CgroupController struct {
//suported cgroup Controllers
cpuset
cpu
// any future cgroup controllers
}
Then created methods that return interface files of that particular controller ?
|
||
func (m *Manager) GetConfig(ctx context.Context, c *kubernetes.Clientset, pod *corev1.Pod, containerName string) (*config.Config, error) { | ||
var cmd []string | ||
cfg := &config.Config{} |
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.
GetConfig here supports getting here only cpuset.cpus, cpu.max, but there are other interface files that equally important and we do need them in future like
cpuset.cpu.partition, cpuset.cpus.effective, cpuset.mems (this is specifically required for memory manager to know which numa interface the pod has been assigned).
This PR is a good starting point, i think we can improve it in further iteration |
b42c534
to
59b3f14
Compare
@Tal-or: This pull request references CNF-9173 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@Tal-or: This pull request references CNF-9173 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@Tal-or: This pull request references CNF-9173 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@Tal-or: This pull request references CNF-9173 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@Tal-or: This pull request references CNF-9173 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@mrniranjan IMO the existing implementation is good enough for now and we can expand it later |
it's probabably wasteful to retry until we can consume cri-o/cri-o#7643 in our CI clusters |
} | ||
|
||
func (cm *ControllersManager) Cpu(ctx context.Context, pod *corev1.Pod, containerName, runtimeType string) (*controller.Cpu, error) { | ||
cfg := &controller.Cpu{} |
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.
We are passing runtimeType but we are not using this variable in Cpu function
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.
Yes I need to learn the details, i just passed the argument for now
return &ControllersManager{client: c, k8sClient: k8sClient} | ||
} | ||
|
||
func (cm *ControllersManager) CpuSet(ctx context.Context, pod *corev1.Pod, containerName, runtimeType string) (*controller.CpuSet, error) { |
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.
We are passing runtimeType but we are not using this variable in CpuSet function
LGTM from my side, we can improve this further in future iterations. |
This is why the updating lane is falling? |
/test-required |
/test required |
@Tal-or: The specified target(s) for
The following commands are available to trigger optional jobs:
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
In case no name provided, it takes the name from the first container in the pod. Signed-off-by: Talor Itzhak <titzhak@redhat.com>
1cc1cde
to
81e2c02
Compare
81e2c02
to
36a1f9e
Compare
/hold cancel |
/retest |
This package provides a ControllerGetter which is cgroup version agnostic. It provides a unified api for testing the mixedcpus feature for both v1 and v2. The package can be expand in the future for testing additional features that requires cgroups inspection. Also in the future this package should be runtime (crun/runc) agnostic. Signed-off-by: Talor Itzhak <titzhak@redhat.com>
36a1f9e
to
58b3575
Compare
/retest |
The exec command might return empty value. In order to have better control of what we get we should read the files in separate exec calls. Signed-off-by: Talor Itzhak <titzhak@redhat.com>
/lgtm |
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.
LGTM
nice addition
@@ -148,7 +148,7 @@ var _ = Describe("[performance]Hugepages", Ordered, func() { | |||
Expect(err).ToNot(HaveOccurred()) | |||
|
|||
cmd2 := []string{"/bin/bash", "-c", "tmux new -d 'LD_PRELOAD=libhugetlbfs.so HUGETLB_MORECORE=yes top -b > /dev/null'"} | |||
_, err = pods.ExecCommandOnPod(testclient.K8sClient, testpod, cmd2) | |||
_, err = pods.ExecCommandOnPod(testclient.K8sClient, testpod, "", cmd2) |
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.
this works. An alternative option could have been to add a variant function which accepts a container name and reimplement the existing ExecCommandOnPod (with the current signature) on top of it. But we can keep this approach.
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.
Yes this is an option as well.
@@ -99,3 +93,25 @@ func (cm *ControllersManager) Child(ctx context.Context, pod *corev1.Pod, contai | |||
// TODO | |||
return nil | |||
} | |||
|
|||
func (cm *ControllersManager) execAndStore(pod *corev1.Pod, containerName, dirPath string, store map[string]*string) error { |
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.
not a big fan of mutating arguments (and of maps whose values are pointers) but I see why you are doing like this and I don't have compelling suggestions
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.
Yea, it was the only way to generalize the calls per each controller file
@@ -98,3 +92,24 @@ func (cm *ControllersManager) Child(ctx context.Context, pod *corev1.Pod, contai | |||
} | |||
return nil | |||
} | |||
func (cm *ControllersManager) execAndStore(pod *corev1.Pod, containerName, dirPath string, store map[string]*string) error { |
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.
this seems one of the instances on which seems better to generalize the function. But I think you did not because the v1 and v2 package have no common package to share library functions, and adding one doesn't seem so great. If that's the case I agree to keep it like this for starters.
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.
Thanks. We may consider shared library in the future in case of additional common functions.
/approve we want this change in |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ffromani, Tal-or The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@Tal-or: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
[ART PR BUILD NOTIFIER] This PR has been included in build cluster-node-tuning-operator-container-v4.16.0-202402051840.p0.g51e073f.assembly.stream for distgit cluster-node-tuning-operator. |
/cherry-pick release-4.15 Needed for mixed-cpus e2e testing |
@Tal-or: #906 failed to apply on top of branch "release-4.15":
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This package provides a Getter which is cgroup version agnostic.
It provides a unified api for testing the mixedcpus feature for both v1 and v2.
The package can be expand in the future for testing additional features that requires cgroups inspection. (for example runc vs crun)
How to use: