Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/hub-net-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/rand"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
Expand Down Expand Up @@ -55,6 +56,7 @@ func init() {

func main() {
flag.Parse()
rand.Seed(time.Now().UnixNano())

handleExitFunc := func() {
klog.Flush()
Expand Down
3 changes: 3 additions & 0 deletions cmd/mcs-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
"os/signal"
"sync"
"syscall"
"time"

"k8s.io/apimachinery/pkg/util/rand"
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
Expand Down Expand Up @@ -64,6 +66,7 @@ func init() {

func main() {
flag.Parse()
rand.Seed(time.Now().UnixNano())

handleExitFunc := func() {
klog.Flush()
Expand Down
3 changes: 3 additions & 0 deletions cmd/member-net-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import (
"os/signal"
"sync"
"syscall"
"time"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/rand"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
Expand Down Expand Up @@ -70,6 +72,7 @@ func init() {

func main() {
flag.Parse()
rand.Seed(time.Now().UnixNano())

handleExitFunc := func() {
klog.Flush()
Expand Down
7 changes: 1 addition & 6 deletions pkg/common/uniquename/uniquename.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ package uniquename

import (
"fmt"
"math/rand"
"strings"
"time"
"unicode"

"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/validation"
)
Expand All @@ -31,10 +30,6 @@ const (
uuidLength = 5
)

func init() {
rand.Seed(time.Now().UnixNano())
}

// minInt returns the smaller one of two integers.
func minInt(a, b int) int {
if a < b {
Expand Down
10 changes: 9 additions & 1 deletion pkg/controllers/member/internalmembercluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -31,6 +32,9 @@ import (
const (
conditionReasonJoined = "AgentJoined"
conditionReasonLeft = "AgentLeft"

// we add +-5% jitter
jitterPercent = 10
)

// Reconciler reconciles a InternalMemberCluster object.
Expand Down Expand Up @@ -80,7 +84,11 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
if err := r.updateAgentStatus(ctx, &imc, agentStatus); err != nil {
return ctrl.Result{}, err
}
return ctrl.Result{RequeueAfter: time.Second * time.Duration(imc.Spec.HeartbeatPeriodSeconds)}, nil
// add jitter to the heart beat to mitigate the herding of multiple agents
hbInterval := 1000 * imc.Spec.HeartbeatPeriodSeconds
jitterRange := int64(hbInterval*jitterPercent) / 100
requeueAfter := time.Millisecond * (time.Duration(hbInterval) + time.Duration(rand.Int63nRange(0, jitterRange)-jitterRange/2))
return ctrl.Result{RequeueAfter: requeueAfter}, nil
case fleetv1alpha1.ClusterStateLeave:
if r.AgentType == fleetv1alpha1.MultiClusterServiceAgent {
if err := r.cleanupMCSRelatedResources(ctx); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/multiclusterservice/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (r *Reconciler) updateMultiClusterServiceStatus(ctx context.Context, mcs *f
Status: metav1.ConditionUnknown,
Reason: conditionReasonUnknownServiceImport,
ObservedGeneration: mcs.GetGeneration(),
Message: "importing service; if the condition remains for a while, please verify that service has been exported",
Message: "importing service; if the condition remains for a while, please verify that service has been exported or service has been exported by other multiClusterService",
}
}

Expand Down