/
monitoring.go
56 lines (44 loc) · 1.52 KB
/
monitoring.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Package monitoring wraps the informer logic used to observe the peering process.
package monitoring
import (
"context"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/dynamic/dynamicinformer"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
"github.com/liqotech/liqo-benchmarks/peering/peering-measurer/pkg/measurer"
)
const resyncPeriod = 0
var M func() *measurer.GlobalMeasurer
// Redefined here, as part of an internal Liqo package.
const (
replicationLabelValueLocal = "true"
replicationLabelValueRemote = "false"
certificateAvailableLabel = "discovery.liqo.io/certificate-available"
)
func Start(ctx context.Context, client dynamic.Interface, completion chan<- struct{}) {
klog.V(1).Info("Configuring the measurer")
m := measurer.NewMeasurer(completion)
M = func() *measurer.GlobalMeasurer {
return m
}
klog.V(1).Info("Configuring the informers")
factory := dynamicinformer.NewDynamicSharedInformerFactory(client, resyncPeriod)
prepareForeignClusterInformer(factory)
prepareSecretsInformer(factory)
prepareResourceRequestInformer(factory)
prepareResourceOfferInformer(factory)
prepareNetworkConfigInformer(factory)
prepareTunnelEndpointInformer(factory)
preparePodsInformer(factory)
prepareNodesInformer(factory)
klog.V(1).Info("Starting the informer factory")
factory.Start(ctx.Done())
klog.V(1).Info("Waiting for cache sync")
factory.WaitForCacheSync(ctx.Done())
klog.V(1).Info("Cache correctly sync'ed")
}
func namespacedName(obj interface{}) string {
key, _ := cache.MetaNamespaceKeyFunc(obj)
return key
}