Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(usage): include pvc name in volume events #150

Merged
merged 1 commit into from
Jun 8, 2020
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
1 change: 1 addition & 0 deletions changelogs/unreleased/150-pawanpraka1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include pvc name in volume events
1 change: 1 addition & 0 deletions deploy/operators/centos7/zfs-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ spec:
- "--strict-topology"
- "--enable-leader-election"
- "--leader-election-type=leases"
- "--extra-create-metadata=true"
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
Expand Down
1 change: 1 addition & 0 deletions deploy/operators/centos8/zfs-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ spec:
- "--strict-topology"
- "--enable-leader-election"
- "--leader-election-type=leases"
- "--extra-create-metadata=true"
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
Expand Down
1 change: 1 addition & 0 deletions deploy/yamls/centos7/zfs-driver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ spec:
- "--strict-topology"
- "--enable-leader-election"
- "--leader-election-type=leases"
- "--extra-create-metadata=true"
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
Expand Down
1 change: 1 addition & 0 deletions deploy/yamls/centos8/zfs-driver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ spec:
- "--strict-topology"
- "--enable-leader-election"
- "--leader-election-type=leases"
- "--extra-create-metadata=true"
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
Expand Down
1 change: 1 addition & 0 deletions deploy/yamls/ubuntu/zfs-driver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ spec:
- "--strict-topology"
- "--enable-leader-election"
- "--leader-election-type=leases"
- "--extra-create-metadata=true"
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
Expand Down
1 change: 1 addition & 0 deletions deploy/zfs-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ spec:
- "--strict-topology"
- "--enable-leader-election"
- "--leader-election-type=leases"
- "--extra-create-metadata=true"
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
Expand Down
8 changes: 5 additions & 3 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ var SupportedVolumeCapabilityAccessModes = []*csi.VolumeCapability_AccessMode{
}

// sendEventOrIgnore sends anonymous local-pv provision/delete events
func sendEventOrIgnore(pvName, capacity, stgType, method string) {
func sendEventOrIgnore(pvcName, pvName, capacity, stgType, method string) {
if zfs.GoogleAnalyticsEnabled == "true" {
analytics.New().Build().ApplicationBuilder().
SetVolumeType(stgType, method).
SetDocumentTitle(pvName).
SetCampaignName(pvcName).
SetLabel(analytics.EventLabelCapacity).
SetReplicaCount(analytics.LocalPVReplicaCount, method).
SetCategory(method).
Expand Down Expand Up @@ -204,6 +205,7 @@ func (cs *controller) CreateVolume(
pool := helpers.GetInsensitiveParameter(&parameters, "poolname")
size := req.GetCapacityRange().RequiredBytes
contentSource := req.GetVolumeContentSource()
pvcName := helpers.GetInsensitiveParameter(&parameters, "csi.storage.k8s.io/pvc/name")

if err = cs.validateVolumeCreateReq(req); err != nil {
return nil, err
Expand All @@ -221,7 +223,7 @@ func (cs *controller) CreateVolume(
return nil, status.Error(codes.Internal, err.Error())
}

sendEventOrIgnore(volName, strconv.FormatInt(int64(size), 10), "zfs-localpv", analytics.VolumeProvision)
sendEventOrIgnore(pvcName, volName, strconv.FormatInt(int64(size), 10), "zfs-localpv", analytics.VolumeProvision)

topology := map[string]string{zfs.ZFSTopologyKey: selected}
cntx := map[string]string{zfs.PoolNameKey: pool}
Expand Down Expand Up @@ -268,7 +270,7 @@ func (cs *controller) DeleteVolume(
)
}

sendEventOrIgnore(volumeID, vol.Spec.Capacity, "zfs-localpv", analytics.VolumeDeprovision)
sendEventOrIgnore("", volumeID, vol.Spec.Capacity, "zfs-localpv", analytics.VolumeDeprovision)

deleteResponse:
return csipayload.NewDeleteVolumeResponseBuilder().Build(), nil
Expand Down
1 change: 1 addition & 0 deletions pkg/usage/googleanalytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (u *Usage) Send() {
gaClient.ClientID(u.clientID).
CampaignSource(u.campaignSource).
CampaignContent(u.clientID).
CampaignName(u.campaignName).
ApplicationID(u.appID).
ApplicationVersion(u.appVersion).
DataSource(u.dataSource).
Expand Down
9 changes: 9 additions & 0 deletions pkg/usage/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ type Gclient struct {
// anonymous campaign source
campaignSource string

// anonymous campaign name
campaignName string

// https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ds
// (usecase) node-detail
dataSource string
Expand Down Expand Up @@ -133,6 +136,12 @@ func (u *Usage) SetApplicationName(appName string) *Usage {
return u
}

// SetCampaignName : set the name of the PVC or will be empty.
func (u *Usage) SetCampaignName(campaignName string) *Usage {
u.campaignName = campaignName
return u
}

// SetApplicationID : usecase(OpenEBS/NDM)
func (u *Usage) SetApplicationID(appID string) *Usage {
u.appID = appID
Expand Down