Skip to content

Commit df45568

Browse files
authored
Merge pull request #822 from andyzhangx/mount-error-help-link
feat: append help link when there is mount error
2 parents b1a841e + bc70c50 commit df45568

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

pkg/blob/blob.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ type DriverOptions struct {
151151
AllowInlineVolumeKeyAccessWithIdentity bool
152152
EnableGetVolumeStats bool
153153
AppendTimeStampInCacheDir bool
154+
AppendMountErrorHelpLink bool
154155
MountPermissions uint64
155156
KubeAPIQPS float64
156157
KubeAPIBurst int
@@ -173,6 +174,7 @@ type Driver struct {
173174
enableGetVolumeStats bool
174175
allowInlineVolumeKeyAccessWithIdentity bool
175176
appendTimeStampInCacheDir bool
177+
appendMountErrorHelpLink bool
176178
blobfuseProxyConnTimout int
177179
mountPermissions uint64
178180
kubeAPIQPS float64
@@ -210,6 +212,7 @@ func NewDriver(options *DriverOptions) *Driver {
210212
enableBlobMockMount: options.EnableBlobMockMount,
211213
allowEmptyCloudConfig: options.AllowEmptyCloudConfig,
212214
enableGetVolumeStats: options.EnableGetVolumeStats,
215+
appendMountErrorHelpLink: options.AppendMountErrorHelpLink,
213216
mountPermissions: options.MountPermissions,
214217
kubeAPIQPS: options.KubeAPIQPS,
215218
kubeAPIBurst: options.KubeAPIBurst,

pkg/blob/nodeserver.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
312312
if err := wait.PollImmediate(1*time.Second, 2*time.Minute, func() (bool, error) {
313313
return true, d.mounter.MountSensitive(source, targetPath, NFS, mountOptions, []string{})
314314
}); err != nil {
315-
return nil, status.Error(codes.Internal, fmt.Sprintf("volume(%s) mount %q on %q failed with %v", volumeID, source, targetPath, err))
315+
var helpLinkMsg string
316+
if d.appendMountErrorHelpLink {
317+
helpLinkMsg = fmt.Sprintf("\nPlease refer to http://aka.ms/blobmounterror for possible causes and solutions for mount errors.")
318+
}
319+
return nil, status.Error(codes.Internal, fmt.Sprintf("volume(%s) mount %q on %q failed with %v%s", volumeID, source, targetPath, err, helpLinkMsg))
316320
}
317321

318322
if performChmodOp {
@@ -367,7 +371,11 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
367371
}
368372

369373
if err != nil {
370-
err = status.Errorf(codes.Internal, "Mount failed with error: %v, output: %v", err, output)
374+
var helpLinkMsg string
375+
if d.appendMountErrorHelpLink {
376+
helpLinkMsg = fmt.Sprintf("\nPlease refer to http://aka.ms/blobmounterror for possible causes and solutions for mount errors.")
377+
}
378+
err = status.Errorf(codes.Internal, "Mount failed with error: %v, output: %v%s", err, output, helpLinkMsg)
371379
klog.Errorf("%v", err)
372380
notMnt, mntErr := d.mounter.IsLikelyNotMountPoint(targetPath)
373381
if mntErr != nil {

pkg/blobplugin/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ var (
5757
allowInlineVolumeKeyAccessWithIdentity = flag.Bool("allow-inline-volume-key-access-with-idenitity", false, "allow accessing storage account key using cluster identity for inline volume")
5858
kubeAPIQPS = flag.Float64("kube-api-qps", 25.0, "QPS to use while communicating with the kubernetes apiserver.")
5959
kubeAPIBurst = flag.Int("kube-api-burst", 50, "Burst to use while communicating with the kubernetes apiserver.")
60+
appendMountErrorHelpLink = flag.Bool("append-mount-error-help-link", true, "Whether to include a link for help with mount errors when a mount error occurs.")
6061
)
6162

6263
func main() {
@@ -93,6 +94,7 @@ func handle() {
9394
AppendTimeStampInCacheDir: *appendTimeStampInCacheDir,
9495
MountPermissions: *mountPermissions,
9596
AllowInlineVolumeKeyAccessWithIdentity: *allowInlineVolumeKeyAccessWithIdentity,
97+
AppendMountErrorHelpLink: *appendMountErrorHelpLink,
9698
KubeAPIQPS: *kubeAPIQPS,
9799
KubeAPIBurst: *kubeAPIBurst,
98100
}

0 commit comments

Comments
 (0)