-
Notifications
You must be signed in to change notification settings - Fork 96
feat: add telemetry as part of mount options for blobfuse mounts #2248
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
7999704
2b4e9c8
8d9b9fd
5c45e5b
618aac5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,7 +34,8 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mutex sync.Mutex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mutex sync.Mutex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| driverVersion string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type BlobfuseVersion int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -71,6 +72,7 @@ func (server *MountServer) MountAzureBlob(_ context.Context, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var cmd *exec.Cmd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var result mount_azure_blob.MountAzureBlobResponse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if protocol == blob.Fuse2 || server.blobfuseVersion == BlobfuseV2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| telemetryTag := "azpartner-aks/" + driverVersion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args = "mount " + args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // add this arg for blobfuse2 to solve the issue: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // https://github.com/Azure/azure-storage-fuse/issues/1015 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -82,6 +84,21 @@ func (server *MountServer) MountAzureBlob(_ context.Context, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| klog.V(2).Infof("append --disable-version-check to mount args") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args = args + " " + "--disable-version-check=true" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Adding telemetry tag to know that blob is been mounted through AKS CSI Driver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !strings.Contains(args, "--telemetry") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| klog.V(2).Infof("append --telemetry=%s to mount args", telemetryTag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args = args + " " + "--telemetry=" + telemetryTag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // If telemetry flag is already present, check for aks tag if not present | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // then user might have their own telemetry tag append aks tag to it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !strings.Contains(args, "azpartner-aks") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| splitedArgs := strings.Split(args, "--telemetry=") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if len(splitedArgs) == 2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args = splitedArgs[0] + " --telemetry=" + telemetryTag + "," + splitedArgs[1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mittachaitu marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+100
to
+102
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| splitedArgs := strings.Split(args, "--telemetry=") | |
| if len(splitedArgs) == 2 { | |
| args = splitedArgs[0] + " --telemetry=" + telemetryTag + "," + splitedArgs[1] | |
| splitArgs := strings.Split(args, "--telemetry=") | |
| if len(splitArgs) == 2 { | |
| args = splitArgs[0] + " --telemetry=" + telemetryTag + "," + splitArgs[1] |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string manipulation logic for inserting the telemetry tag creates a potential issue with spacing. The code constructs splitedArgs[0] + " --telemetry=" + telemetryTag + "," + splitedArgs[1], which adds a space before --telemetry= but doesn't trim it from splitedArgs[0]. This could result in double spaces if splitedArgs[0] already ends with a space. Consider using strings.TrimSpace() on splitedArgs[0] before concatenation.
| args = splitedArgs[0] + " --telemetry=" + telemetryTag + "," + splitedArgs[1] | |
| args = strings.TrimSpace(splitedArgs[0]) + " --telemetry=" + telemetryTag + "," + splitedArgs[1] |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic doesn't handle the edge case where --telemetry= is provided with an empty value (e.g., --telemetry= --other-flag). In this case, splitedArgs[1] would start with a space and a different flag, resulting in malformed telemetry arguments like --telemetry=blobpartner-csi/version, --other-flag. Consider trimming whitespace from splitedArgs[1] and checking if it's empty before concatenating.
| args = splitedArgs[0] + " --telemetry=" + telemetryTag + "," + splitedArgs[1] | |
| telemetryValue := strings.TrimSpace(splitedArgs[1]) | |
| if telemetryValue == "" { | |
| args = splitedArgs[0] + " --telemetry=" + telemetryTag | |
| } else { | |
| args = splitedArgs[0] + " --telemetry=" + telemetryTag + "," + telemetryValue | |
| } |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The telemetry string parsing logic has a critical flaw. When splitting by "--telemetry=", if there are multiple occurrences of this substring in args (e.g., in a container name or account name), len(splitedArgs) could be greater than 2, but only the first occurrence is handled. This could result in malformed arguments. Consider using a more robust parsing method such as regular expressions or proper argument parsing to specifically target the --telemetry flag.
| splitedArgs := strings.Split(args, "--telemetry=") | |
| if len(splitedArgs) == 2 { | |
| args = splitedArgs[0] + " --telemetry=" + telemetryTag + "," + splitedArgs[1] | |
| } | |
| klog.V(2).Infof("updated --telemetry tag in mount args: %s", args) | |
| // Split args into slice for robust parsing | |
| argSlice := strings.Fields(args) | |
| telemetryIdx := -1 | |
| for i, arg := range argSlice { | |
| if strings.HasPrefix(arg, "--telemetry=") { | |
| telemetryIdx = i | |
| break | |
| } | |
| } | |
| if telemetryIdx != -1 { | |
| // Update the telemetry tag, appending our tag if not present | |
| telemetryVal := strings.TrimPrefix(argSlice[telemetryIdx], "--telemetry=") | |
| // Avoid duplicate tags | |
| if !strings.Contains(telemetryVal, telemetryTagPrefix) { | |
| argSlice[telemetryIdx] = "--telemetry=" + telemetryTag + "," + telemetryVal | |
| args = strings.Join(argSlice, " ") | |
| klog.V(2).Infof("updated --telemetry tag in mount args: %s", args) | |
| } | |
| } |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code silently does nothing when len(splitedArgs) != 2 (line 101 condition). This can occur if the string "--telemetry=" appears multiple times or is part of another parameter value. Consider adding logging (e.g., klog.Warningf) to indicate when the telemetry tag cannot be updated, so operators can identify potential issues with their mount arguments.
| } | |
| klog.V(2).Infof("updated --telemetry tag in mount args: %s", args) | |
| klog.V(2).Infof("updated --telemetry tag in mount args: %s", args) | |
| } else { | |
| klog.Warningf("could not update --telemetry tag in mount args: unexpected format or multiple --telemetry= flags found in args: %s", args) | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If telemetry flag is already present, we just respect original setting, I don't think we need to change the original value by force
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If user has some custom tag, then we can't use that for tracking blob usage through AKS. If we just use the original setting then whole purpose to track usage will be lost, so I appended our tag with user specified value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but what if customer only wants to keep the original telemetry? this PR would change the telemetry even user does not want to.
and this adds the telemetry as
azpartner-aksin open source driver, which means if it runs on AWS k8s node, it would still have thisazpartner-akstelemetry, so maybe use default userAgent asfmt.Sprintf("%s/%s", driverName, driverVersion)is more reasonable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated tag to
blobpartner-csi/<driver-version>, Concern from blobfuse team is if we go with driver specific tag then it will become costly operation for blobfuse analytics team to parse these tags (since they are expecting all partners should use similar tag instead of each partner goes with different tag).