From bc70c50336ab99fae71fbea09b710fbbc0c9716d Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Thu, 9 Feb 2023 13:18:26 +0000 Subject: [PATCH] feat: append help link when there is mount error --- pkg/blob/blob.go | 3 +++ pkg/blob/nodeserver.go | 12 ++++++++++-- pkg/blobplugin/main.go | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/blob/blob.go b/pkg/blob/blob.go index 76bbc8e60..2a307eeca 100644 --- a/pkg/blob/blob.go +++ b/pkg/blob/blob.go @@ -151,6 +151,7 @@ type DriverOptions struct { AllowInlineVolumeKeyAccessWithIdentity bool EnableGetVolumeStats bool AppendTimeStampInCacheDir bool + AppendMountErrorHelpLink bool MountPermissions uint64 KubeAPIQPS float64 KubeAPIBurst int @@ -173,6 +174,7 @@ type Driver struct { enableGetVolumeStats bool allowInlineVolumeKeyAccessWithIdentity bool appendTimeStampInCacheDir bool + appendMountErrorHelpLink bool blobfuseProxyConnTimout int mountPermissions uint64 kubeAPIQPS float64 @@ -210,6 +212,7 @@ func NewDriver(options *DriverOptions) *Driver { enableBlobMockMount: options.EnableBlobMockMount, allowEmptyCloudConfig: options.AllowEmptyCloudConfig, enableGetVolumeStats: options.EnableGetVolumeStats, + appendMountErrorHelpLink: options.AppendMountErrorHelpLink, mountPermissions: options.MountPermissions, kubeAPIQPS: options.KubeAPIQPS, kubeAPIBurst: options.KubeAPIBurst, diff --git a/pkg/blob/nodeserver.go b/pkg/blob/nodeserver.go index a8e31829e..8c73f8195 100644 --- a/pkg/blob/nodeserver.go +++ b/pkg/blob/nodeserver.go @@ -312,7 +312,11 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe if err := wait.PollImmediate(1*time.Second, 2*time.Minute, func() (bool, error) { return true, d.mounter.MountSensitive(source, targetPath, NFS, mountOptions, []string{}) }); err != nil { - return nil, status.Error(codes.Internal, fmt.Sprintf("volume(%s) mount %q on %q failed with %v", volumeID, source, targetPath, err)) + var helpLinkMsg string + if d.appendMountErrorHelpLink { + helpLinkMsg = fmt.Sprintf("\nPlease refer to http://aka.ms/blobmounterror for possible causes and solutions for mount errors.") + } + return nil, status.Error(codes.Internal, fmt.Sprintf("volume(%s) mount %q on %q failed with %v%s", volumeID, source, targetPath, err, helpLinkMsg)) } if performChmodOp { @@ -367,7 +371,11 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe } if err != nil { - err = status.Errorf(codes.Internal, "Mount failed with error: %v, output: %v", err, output) + var helpLinkMsg string + if d.appendMountErrorHelpLink { + helpLinkMsg = fmt.Sprintf("\nPlease refer to http://aka.ms/blobmounterror for possible causes and solutions for mount errors.") + } + err = status.Errorf(codes.Internal, "Mount failed with error: %v, output: %v%s", err, output, helpLinkMsg) klog.Errorf("%v", err) notMnt, mntErr := d.mounter.IsLikelyNotMountPoint(targetPath) if mntErr != nil { diff --git a/pkg/blobplugin/main.go b/pkg/blobplugin/main.go index 8690778c2..01fde796d 100644 --- a/pkg/blobplugin/main.go +++ b/pkg/blobplugin/main.go @@ -57,6 +57,7 @@ var ( allowInlineVolumeKeyAccessWithIdentity = flag.Bool("allow-inline-volume-key-access-with-idenitity", false, "allow accessing storage account key using cluster identity for inline volume") kubeAPIQPS = flag.Float64("kube-api-qps", 25.0, "QPS to use while communicating with the kubernetes apiserver.") kubeAPIBurst = flag.Int("kube-api-burst", 50, "Burst to use while communicating with the kubernetes apiserver.") + appendMountErrorHelpLink = flag.Bool("append-mount-error-help-link", true, "Whether to include a link for help with mount errors when a mount error occurs.") ) func main() { @@ -93,6 +94,7 @@ func handle() { AppendTimeStampInCacheDir: *appendTimeStampInCacheDir, MountPermissions: *mountPermissions, AllowInlineVolumeKeyAccessWithIdentity: *allowInlineVolumeKeyAccessWithIdentity, + AppendMountErrorHelpLink: *appendMountErrorHelpLink, KubeAPIQPS: *kubeAPIQPS, KubeAPIBurst: *kubeAPIBurst, }