mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
e2e pod: remove dead code
This commit is contained in:
parent
3bb735e6fa
commit
1bd1167d56
@ -572,15 +572,3 @@ func IsPodActive(p *v1.Pod) bool {
|
|||||||
v1.PodFailed != p.Status.Phase &&
|
v1.PodFailed != p.Status.Phase &&
|
||||||
p.DeletionTimestamp == nil
|
p.DeletionTimestamp == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func podIdentifier(namespace, name string) string {
|
|
||||||
return fmt.Sprintf("%s/%s", namespace, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
func identifier(pod *v1.Pod) string {
|
|
||||||
id := podIdentifier(pod.Namespace, pod.Name)
|
|
||||||
if pod.UID != "" {
|
|
||||||
id += fmt.Sprintf("(%s)", pod.UID)
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
|
@ -35,7 +35,6 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
apitypes "k8s.io/apimachinery/pkg/types"
|
apitypes "k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/kubectl/pkg/util/podutils"
|
"k8s.io/kubectl/pkg/util/podutils"
|
||||||
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
||||||
@ -69,45 +68,6 @@ const (
|
|||||||
|
|
||||||
type podCondition func(pod *v1.Pod) (bool, error)
|
type podCondition func(pod *v1.Pod) (bool, error)
|
||||||
|
|
||||||
type timeoutError struct {
|
|
||||||
msg string
|
|
||||||
observedObjects []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *timeoutError) Error() string {
|
|
||||||
return e.msg
|
|
||||||
}
|
|
||||||
|
|
||||||
func TimeoutError(msg string, observedObjects ...interface{}) *timeoutError {
|
|
||||||
return &timeoutError{
|
|
||||||
msg: msg,
|
|
||||||
observedObjects: observedObjects,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// maybeTimeoutError returns a TimeoutError if err is a timeout. Otherwise, wrap err.
|
|
||||||
// taskFormat and taskArgs should be the task being performed when the error occurred,
|
|
||||||
// e.g. "waiting for pod to be running".
|
|
||||||
func maybeTimeoutError(err error, taskFormat string, taskArgs ...interface{}) error {
|
|
||||||
if IsTimeout(err) {
|
|
||||||
return TimeoutError(fmt.Sprintf("timed out while "+taskFormat, taskArgs...))
|
|
||||||
} else if err != nil {
|
|
||||||
return fmt.Errorf("error while %s: %w", fmt.Sprintf(taskFormat, taskArgs...), err)
|
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func IsTimeout(err error) bool {
|
|
||||||
if err == wait.ErrWaitTimeout {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if _, ok := err.(*timeoutError); ok {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// BeRunningNoRetries verifies that a pod starts running. It's a permanent
|
// BeRunningNoRetries verifies that a pod starts running. It's a permanent
|
||||||
// failure when the pod enters some other permanent phase.
|
// failure when the pod enters some other permanent phase.
|
||||||
func BeRunningNoRetries() types.GomegaMatcher {
|
func BeRunningNoRetries() types.GomegaMatcher {
|
||||||
@ -812,23 +772,3 @@ func WaitForContainerRunning(ctx context.Context, c clientset.Interface, namespa
|
|||||||
return false, nil
|
return false, nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleWaitingAPIErrror handles an error from an API request in the context of a Wait function.
|
|
||||||
// If the error is retryable, sleep the recommended delay and ignore the error.
|
|
||||||
// If the error is terminal, return it.
|
|
||||||
func handleWaitingAPIError(err error, retryNotFound bool, taskFormat string, taskArgs ...interface{}) (bool, error) {
|
|
||||||
taskDescription := fmt.Sprintf(taskFormat, taskArgs...)
|
|
||||||
if retryNotFound && apierrors.IsNotFound(err) {
|
|
||||||
framework.Logf("Ignoring NotFound error while " + taskDescription)
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
if retry, delay := framework.ShouldRetry(err); retry {
|
|
||||||
framework.Logf("Retryable error while %s, retrying after %v: %v", taskDescription, delay, err)
|
|
||||||
if delay > 0 {
|
|
||||||
time.Sleep(delay)
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
framework.Logf("Encountered non-retryable error while %s: %v", taskDescription, err)
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user