update operator default timeout
Signed-off-by: Vacant2333 <rentian.zhou@daocloud.io>
This commit is contained in:
parent
6dea12190e
commit
a6de63740b
|
@ -12,8 +12,8 @@ import (
|
||||||
"github.com/karmada-io/karmada/operator/pkg/util/apiclient"
|
"github.com/karmada-io/karmada/operator/pkg/util/apiclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EnsureWebhookconfiguration creates karmada webhook mutatingWebhookConfiguration and validatingWebhookConfiguration
|
// EnsureWebhookConfiguration creates karmada webhook mutatingWebhookConfiguration and validatingWebhookConfiguration
|
||||||
func EnsureWebhookconfiguration(client clientset.Interface, namespace, name, caBundle string) error {
|
func EnsureWebhookConfiguration(client clientset.Interface, namespace, name, caBundle string) error {
|
||||||
if err := mutatingWebhookConfiguration(client, namespace, name, caBundle); err != nil {
|
if err := mutatingWebhookConfiguration(client, namespace, name, caBundle); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package tasks
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
|
@ -104,7 +103,7 @@ func runWaitKarmadaAPIServer(r workflow.RunData) error {
|
||||||
return errors.New("wait-KarmadaAPIServer task invoked with an invalid data struct")
|
return errors.New("wait-KarmadaAPIServer task invoked with an invalid data struct")
|
||||||
}
|
}
|
||||||
|
|
||||||
waiter := apiclient.NewKarmadaWaiter(data.ControlplaneConfig(), data.RemoteClient(), time.Second*30)
|
waiter := apiclient.NewKarmadaWaiter(data.ControlplaneConfig(), data.RemoteClient(), componentBeReadyTimeout)
|
||||||
|
|
||||||
err := waiter.WaitForSomePods(karmadaApiserverLabels.String(), data.GetNamespace(), 1)
|
err := waiter.WaitForSomePods(karmadaApiserverLabels.String(), data.GetNamespace(), 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -147,11 +146,11 @@ func runWaitKarmadaAggregatedAPIServer(r workflow.RunData) error {
|
||||||
return errors.New("wait-KarmadaAggregatedAPIServer task invoked with an invalid data struct")
|
return errors.New("wait-KarmadaAggregatedAPIServer task invoked with an invalid data struct")
|
||||||
}
|
}
|
||||||
|
|
||||||
waiter := apiclient.NewKarmadaWaiter(data.ControlplaneConfig(), data.RemoteClient(), time.Second*30)
|
waiter := apiclient.NewKarmadaWaiter(data.ControlplaneConfig(), data.RemoteClient(), componentBeReadyTimeout)
|
||||||
|
|
||||||
err := waiter.WaitForSomePods(karmadaAggregatedAPIServerLabels.String(), data.GetNamespace(), 1)
|
err := waiter.WaitForSomePods(karmadaAggregatedAPIServerLabels.String(), data.GetNamespace(), 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("waiting for karmada-apiserver to ready timeout, err: %w", err)
|
return fmt.Errorf("waiting for karmada-aggregated-apiserver to ready timeout, err: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
klog.V(2).InfoS("[wait-KarmadaAggregatedAPIServer] the karmada-aggregated-apiserver is ready", "karmada", klog.KObj(data))
|
klog.V(2).InfoS("[wait-KarmadaAggregatedAPIServer] the karmada-aggregated-apiserver is ready", "karmada", klog.KObj(data))
|
||||||
|
|
|
@ -3,7 +3,6 @@ package tasks
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
|
@ -72,12 +71,12 @@ func runWaitEtcd(r workflow.RunData) error {
|
||||||
return errors.New("wait-etcd task invoked with an invalid data struct")
|
return errors.New("wait-etcd task invoked with an invalid data struct")
|
||||||
}
|
}
|
||||||
|
|
||||||
waiter := apiclient.NewKarmadaWaiter(data.ControlplaneConfig(), data.RemoteClient(), time.Second*30)
|
waiter := apiclient.NewKarmadaWaiter(data.ControlplaneConfig(), data.RemoteClient(), componentBeReadyTimeout)
|
||||||
|
|
||||||
// wait etcd, karmada apiserver and aggregated apiserver to ready
|
// wait etcd, karmada apiserver and aggregated apiserver to ready
|
||||||
// as long as a replica of pod is ready, we consider the service available.
|
// as long as a replica of pod is ready, we consider the service available.
|
||||||
if err := waiter.WaitForSomePods(etcdLabels.String(), data.GetNamespace(), 1); err != nil {
|
if err := waiter.WaitForSomePods(etcdLabels.String(), data.GetNamespace(), 1); err != nil {
|
||||||
return fmt.Errorf("waiting for etcd to ready timeout, err: %w", err)
|
return fmt.Errorf("waiting for karmada-etcd to ready timeout, err: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
klog.V(2).InfoS("[wait-etcd] the etcd pods is ready", "karmada", klog.KObj(data))
|
klog.V(2).InfoS("[wait-etcd] the etcd pods is ready", "karmada", klog.KObj(data))
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
|
@ -176,7 +175,7 @@ func runWebhookConfiguration(r workflow.RunData) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
caBase64 := base64.StdEncoding.EncodeToString(cert.CertData())
|
caBase64 := base64.StdEncoding.EncodeToString(cert.CertData())
|
||||||
return webhookconfiguration.EnsureWebhookconfiguration(
|
return webhookconfiguration.EnsureWebhookConfiguration(
|
||||||
data.KarmadaClient(),
|
data.KarmadaClient(),
|
||||||
data.GetNamespace(),
|
data.GetNamespace(),
|
||||||
data.GetName(),
|
data.GetName(),
|
||||||
|
@ -200,7 +199,7 @@ func runAPIService(r workflow.RunData) error {
|
||||||
return fmt.Errorf("failed to apply aggregated APIService resource to karmada controlplane, err: %w", err)
|
return fmt.Errorf("failed to apply aggregated APIService resource to karmada controlplane, err: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
waiter := apiclient.NewKarmadaWaiter(config, nil, time.Second*20)
|
waiter := apiclient.NewKarmadaWaiter(config, nil, componentBeReadyTimeout)
|
||||||
if err := apiclient.TryRunCommand(waiter.WaitForAPIService, 3); err != nil {
|
if err := apiclient.TryRunCommand(waiter.WaitForAPIService, 3); err != nil {
|
||||||
return fmt.Errorf("the APIService is unhealthy, err: %w", err)
|
return fmt.Errorf("the APIService is unhealthy, err: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,16 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// The timeout for wait each component be ready
|
||||||
|
// It includes the time for pulling the component image.
|
||||||
|
componentBeReadyTimeout = 120 * time.Second
|
||||||
|
|
||||||
etcdLabels = labels.Set{"karmada-app": constants.Etcd}
|
etcdLabels = labels.Set{"karmada-app": constants.Etcd}
|
||||||
karmadaApiserverLabels = labels.Set{"karmada-app": constants.KarmadaAPIServer}
|
karmadaApiserverLabels = labels.Set{"karmada-app": constants.KarmadaAPIServer}
|
||||||
karmadaAggregatedAPIServerLabels = labels.Set{"karmada-app": constants.KarmadaAggregatedAPIServer}
|
karmadaAggregatedAPIServerLabels = labels.Set{"karmada-app": constants.KarmadaAggregatedAPIServer}
|
||||||
kubeControllerManagerLabels = labels.Set{"karmada-app": constants.KubeControllerManager}
|
kubeControllerManagerLabels = labels.Set{"karmada-app": constants.KubeControllerManager}
|
||||||
karmadaControllerManagerLabels = labels.Set{"karmada-app": constants.KarmadaControllerManager}
|
karmadaControllerManagerLabels = labels.Set{"karmada-app": constants.KarmadaControllerManager}
|
||||||
karmadaSchedulerLablels = labels.Set{"karmada-app": constants.KarmadaScheduler}
|
karmadaSchedulerLabels = labels.Set{"karmada-app": constants.KarmadaScheduler}
|
||||||
karmadaWebhookLabels = labels.Set{"karmada-app": constants.KarmadaWebhook}
|
karmadaWebhookLabels = labels.Set{"karmada-app": constants.KarmadaWebhook}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -38,7 +42,7 @@ func runWaitApiserver(r workflow.RunData) error {
|
||||||
}
|
}
|
||||||
klog.V(4).InfoS("[check-apiserver-health] Running task", "karmada", klog.KObj(data))
|
klog.V(4).InfoS("[check-apiserver-health] Running task", "karmada", klog.KObj(data))
|
||||||
|
|
||||||
waiter := apiclient.NewKarmadaWaiter(data.ControlplaneConfig(), data.RemoteClient(), time.Second*30)
|
waiter := apiclient.NewKarmadaWaiter(data.ControlplaneConfig(), data.RemoteClient(), componentBeReadyTimeout)
|
||||||
|
|
||||||
// check whether the karmada apiserver is health.
|
// check whether the karmada apiserver is health.
|
||||||
if err := apiclient.TryRunCommand(waiter.WaitForAPI, 3); err != nil {
|
if err := apiclient.TryRunCommand(waiter.WaitForAPI, 3); err != nil {
|
||||||
|
@ -57,7 +61,7 @@ func NewWaitControlPlaneTask() workflow.Task {
|
||||||
Tasks: []workflow.Task{
|
Tasks: []workflow.Task{
|
||||||
newWaitControlPlaneSubTask("KubeControllerManager", kubeControllerManagerLabels),
|
newWaitControlPlaneSubTask("KubeControllerManager", kubeControllerManagerLabels),
|
||||||
newWaitControlPlaneSubTask("KarmadaControllerManager", karmadaControllerManagerLabels),
|
newWaitControlPlaneSubTask("KarmadaControllerManager", karmadaControllerManagerLabels),
|
||||||
newWaitControlPlaneSubTask("KarmadaScheduler", karmadaSchedulerLablels),
|
newWaitControlPlaneSubTask("KarmadaScheduler", karmadaSchedulerLabels),
|
||||||
newWaitControlPlaneSubTask("KarmadaWebhook", karmadaWebhookLabels),
|
newWaitControlPlaneSubTask("KarmadaWebhook", karmadaWebhookLabels),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -87,7 +91,7 @@ func runWaitControlPlaneSubTask(component string, lables labels.Set) func(r work
|
||||||
return errors.New("wait-controlPlane task invoked with an invalid data struct")
|
return errors.New("wait-controlPlane task invoked with an invalid data struct")
|
||||||
}
|
}
|
||||||
|
|
||||||
waiter := apiclient.NewKarmadaWaiter(nil, data.RemoteClient(), time.Second*120)
|
waiter := apiclient.NewKarmadaWaiter(nil, data.RemoteClient(), componentBeReadyTimeout)
|
||||||
if err := waiter.WaitForSomePods(lables.String(), data.GetNamespace(), 1); err != nil {
|
if err := waiter.WaitForSomePods(lables.String(), data.GetNamespace(), 1); err != nil {
|
||||||
return fmt.Errorf("waiting for %s to ready timeout, err: %w", component, err)
|
return fmt.Errorf("waiting for %s to ready timeout, err: %w", component, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
|
|
||||||
var errAllocated = errors.New("provided port is already allocated")
|
var errAllocated = errors.New("provided port is already allocated")
|
||||||
|
|
||||||
// NewCRDsClient is to create a clientset ClientSet
|
// NewCRDsClient is to create a Clientset
|
||||||
func NewCRDsClient(c *rest.Config) (*crdsclient.Clientset, error) {
|
func NewCRDsClient(c *rest.Config) (*crdsclient.Clientset, error) {
|
||||||
return crdsclient.NewForConfig(c)
|
return crdsclient.NewForConfig(c)
|
||||||
}
|
}
|
||||||
|
@ -207,26 +207,26 @@ func PatchCustomResourceDefinition(client *crdsclient.Clientset, name string, da
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOrUpdateStatefulSet creates a StatefulSet if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.
|
// CreateOrUpdateStatefulSet creates a StatefulSet if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.
|
||||||
func CreateOrUpdateStatefulSet(client clientset.Interface, statefuleSet *appsv1.StatefulSet) error {
|
func CreateOrUpdateStatefulSet(client clientset.Interface, statefulSet *appsv1.StatefulSet) error {
|
||||||
_, err := client.AppsV1().StatefulSets(statefuleSet.GetNamespace()).Create(context.TODO(), statefuleSet, metav1.CreateOptions{})
|
_, err := client.AppsV1().StatefulSets(statefulSet.GetNamespace()).Create(context.TODO(), statefulSet, metav1.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !apierrors.IsAlreadyExists(err) {
|
if !apierrors.IsAlreadyExists(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
older, err := client.AppsV1().StatefulSets(statefuleSet.GetNamespace()).Get(context.TODO(), statefuleSet.GetName(), metav1.GetOptions{})
|
older, err := client.AppsV1().StatefulSets(statefulSet.GetNamespace()).Get(context.TODO(), statefulSet.GetName(), metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
statefuleSet.ResourceVersion = older.ResourceVersion
|
statefulSet.ResourceVersion = older.ResourceVersion
|
||||||
_, err = client.AppsV1().StatefulSets(statefuleSet.GetNamespace()).Update(context.TODO(), statefuleSet, metav1.UpdateOptions{})
|
_, err = client.AppsV1().StatefulSets(statefulSet.GetNamespace()).Update(context.TODO(), statefulSet, metav1.UpdateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
klog.V(5).InfoS("Successfully created or updated statefulset", "statefulset", statefuleSet.GetName)
|
klog.V(5).InfoS("Successfully created or updated statefulset", "statefulset", statefulSet.GetName)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ func DeleteDeploymentIfHasLabels(client clientset.Interface, name, namespace str
|
||||||
return client.AppsV1().Deployments(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{})
|
return client.AppsV1().Deployments(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteStatefulSetIfHasLabels deletes a StatefuleSet that exists the given labels.
|
// DeleteStatefulSetIfHasLabels deletes a StatefulSet that exists the given labels.
|
||||||
func DeleteStatefulSetIfHasLabels(client clientset.Interface, name, namespace string, ls labels.Set) error {
|
func DeleteStatefulSetIfHasLabels(client clientset.Interface, name, namespace string, ls labels.Set) error {
|
||||||
sts, err := client.AppsV1().StatefulSets(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
sts, err := client.AppsV1().StatefulSets(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -19,8 +19,7 @@ func GetControlplaneEndpoint(address, port string) (string, error) {
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
return "", fmt.Errorf("invalid value `%s` given for address", address)
|
return "", fmt.Errorf("invalid value `%s` given for address", address)
|
||||||
}
|
}
|
||||||
url := formatURL(ip.String(), port)
|
return formatURL(ip.String(), port).String(), nil
|
||||||
return url.String(), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// formatURL takes a host and a port string and creates a net.URL using https scheme
|
// formatURL takes a host and a port string and creates a net.URL using https scheme
|
||||||
|
|
Loading…
Reference in New Issue