mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 04:54:54 +00:00
Use context.Background() directly in kubeadm polling API calls
Replace context.TODO() and poll timeout context propagation with direct context.Background() calls to prevent timeout errors from masking actual API errors. Affects discovery/file.go, phases/upgrade/health.go, and util/apiclient/wait.go for consistent error reporting.
This commit is contained in:
@@ -94,7 +94,7 @@ func ValidateConfigInfo(config *clientcmdapi.Config, discoveryTimeout time.Durat
|
||||
err = wait.PollUntilContextTimeout(context.Background(),
|
||||
constants.DiscoveryRetryInterval, discoveryTimeout,
|
||||
true, func(_ context.Context) (bool, error) {
|
||||
clusterinfoCM, lastError = client.CoreV1().ConfigMaps(metav1.NamespacePublic).Get(context.TODO(), bootstrapapi.ConfigMapClusterInfo, metav1.GetOptions{})
|
||||
clusterinfoCM, lastError = client.CoreV1().ConfigMaps(metav1.NamespacePublic).Get(context.Background(), bootstrapapi.ConfigMapClusterInfo, metav1.GetOptions{})
|
||||
if lastError != nil {
|
||||
if apierrors.IsForbidden(lastError) {
|
||||
// If the request fails with a forbidden error, the cluster admin has not granted access to the cluster info configmap for anonymous clients.
|
||||
|
||||
@@ -327,7 +327,7 @@ func (w *KubeWaiter) WaitForPodsWithLabel(kvLabel string) error {
|
||||
constants.KubernetesAPICallRetryInterval, w.timeout,
|
||||
true, func(_ context.Context) (bool, error) {
|
||||
listOpts := metav1.ListOptions{LabelSelector: kvLabel}
|
||||
pods, err := w.client.CoreV1().Pods(metav1.NamespaceSystem).List(context.TODO(), listOpts)
|
||||
pods, err := w.client.CoreV1().Pods(metav1.NamespaceSystem).List(context.Background(), listOpts)
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintf(w.writer, "[apiclient] Error getting Pods with label selector %q [%v]\n", kvLabel, err)
|
||||
return false, nil
|
||||
@@ -493,7 +493,7 @@ func (w *KubeWaiter) WaitForStaticPodHashChange(nodeName, component, previousHas
|
||||
func getStaticPodSingleHash(client clientset.Interface, nodeName string, component string) (string, error) {
|
||||
|
||||
staticPodName := fmt.Sprintf("%s-%s", component, nodeName)
|
||||
staticPod, err := client.CoreV1().Pods(metav1.NamespaceSystem).Get(context.TODO(), staticPodName, metav1.GetOptions{})
|
||||
staticPod, err := client.CoreV1().Pods(metav1.NamespaceSystem).Get(context.Background(), staticPodName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "failed to obtain static Pod hash for component %s on Node %s", component, nodeName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user