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

test/e2e/framework: remove direct imports to k8s.io/kubernetes/pkg #89504

Merged
merged 1 commit into from Apr 1, 2020
Merged

test/e2e/framework: remove direct imports to k8s.io/kubernetes/pkg #89504

merged 1 commit into from Apr 1, 2020

Conversation

tanjunchen
Copy link
Member

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Which issue(s) this PR fixes:

ref:#74352

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

None

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

None

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 26, 2020
@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. labels Mar 26, 2020
@tanjunchen
Copy link
Member Author

/priority important-longterm
/kind cleanup

/cc @neolit123 @oomichi
Thank you very much.

@k8s-ci-robot k8s-ci-robot added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Mar 26, 2020
@@ -379,7 +378,8 @@ func FilterNonRestartablePods(pods []*v1.Pod) []*v1.Pod {
}

func isNotRestartAlwaysMirrorPod(p *v1.Pod) bool {
if !kubetypes.IsMirrorPod(p) {
Copy link
Member Author

Choose a reason for hiding this comment

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

// IsMirrorPod returns true if the passed Pod is a Mirror Pod.
func IsMirrorPod(pod *v1.Pod) bool {
	_, ok := pod.Annotations[ConfigMirrorAnnotationKey]
	return ok
}

const (
	ConfigSourceAnnotationKey    = "kubernetes.io/config.source"
	ConfigMirrorAnnotationKey    = v1.MirrorPodAnnotationKey
	ConfigFirstSeenAnnotationKey = "kubernetes.io/config.seen"
	ConfigHashAnnotationKey      = "kubernetes.io/config.hash"
)

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

@@ -302,7 +301,7 @@ func WaitForMatchPodsCondition(c clientset.Interface, opts metav1.ListOptions, d
return fmt.Errorf("Unexpected error: %v", err)
}
if !done {
conditionNotMatch = append(conditionNotMatch, format.Pod(&pod))
Copy link
Member Author

Choose a reason for hiding this comment

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

format.Pod()

// Pod returns a string representing a pod in a consistent human readable format,
// with pod UID as part of the string.
func Pod(pod *v1.Pod) string {
	return PodDesc(pod.Name, pod.Namespace, pod.UID)
}

// PodDesc returns a string representing a pod in a consistent human readable format,
// with pod UID as part of the string.
func PodDesc(podName, podNamespace string, podUID types.UID) string {
	// Use underscore as the delimiter because it is not allowed in pod name
	// (DNS subdomain format), while allowed in the container name format.
	return fmt.Sprintf("%s_%s(%s)", podName, podNamespace, podUID)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm!

@@ -302,7 +301,7 @@ func WaitForMatchPodsCondition(c clientset.Interface, opts metav1.ListOptions, d
return fmt.Errorf("Unexpected error: %v", err)
}
if !done {
conditionNotMatch = append(conditionNotMatch, format.Pod(&pod))
conditionNotMatch = append(conditionNotMatch, fmt.Sprintf("%s_%s(%s)", pod.Name, pod.Namespace, pod.UID))
Copy link
Member

Choose a reason for hiding this comment

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

just noting that this can be problematic, if for some reason the definition in pkg/kubelet/util/format changes!

at the minimum we should include the following comment over the line:

// This should match the format defined in kubernetes/pkg/kubelet/util/format.

Copy link
Member Author

Choose a reason for hiding this comment

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

sure , we can trace this function with comment.
Thanks

@tanjunchen tanjunchen closed this Mar 26, 2020
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 26, 2020
@k8s-ci-robot k8s-ci-robot reopened this Mar 26, 2020
@k8s-ci-robot
Copy link
Contributor

@tanjunchen: Reopened this PR.

In response to this:

/reopen

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 size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 26, 2020
@@ -379,7 +378,8 @@ func FilterNonRestartablePods(pods []*v1.Pod) []*v1.Pod {
}

func isNotRestartAlwaysMirrorPod(p *v1.Pod) bool {
if !kubetypes.IsMirrorPod(p) {
_, ok := p.Annotations[v1.MirrorPodAnnotationKey]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment here, please?
Something simple like "checking that pod is mirror pod" or something.

Copy link
Contributor

Choose a reason for hiding this comment

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

if IsMirrorPod(p) is kind of self-descriptive.
if _, ok := p.Annotations[v1.MirrorPodAnnotationKey]; !ok would do well with some additional context,I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

sure , i will update it. it looks good with comment.

Copy link
Contributor

@alejandrox1 alejandrox1 left a comment

Choose a reason for hiding this comment

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

minor comment but lgtm otherwise.
Thank you @tanjunchen

/retest

@tanjunchen
Copy link
Member Author

@alejandrox1 done

@tanjunchen
Copy link
Member Author

/test pull-kubernetes-verify

1 similar comment
@tanjunchen
Copy link
Member Author

/test pull-kubernetes-verify

@tanjunchen
Copy link
Member Author

Errors from golint:
test/e2e/framework/pod/wait.go:319:6: func name will be used as pod.PodDesc by other packages, and that stutters; consider calling this Desc?

@tanjunchen
Copy link
Member Author

/cc @neolit123

@@ -379,7 +378,8 @@ func FilterNonRestartablePods(pods []*v1.Pod) []*v1.Pod {
}

func isNotRestartAlwaysMirrorPod(p *v1.Pod) bool {
if !kubetypes.IsMirrorPod(p) {
// Checking that pod is mirror pod
Copy link
Member

Choose a reason for hiding this comment

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

// Check if the pod is a mirror pod

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@neolit123
Copy link
Member

see the golint error:

test/e2e/framework/pod/wait.go:319:6: func name will be used as pod.PodDesc by other packages, and that stutters; consider calling this Desc

Please review the above warnings. You can test via "golint" and commit the result.
If the above warnings do not make sense, you can exempt this package from golint
checking by adding it to hack/.golint_failures (if your reviewer is okay with it).

https://prow.k8s.io/view/gcs/kubernetes-jenkins/pr-logs/pull/89504/pull-kubernetes-verify/1243440072976502784

the function should be called something else - e.g. Desc

@@ -301,7 +302,7 @@ func WaitForMatchPodsCondition(c clientset.Interface, opts metav1.ListOptions, d
return fmt.Errorf("Unexpected error: %v", err)
}
if !done {
conditionNotMatch = append(conditionNotMatch, fmt.Sprintf("%s_%s(%s)", pod.Name, pod.Namespace, pod.UID))
conditionNotMatch = append(conditionNotMatch, GetPodDesc(pod.Name, pod.Namespace, pod.UID))
Copy link
Member Author

Choose a reason for hiding this comment

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

see #89504 (comment)
It is has been changed to fmt.Sprintf("%s_%s(%s)" , but i want to update them according to your comment.Thanks.
/cc @neolit123

// GetPodDesc returns a string representing a pod in a consistent human readable format,
// with pod UID as part of the string.
// This should match the format defined in kubernetes/pkg/kubelet/util/format.
func GetPodDesc(podName, podNamespace string, podUID types.UID) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

could we do something more verbose, i.e., GetPodDescription, or PodIdentifier, etc?
GetPodDesc sounds crptic 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

sure

Copy link
Member Author

Choose a reason for hiding this comment

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

/cc @alejandrox1
updated

@tanjunchen
Copy link
Member Author

/test pull-kubernetes-conformance-kind-ipv6-parallel

// GetPodDescription returns a string representing a pod in a consistent human readable format,
// with pod UID as part of the string.
// This should match the format defined in kubernetes/pkg/kubelet/util/format.
func GetPodDescription(podName, podNamespace string, podUID types.UID) string {
Copy link
Member

@SataQiu SataQiu Mar 30, 2020

Choose a reason for hiding this comment

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

If there are no other references, I think this function can be set to private.
SGTM otherwise.

// GetPodDescription returns a string representing a pod in a consistent human readable format,
// with pod UID as part of the string.
// This should match the format defined in kubernetes/pkg/kubelet/util/format.
func GetPodDescription(podName, podNamespace string, podUID types.UID) string {
Copy link
Member

Choose a reason for hiding this comment

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

Why we need to add this function?
This addition doesn't remove import of k/k code from this package.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@tanjunchen Since b748c70 the direct import(format) has been removed already by @SataQiu . So we don't need to change here today.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK , I prefer to this change, revert this . Thanks

Copy link
Member Author

Choose a reason for hiding this comment

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

/cc @SataQiu
/cc @oomichi
updated . could you approve this?Thanks

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 31, 2020
@tanjunchen
Copy link
Member Author

/retest

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.

Thanks for updating.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 31, 2020
@tanjunchen
Copy link
Member Author

/cc @SataQiu

@oomichi
Copy link
Member

oomichi commented Apr 1, 2020

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: oomichi, tanjunchen

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 Apr 1, 2020
@oomichi
Copy link
Member

oomichi commented Apr 1, 2020

/test pull-kubernetes-e2e-kind

@k8s-ci-robot k8s-ci-robot merged commit 6e9bec8 into kubernetes:master Apr 1, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Apr 1, 2020
@tanjunchen tanjunchen deleted the remove-dependency-001 branch April 2, 2020 01:22
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. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. 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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants