Skip to content

Commit 8d9b9fd

Browse files
committed
fix: move the tag adding logic inside blobfuse-proxy code
This commit moves the logic to add tag to blobfuse-proxy service. If user specifies --telemetry=tire1 as mount option then add azpartner-aks/v1.28.0 value as comma separated value to user provided version (--telemetry=azpartner-aks/v1.28.0,tire1) Signed-off-by: [email protected] <[email protected]>
1 parent 2b4e9c8 commit 8d9b9fd

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,4 @@ delete-metrics-svc:
178178

179179
.PHONY: blobfuse-proxy
180180
blobfuse-proxy:
181-
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -mod vendor -ldflags="-s -w" -o _output/${ARCH}/blobfuse-proxy ./pkg/blobfuse-proxy
181+
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -mod vendor -ldflags="-s -w -X ${PKG}/pkg/blobfuse-proxy/server.driverVersion=${IMAGE_VERSION}" -o _output/${ARCH}/blobfuse-proxy ./pkg/blobfuse-proxy

pkg/blob/nodeserver.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,6 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
409409
}
410410

411411
// Get mountOptions that the volume will be formatted and mounted with
412-
if protocol == Fuse2 {
413-
// Adding telemetry tag to know that blob is been mounted through AKS
414-
mountFlags = util.JoinMountOptions(mountFlags, []string{fmt.Sprintf("--telemetry=azpartner-aks/%s", d.Version)})
415-
}
416412
mountOptions := mountFlags
417413
if ephemeralVol {
418414
mountOptions = util.JoinMountOptions(mountOptions, strings.Split(ephemeralVolMountOptions, ","))

pkg/blobfuse-proxy/server/server.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import (
3434
)
3535

3636
var (
37-
mutex sync.Mutex
37+
mutex sync.Mutex
38+
driverVersion string
3839
)
3940

4041
type BlobfuseVersion int
@@ -71,6 +72,7 @@ func (server *MountServer) MountAzureBlob(_ context.Context,
7172
var cmd *exec.Cmd
7273
var result mount_azure_blob.MountAzureBlobResponse
7374
if protocol == blob.Fuse2 || server.blobfuseVersion == BlobfuseV2 {
75+
telemetryTag := "azpartner-aks/" + driverVersion
7476
args = "mount " + args
7577
// add this arg for blobfuse2 to solve the issue:
7678
// https://github.com/Azure/azure-storage-fuse/issues/1015
@@ -82,6 +84,21 @@ func (server *MountServer) MountAzureBlob(_ context.Context,
8284
klog.V(2).Infof("append --disable-version-check to mount args")
8385
args = args + " " + "--disable-version-check=true"
8486
}
87+
// Adding telemetry tag to know that blob is been mounted through AKS CSI Driver
88+
if !strings.Contains(args, "--telemetry") {
89+
klog.V(2).Infof("append --telemetry=%s to mount args", telemetryTag)
90+
args = args + " " + "--telemetry=" + telemetryTag
91+
} else {
92+
// If telemetry flag is already present, check for aks tag if not present
93+
// then user might have their own telemetry tag append aks tag to it
94+
if !strings.Contains(args, "azpartner-aks") {
95+
splitedArgs := strings.Split(args, "--telemetry=")
96+
if len(splitedArgs) == 2 {
97+
args = splitedArgs[0] + " --telemetry=" + telemetryTag + "," + splitedArgs[1]
98+
}
99+
klog.V(2).Infof("updated --telemetry tag in mount args: %s", args)
100+
}
101+
}
85102
args = util.TrimDuplicatedSpace(args)
86103
klog.V(2).Infof("mount with v2, protocol: %s, args: %s", protocol, args)
87104
cmd = exec.Command("blobfuse2", strings.Split(args, " ")...)

0 commit comments

Comments
 (0)