diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 981ea740..586160bd 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -45,9 +45,6 @@ jobs: - name: Format test run: make format - - name: License test - run: make license-check - - name: bootstrap run: make bootstrap diff --git a/Makefile b/Makefile index 3fe72c29..0bb505dd 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,3 @@ -# Copyright 2020 The OpenEBS Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - # list only csi source code directories PACKAGES = $(shell go list ./... | grep -v 'pkg/generated') @@ -90,7 +76,7 @@ export DBUILD_ARGS=--build-arg DBUILD_DATE=${DBUILD_DATE} --build-arg DBUILD_REP CSI_DRIVER=lvm-driver .PHONY: all -all: license-check golint test manifests lvm-driver-image +all: golint test manifests lvm-driver-image .PHONY: clean clean: @@ -276,17 +262,4 @@ golint: @echo "--------------------------------" @echo "" -.PHONY: license-check -license-check: - @echo "--> Checking license header..." - @licRes=$$(for file in $$(find . -type f -regex '.*\.sh\|.*\.go\|.*Docker.*\|.*\Makefile*') ; do \ - awk 'NR<=5' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \ - done); \ - if [ -n "$${licRes}" ]; then \ - echo "license header checking failed:"; echo "$${licRes}"; \ - exit 1; \ - fi - @echo "--> Done checking license." - @echo - include Makefile.buildx.mk diff --git a/go.mod b/go.mod index 11952fd5..db4d5480 100644 --- a/go.mod +++ b/go.mod @@ -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.1 github.com/openebs/lib-csi v0.8.2 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.15.1 @@ -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 diff --git a/go.sum b/go.sum index ca2a07cd..167a0e06 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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.1 h1:+DgJjcPM3uVyWp9VxvNQgNXCWWv0OFhopijFdPVVX9Q= +github.com/openebs/google-analytics-4 v0.2.1/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= diff --git a/pkg/driver/controller.go b/pkg/driver/controller.go index 38b53f39..e0708321 100644 --- a/pkg/driver/controller.go +++ b/pkg/driver/controller.go @@ -1,19 +1,3 @@ -/* -Copyright © 2019 The OpenEBS Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - package driver import ( @@ -22,36 +6,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 @@ -63,12 +44,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" ) @@ -115,8 +95,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() } @@ -244,7 +223,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, diff --git a/tests/utils.go b/tests/utils.go index 99de47d7..edd48042 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -1,19 +1,3 @@ -/* -Copyright 2021 The OpenEBS Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - package tests import ( @@ -25,6 +9,11 @@ import ( "github.com/onsi/gomega" "github.com/openebs/lib-csi/pkg/csipv" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/openebs/lvm-localpv/pkg/lvm" "github.com/openebs/lvm-localpv/tests/container" "github.com/openebs/lvm-localpv/tests/deploy" @@ -33,10 +22,6 @@ import ( "github.com/openebs/lvm-localpv/tests/pts" "github.com/openebs/lvm-localpv/tests/pvc" "github.com/openebs/lvm-localpv/tests/sc" - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - k8serrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/api/resource" )