Skip to content

Commit

Permalink
feat(analytics): add heartbeat pinger
Browse files Browse the repository at this point in the history
Signed-off-by: Niladri Halder <[email protected]>
  • Loading branch information
niladrih committed Jun 24, 2024
1 parent 45b61d1 commit 40a3c72
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/kubernetes-csi/csi-lib-utils v0.9.0
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.27.4
github.com/openebs/google-analytics-4 v0.1.0
github.com/openebs/google-analytics-4 v0.2.0
github.com/openebs/lib-csi v0.8.2
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.15.1
Expand All @@ -31,7 +31,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Expand Down Expand Up @@ -310,8 +310,8 @@ github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfad
github.com/onsi/gomega v1.27.3/go.mod h1:5vG284IBtfDAmDyrK+eGyZmUgUlmi+Wngqo557cZ6Gw=
github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E=
github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ=
github.com/openebs/google-analytics-4 v0.1.0 h1:6aUDbQoh1ezb+NU/MkapFKffogW4QK3WYt8g2UmENe8=
github.com/openebs/google-analytics-4 v0.1.0/go.mod h1:3DkQfGCo79pZhL76Xtg0/R7LNLMttW6Bm/uP0yiZQHU=
github.com/openebs/google-analytics-4 v0.2.0 h1:zokvnWat73QscmEsU/LH/zCZsTCMz0x6bJ4qUwMHoNE=
github.com/openebs/google-analytics-4 v0.2.0/go.mod h1:lKjvRs6HAYOlOTYjtOUp35iTutoXzRL0hOeVAvLAfZI=
github.com/openebs/lib-csi v0.8.2 h1:HmoiZX3VXFPglwqnRPnRus7K58ixDWBa19OpPZGk2Ws=
github.com/openebs/lib-csi v0.8.2/go.mod h1:4yc0Q1thH+oU80z73zGELfrOw2yeLdLNIRmcrxBxsBc=
github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34=
Expand Down
38 changes: 17 additions & 21 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,33 @@ import (
"strings"
"time"

"github.com/container-storage-interface/spec/lib/go/csi"
analytics "github.com/openebs/google-analytics-4/usage"
k8sapi "github.com/openebs/lib-csi/pkg/client/k8s"
"github.com/openebs/lib-csi/pkg/common/errors"
"github.com/openebs/lib-csi/pkg/csipv"
corev1 "k8s.io/api/core/v1"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

clientset "github.com/openebs/lvm-localpv/pkg/generated/clientset/internalclientset"
informers "github.com/openebs/lvm-localpv/pkg/generated/informer/externalversions"
"github.com/openebs/lvm-localpv/pkg/version"

"github.com/container-storage-interface/spec/lib/go/csi"
schd "github.com/openebs/lib-csi/pkg/scheduler"
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
corev1 "k8s.io/api/core/v1"
k8serror "k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/labels"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

"github.com/openebs/lib-csi/pkg/common/errors"
schd "github.com/openebs/lib-csi/pkg/scheduler"

analytics "github.com/openebs/google-analytics-4/usage"
lvmapi "github.com/openebs/lvm-localpv/pkg/apis/openebs.io/lvm/v1alpha1"
"github.com/openebs/lvm-localpv/pkg/builder/snapbuilder"
"github.com/openebs/lvm-localpv/pkg/builder/volbuilder"
clientset "github.com/openebs/lvm-localpv/pkg/generated/clientset/internalclientset"
informers "github.com/openebs/lvm-localpv/pkg/generated/informer/externalversions"
"github.com/openebs/lvm-localpv/pkg/lvm"
csipayload "github.com/openebs/lvm-localpv/pkg/response"
"github.com/openebs/lvm-localpv/pkg/version"
)

// size constants
Expand All @@ -63,12 +60,11 @@ const (

// Ping event is sent periodically
Ping string = "lvm-ping"

// Heartbeat message.
Heartbeat string = "lvm-heartbeat"
// DefaultCASType Event application name constant for volume event
DefaultCASType string = "lvm-localpv"

// LocalPVReplicaCount is the constant used by usage to represent
// replication factor in LocalPV
// LocalPVReplicaCount is the constant used by usage to represent replication factor in LocalPV
LocalPVReplicaCount string = "1"
)

Expand Down Expand Up @@ -115,8 +111,7 @@ func sendEventOrIgnore(pvcName, pvName, capacity, method string) {
analytics.New().CommonBuild(DefaultCASType).ApplicationBuilder().
SetVolumeName(pvName).
SetVolumeClaimName(pvcName).
SetLabel(analytics.EventLabelCapacity).
SetReplicaCount(LocalPVReplicaCount, method).
SetReplicaCount(LocalPVReplicaCount).
SetCategory(method).
SetVolumeCapacity(capacity).Send()
}
Expand Down Expand Up @@ -244,7 +239,8 @@ func (cs *controller) init() error {
if lvm.GoogleAnalyticsEnabled == "true" {
analytics.RegisterVersionGetter(version.GetVersionDetails)
analytics.New().CommonBuild(DefaultCASType).InstallBuilder(true).Send()
go analytics.PingCheck(DefaultCASType, Ping)
go analytics.PingCheck(DefaultCASType, Ping, false)
go analytics.PingCheck(DefaultCASType, Heartbeat, true)
}

if cs.leakProtection, err = csipv.NewLeakProtectionController(kubeClient,
Expand Down

0 comments on commit 40a3c72

Please sign in to comment.