...

Source file src/github.com/linkerd/linkerd2/controller/k8s/k8s.go

Documentation: github.com/linkerd/linkerd2/controller/k8s

     1  package k8s
     2  
     3  import (
     4  	"context"
     5  	"strings"
     6  	"time"
     7  
     8  	"github.com/linkerd/linkerd2/pkg/k8s"
     9  	log "github.com/sirupsen/logrus"
    10  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    11  	"k8s.io/client-go/tools/cache"
    12  )
    13  
    14  const ResyncTime = 10 * time.Minute
    15  
    16  func waitForCacheSync(syncChecks []cache.InformerSynced) {
    17  	ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
    18  	defer cancel()
    19  
    20  	log.Infof("waiting for caches to sync")
    21  	if !cache.WaitForCacheSync(ctx.Done(), syncChecks...) {
    22  		//nolint:gocritic
    23  		log.Fatal("failed to sync caches")
    24  	}
    25  	log.Infof("caches synced")
    26  }
    27  
    28  func isValidRSParent(rs metav1.Object) bool {
    29  	if len(rs.GetOwnerReferences()) != 1 {
    30  		return false
    31  	}
    32  
    33  	validParentKinds := []string{
    34  		k8s.Job,
    35  		k8s.StatefulSet,
    36  		k8s.DaemonSet,
    37  		k8s.Deployment,
    38  	}
    39  
    40  	rsOwner := rs.GetOwnerReferences()[0]
    41  	rsOwnerKind := strings.ToLower(rsOwner.Kind)
    42  	for _, kind := range validParentKinds {
    43  		if rsOwnerKind == kind {
    44  			return true
    45  		}
    46  	}
    47  	return false
    48  }
    49  

View as plain text