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

Move service_util endpoints related functions to framework/endpoints/ports.go #77720

Merged
merged 1 commit into from
May 21, 2019

Conversation

jiatongw
Copy link

@jiatongw jiatongw commented May 10, 2019

What type of PR is this?

/kind cleanup
/priority backlog

What this PR does / why we need it:

  • Move service_util.go endpoints related functions to framework/endpoints/ports.go.
  • Fix references of some methods to use the right package

Reference issue #77197, #76206 (parent issue #75601 )

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. priority/backlog Higher priority than priority/awaiting-more-evidence. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 10, 2019
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 10, 2019
@k8s-ci-robot k8s-ci-robot requested review from dcbw and pohly May 10, 2019 05:29
@k8s-ci-robot k8s-ci-robot added area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 10, 2019
@@ -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 {
Copy link
Author

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

@jiatongw
Copy link
Author

/assign @andrewsykim

@neolit123
Copy link
Member

thanks for the PR @jiatongw
/approve
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 10, 2019
@jiatongw
Copy link
Author

/assign @timothysc

Copy link
Member

@timothysc timothysc left a 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

@@ -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"
Copy link
Member

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.

Copy link
Author

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?

Copy link
Member

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.

Copy link
Author

@jiatongw jiatongw May 14, 2019

Choose a reason for hiding this comment

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

Thanks Lubomir and Tim

@timothysc timothysc dismissed their stale review May 14, 2019 14:16

changes coming

@timothysc
Copy link
Member

/approve

to unblock post renaming in case others want to lgtm earlier.

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 14, 2019
@jiatongw jiatongw force-pushed the e2e/framework/service_util branch 2 times, most recently from d88e859 to bf00831 Compare May 14, 2019 20:36
@figo
Copy link
Contributor

figo commented May 16, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 16, 2019
@jiatongw jiatongw force-pushed the e2e/framework/service_util branch from bf00831 to 61c1791 Compare May 16, 2019 17:58
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 16, 2019
@jiatongw
Copy link
Author

jiatongw commented May 16, 2019

There are conflicts because we both modified service_util.go. I integrated both yours and mine comments on PortsByPodName, PortsByPodUID, GetContainerPortsByPodUID and ValidateEndpointsOrFail, which in ports.go. Some of them I chose to keep my original comments, please kindly review @atoato88

@jiatongw
Copy link
Author

/assign @oomichi

Assign you as well since you are the approver of PR #77643. Please kindly review :)

@jiatongw jiatongw force-pushed the e2e/framework/service_util branch 2 times, most recently from 6a0df2d to e5fc1d0 Compare May 16, 2019 18:18
Copy link
Member

@oomichi oomichi left a 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)
Copy link
Member

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?

Copy link
Author

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

Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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.

Copy link
Member

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

Copy link
Author

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)
Copy link
Member

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) {
Copy link
Member

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?

@jiatongw jiatongw force-pushed the e2e/framework/service_util branch from e5fc1d0 to 7175ed2 Compare May 16, 2019 22:58
@jiatongw
Copy link
Author

Keep 2 commits for now, if good to merge, I'll squash them to 1 commit

@jiatongw
Copy link
Author

/test pull-kubernetes-bazel-test

@figo
Copy link
Contributor

figo commented May 16, 2019

Keep 2 commits for now, if good to merge, I'll squash them to 1 commit

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)
Copy link
Member

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?

Copy link
Author

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.

@atoato88
Copy link
Contributor

@jiatongw Thank you for mention. I've confirmed that your comments on next items are OK for me. 😃

  • PortsByPodName
  • PortsByPodUID
  • GetContainerPortsByPodUID
  • ValidateEndpointsPortsOrFail (formerly ValidateEndpointsOrFail)

Signed-off-by: Jiatong Wang <wangjiatong@vmware.com>
@jiatongw jiatongw force-pushed the e2e/framework/service_util branch from 7175ed2 to 76f7645 Compare May 20, 2019 18:49
@oomichi
Copy link
Member

oomichi commented May 21, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 21, 2019
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

1 similar comment
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit 2fd1556 into kubernetes:master May 21, 2019
@jiatongw jiatongw deleted the e2e/framework/service_util branch May 21, 2019 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note-none Denotes a PR that doesn't merit a release note. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants