mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #122811 from neolit123/1.30-v1beta4-timeouts
kubeadm: keep a function with short timeout in idempotency.go
This commit is contained in:
commit
a4a56701b5
@ -72,7 +72,7 @@ func (h *handler) FromDocumentMap(docmap kubeadmapi.DocumentMap) (kubeadmapi.Com
|
||||
// fromConfigMap is an utility function, which will load the value of a key of a config map and use h.FromDocumentMap() to perform the parsing
|
||||
// This is an utility func. Used by the component config support implementations. Don't use it outside of that context.
|
||||
func (h *handler) fromConfigMap(client clientset.Interface, cmName, cmKey string, mustExist bool) (kubeadmapi.ComponentConfig, error) {
|
||||
configMap, err := apiclient.GetConfigMapWithRetry(client, metav1.NamespaceSystem, cmName)
|
||||
configMap, err := apiclient.GetConfigMapWithShortRetry(client, metav1.NamespaceSystem, cmName)
|
||||
if err != nil {
|
||||
if !mustExist && (apierrors.IsNotFound(err) || apierrors.IsForbidden(err)) {
|
||||
klog.Warningf("Warning: No %s config is loaded. Continuing without it: %v", h.GroupVersion, err)
|
||||
|
@ -19,6 +19,7 @@ package apiclient
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
@ -331,13 +332,14 @@ func PatchNode(client clientset.Interface, nodeName string, patchFn func(*v1.Nod
|
||||
return lastError
|
||||
}
|
||||
|
||||
// GetConfigMapWithRetry tries to retrieve a ConfigMap using the given client,
|
||||
// retrying if we get an unexpected error.
|
||||
func GetConfigMapWithRetry(client clientset.Interface, namespace, name string) (*v1.ConfigMap, error) {
|
||||
// GetConfigMapWithShortRetry tries to retrieve a ConfigMap using the given client, retrying for a short
|
||||
// time if it gets an unexpected error. The main usage of this function is in areas of the code that
|
||||
// fallback to a default ConfigMap value in case the one from the API cannot be quickly obtained.
|
||||
func GetConfigMapWithShortRetry(client clientset.Interface, namespace, name string) (*v1.ConfigMap, error) {
|
||||
var cm *v1.ConfigMap
|
||||
var lastError error
|
||||
err := wait.PollUntilContextTimeout(context.Background(),
|
||||
constants.KubernetesAPICallRetryInterval, kubeadmapi.GetActiveTimeouts().KubernetesAPICall.Duration,
|
||||
time.Millisecond*50, time.Millisecond*350,
|
||||
true, func(ctx context.Context) (bool, error) {
|
||||
var err error
|
||||
cm, err = client.CoreV1().ConfigMaps(namespace).Get(ctx, name, metav1.GetOptions{})
|
||||
|
@ -71,7 +71,7 @@ func FetchInitConfigurationFromCluster(client clientset.Interface, printer outpu
|
||||
// getInitConfigurationFromCluster is separate only for testing purposes, don't call it directly, use FetchInitConfigurationFromCluster instead
|
||||
func getInitConfigurationFromCluster(kubeconfigDir string, client clientset.Interface, newControlPlane, skipComponentConfigs bool) (*kubeadmapi.InitConfiguration, error) {
|
||||
// Also, the config map really should be KubeadmConfigConfigMap...
|
||||
configMap, err := apiclient.GetConfigMapWithRetry(client, metav1.NamespaceSystem, constants.KubeadmConfigConfigMap)
|
||||
configMap, err := apiclient.GetConfigMapWithShortRetry(client, metav1.NamespaceSystem, constants.KubeadmConfigConfigMap)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get config map")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user