-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Move service_util endpoints related functions to framework/endpoints/ports.go #77720
Move service_util endpoints related functions to framework/endpoints/ports.go #77720
Conversation
Hi @jiatongw. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
@@ -1072,7 +1072,7 @@ metadata: | |||
}) | |||
validateService := func(name string, servicePort int, timeout time.Duration) { | |||
err := wait.Poll(framework.Poll, timeout, func() (bool, error) { | |||
endpoints, err := c.CoreV1().Endpoints(ns).Get(name, metav1.GetOptions{}) | |||
ep, err := c.CoreV1().Endpoints(ns).Get(name, metav1.GetOptions{}) | |||
if err != 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.
Rename variable endpoints
to ep
because we need to import endpoints
package in this file
/assign @andrewsykim |
thanks for the PR @jiatongw |
/assign @timothysc |
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.
minor nits then lgtm
test/e2e/network/service.go
Outdated
@@ -37,6 +37,7 @@ import ( | |||
cloudprovider "k8s.io/cloud-provider" | |||
"k8s.io/kubernetes/pkg/controller/endpoint" | |||
"k8s.io/kubernetes/test/e2e/framework" | |||
"k8s.io/kubernetes/test/e2e/framework/endpoints" |
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.
given the other naming patterns we should prefix with e2e to avoid collisions with existing libraries.
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.
e2eendpoints
is a bit weird.. do you have some 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.
i think it's fine. the double ee
is not a problem.
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 Lubomir and Tim
/approve to unblock post renaming in case others want to lgtm earlier. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jiatongw, neolit123, timothysc 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 |
d88e859
to
bf00831
Compare
/lgtm |
bf00831
to
61c1791
Compare
There are conflicts because we both modified |
6a0df2d
to
e5fc1d0
Compare
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.
/test pull-kubernetes-e2e-gce-device-plugin-gpu
} | ||
portsByUID[pod.ObjectMeta.UID] = portList | ||
} | ||
// Logf("successfully translated pod names to UIDs: %v -> %v on namespace %s", expectedEndpoints, portsByUID, ns) |
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.
Should we remove this commented-out line?
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.
Those code are already commented out before I opened this PR so I don't touch them.
I think they are good to remove since we are more interested in error logs. I'll delete those lines. Thanks
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 like these comments were here before, agreed that they're probably safe to remove
e2elog.Logf("Get endpoints failed (%v elapsed, ignoring for 5s): %v", time.Since(start), err) | ||
continue | ||
} | ||
// Logf("Found endpoints %v", endpoints) |
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.
ditto
// Logf("Found endpoints %v", endpoints) | ||
|
||
portsByPodUID := GetContainerPortsByPodUID(ep) | ||
// Logf("Found port by pod UID %v", portsByPodUID) |
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.
ditto
for name, portList := range expectedEndpoints { | ||
pod, err := c.CoreV1().Pods(ns).Get(name, metav1.GetOptions{}) | ||
if err != nil { | ||
framework.Failf("failed to get pod %s, that's pretty weird. validation failed: %s", name, err) |
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.
Maybe for a future PR, we should try to avoid importing framework
here. Maybe a better pattern is to return an err here and have the calling test run framework.Failf
.
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.
Actually, if you don't mind I think it would be ideal to do this refactor now. It'll keep the dependency graph cleaner for later
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.
updated, ready to review
} | ||
portsByUID[pod.ObjectMeta.UID] = portList | ||
} | ||
// Logf("successfully translated pod names to UIDs: %v -> %v on namespace %s", expectedEndpoints, portsByUID, ns) |
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 like these comments were here before, agreed that they're probably safe to remove
} | ||
|
||
// ValidateEndpointsOrFail validates that the given service exists and is served by the given expectedEndpoints. | ||
func ValidateEndpointsOrFail(c clientset.Interface, namespace, serviceName string, expectedEndpoints PortsByPodName) { |
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 rename this to ValidateEndpointsPortsOrFail
?
e5fc1d0
to
7175ed2
Compare
Keep 2 commits for now, if good to merge, I'll squash them to 1 commit |
/test pull-kubernetes-bazel-test |
it is better to squash if just two commits and very small. |
} else { | ||
e2elog.Logf("Can't list pod debug info: %v", err) | ||
} | ||
return fmt.Errorf("Timed out waiting for service %s in namespace %s to expose endpoints %v (%v elapsed)", serviceName, namespace, expectedEndpoints, framework.ServiceStartTimeout) |
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.
If framework.ServiceStartTimeout
is the only reason we're importing framework
here I think it would be okay to duplicate this constant into this package or import it somewhere else. What do you think?
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 think it's ok to do that. Thanks! Updated.
@jiatongw Thank you for mention. I've confirmed that your comments on next items are OK for me. 😃
|
Signed-off-by: Jiatong Wang <wangjiatong@vmware.com>
7175ed2
to
76f7645
Compare
/lgtm |
/retest Review the full test history for this PR. Silence the bot with an |
1 similar comment
/retest Review the full test history for this PR. Silence the bot with an |
What type of PR is this?
/kind cleanup
/priority backlog
What this PR does / why we need it:
Reference issue #77197, #76206 (parent issue #75601 )
Does this PR introduce a user-facing change?: