Skip to content

Commit

Permalink
Merge pull request #1179 from kubernetes-sigs/mount-error-help-link
Browse files Browse the repository at this point in the history
feat: append help link when there is mount error
  • Loading branch information
andyzhangx authored Feb 10, 2023
2 parents d24cb41 + 23d363e commit 676a214
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/azurefile/azurefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ type DriverOptions struct {
AllowInlineVolumeKeyAccessWithIdentity bool
EnableVHDDiskFeature bool
EnableGetVolumeStats bool
AppendMountErrorHelpLink bool
MountPermissions uint64
FSGroupChangePolicy string
KubeAPIQPS float64
Expand All @@ -211,6 +212,7 @@ type Driver struct {
allowInlineVolumeKeyAccessWithIdentity bool
enableVHDDiskFeature bool
enableGetVolumeStats bool
appendMountErrorHelpLink bool
mountPermissions uint64
kubeAPIQPS float64
kubeAPIBurst int
Expand Down Expand Up @@ -254,6 +256,7 @@ func NewDriver(options *DriverOptions) *Driver {
driver.allowInlineVolumeKeyAccessWithIdentity = options.AllowInlineVolumeKeyAccessWithIdentity
driver.enableVHDDiskFeature = options.EnableVHDDiskFeature
driver.enableGetVolumeStats = options.EnableGetVolumeStats
driver.appendMountErrorHelpLink = options.AppendMountErrorHelpLink
driver.mountPermissions = options.MountPermissions
driver.fsGroupChangePolicy = options.FSGroupChangePolicy
driver.kubeAPIQPS = options.KubeAPIQPS
Expand Down
6 changes: 5 additions & 1 deletion pkg/azurefile/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,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, SMBMount(d.mounter, source, cifsMountPath, mountFsType, mountOptions, sensitiveMountOptions)
}); err != nil {
return nil, status.Error(codes.Internal, fmt.Sprintf("volume(%s) mount %s on %s failed with %v", volumeID, source, cifsMountPath, err))
var helpLinkMsg string
if d.appendMountErrorHelpLink {
helpLinkMsg = fmt.Sprintf("\nPlease refer to http://aka.ms/filemounterror for possible causes and solutions for mount errors.")
}
return nil, status.Error(codes.Internal, fmt.Sprintf("volume(%s) mount %s on %s failed with %v%s", volumeID, source, cifsMountPath, err, helpLinkMsg))
}
if protocol == nfs {
if performChmodOp {
Expand Down
2 changes: 2 additions & 0 deletions pkg/azurefileplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var (
enableVHDDiskFeature = flag.Bool("enable-vhd", true, "enable VHD disk feature (experimental)")
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() {
Expand Down Expand Up @@ -91,6 +92,7 @@ func handle() {
AllowInlineVolumeKeyAccessWithIdentity: *allowInlineVolumeKeyAccessWithIdentity,
FSGroupChangePolicy: *fsGroupChangePolicy,
EnableVHDDiskFeature: *enableVHDDiskFeature,
AppendMountErrorHelpLink: *appendMountErrorHelpLink,
KubeAPIQPS: *kubeAPIQPS,
KubeAPIBurst: *kubeAPIBurst,
}
Expand Down

0 comments on commit 676a214

Please sign in to comment.