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
test/e2e/framework: remove direct imports to k8s.io/kubernetes/pkg #89504
Conversation
/priority important-longterm /cc @neolit123 @oomichi |
@@ -379,7 +378,8 @@ func FilterNonRestartablePods(pods []*v1.Pod) []*v1.Pod { | |||
} | |||
|
|||
func isNotRestartAlwaysMirrorPod(p *v1.Pod) bool { | |||
if !kubetypes.IsMirrorPod(p) { |
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.
// 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"
)
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.
SGTM
test/e2e/framework/pod/wait.go
Outdated
@@ -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)) |
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.
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)
}
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!
test/e2e/framework/pod/wait.go
Outdated
@@ -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)) |
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.
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.
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.
sure , we can trace this function with comment.
Thanks
@tanjunchen: Reopened this PR. 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. |
test/e2e/framework/pod/resource.go
Outdated
@@ -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] |
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.
Could you add a comment here, please?
Something simple like "checking that pod is mirror pod" or something.
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 IsMirrorPod(p)
is kind of self-descriptive.
if _, ok := p.Annotations[v1.MirrorPodAnnotationKey]; !ok
would do well with some additional context,I 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.
sure , i will update it. it looks good with comment.
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 comment but lgtm otherwise.
Thank you @tanjunchen
/retest
@alejandrox1 done |
/test pull-kubernetes-verify |
1 similar comment
/test pull-kubernetes-verify |
Errors from golint: |
/cc @neolit123 |
test/e2e/framework/pod/resource.go
Outdated
@@ -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 |
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.
// Check if the pod is a mirror pod
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.
ok
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
see the golint error:
the function should be called something else - e.g. |
test/e2e/framework/pod/wait.go
Outdated
@@ -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)) |
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.
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
test/e2e/framework/pod/wait.go
Outdated
// 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 { |
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.
could we do something more verbose, i.e., GetPodDescription
, or PodIdentifier
, etc?
GetPodDesc
sounds crptic 🤔
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.
sure
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.
/cc @alejandrox1
updated
/test pull-kubernetes-conformance-kind-ipv6-parallel |
test/e2e/framework/pod/wait.go
Outdated
// 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 { |
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 there are no other references, I think this function can be set to private.
SGTM otherwise.
test/e2e/framework/pod/wait.go
Outdated
// 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 { |
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.
Why we need to add this function?
This addition doesn't remove import of k/k code from this package.
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.
see #89504 (comment)
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.
@tanjunchen Since b748c70 the direct import(format) has been removed already by @SataQiu . So we don't need to change here today.
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.
OK , I prefer to this change, revert this . 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.
/retest |
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 for updating.
/lgtm
/cc @SataQiu |
/approve |
[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 |
/test pull-kubernetes-e2e-kind |
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?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: