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
OCPBUGS-7980: e2e:wait: return updated pod object explicitly #744
OCPBUGS-7980: e2e:wait: return updated pod object explicitly #744
Conversation
Thank you @ffromani for helping with this |
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.
The intent of the change is fine.
I'm reluctant to merge as-is as I'm generally against mutating arguments if we can help it. I'd prefer to return the updated object, even if this change is more invasive, I think is also clearer in the long run and lead to better code.
Also note that by far the most likely reason we have a pointer to pod as first argument (which will indeed mean the function can mutate the argument) is that we were concerned about performance in argument passing.
IOW, we pass a pointer not because the function was meant to mutate (that was never really documented or decided) but as optimization.
Yes I completely understand your intention.
Anyway I'm OK with what ever approach |
You make good points. Even if I'm not a fan of this approach, I won't block it either. I've tagged the other reviewers, let's see if we have a preference collectively. |
/test e2e-hypershift |
I wish we had an explicit way of marking the pointer as mutable (&mut Pod from Rust anyone? :) |
|
I would not rule out the "invasive" approach yet , can we check to what extent is it invasive ? (maybe its not that large) |
Rough guesstimation:
|
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.
My thought on this is that for operations like the ones here (WaitForDeletion
, WaitForCondition
and WaitForPhase
) it seems inappropriate to assume that the pod object returned is mutated (and is fresher than the object passed). Mutation should not be part of the equation here and the focus should be on waiting until the pod is deleted, meets a condition or attains a certain phase respectively. Ideally we should have had a function definition where we passed pod name instead of a pointer to pod object and that would have made it explicit that we don't expect pod object to be mutated.
If the caller relies on a fresh pod object, they should obtain it explicitly. The current changes seem to be further enforcing this (incorrect?) assumption rather than correcting or making it explicit. Now the question is are there many places where we have this assumption? IOW, what is the impact surface if we wanted to rectify this assumption of obtaining upto date pod objects when these functions are called?
If the motivating factor here to ensure clarity and to facilitate the consumer of utils/pods package, how about we add a function to explicitly obtain an updated pod object like below and use that where we expect to have a fresh pod object:
func GetPod(podName, namespace string) (*corev1.Pod, error){
.....
}
I am curious about what exactly is the reason we want to have the latest pod object? Do we expect the pod object to change here? In theory I can see a few use cases (in place VPA allowing resources updates, updates to labels, taints, tolerations etc) but I would like to understand it better in the context of the use cases we care about and our test suite.
I fully agree. It would be much better if the functions accept the pod identification data (= ObjectKey or namespace/name pair) rather than the full pod object.
This would be indeed the most explicit approach.
It's to save a Get which is not really costly, but redundant (yes, this is a form of premature optimization) In a nutshell, some Wait* functions return a copy of the object after the waited condition is met, effectively saving the caller a Get. This is both an optimization and a implementation detail leaking (The Wait* functions are all essentially a Get+condition check wrapped in a poll loop with a timeout), but the saving grace is that it still kinda fits in the semantic, albeit not cleanest approach. |
b0b3278
to
f44889d
Compare
Then it's settle we have a decision. please review that latest patch |
In some of the tests we're implicitly relaying on the fact that the pod data returned from the `pods.WaitFor*` functions is the most updated one. This is not the case in some of the functions on which we are storing the data on different pointer to pod object and never return it. On the other hand, those wait functions changing the passed object is an hidden implementation detail. Now the functions accepts only a key object in order to explicilty indicate no mutation to the object. In addition, the functions returns an updated copy of the object. Signed-off-by: Talor Itzhak <titzhak@redhat.com>
f44889d
to
cdee108
Compare
/test e2e-gcp-pao
|
@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. |
looks good to me . ill wait for others to give an ack before I add the approval |
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.
/approve
thanks for the changes, IMO much better now
[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 |
/hold |
holding to let other reviewers chime in |
/hold cancel |
@Tal-or: Jira Issue OCPBUGS-7980 is in an unrecognized state (MODIFIED) and will not be moved to the MODIFIED state. 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. |
/jira refresh |
@Tal-or: Jira Issue OCPBUGS-7980: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-7980 has been moved to the MODIFIED state. 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. |
/help |
/cherry-pick ? |
@Tal-or: cannot checkout 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 some of the tests we're implicitly relaying on the fact that the pod data returned from the
pods.WaitFor*
functions is the most updated one.This is not the case in some of the functions on which we are storing the data on different pointer to pod object and never return it.
Instead of using different pod object, we should use the same one passed into the function.