Skip to content
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

Configure XFS max-retry=1 max-timeout=5 for EIO/ENOSPC errors #753

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apparmor.profile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ profile directpv flags=(attach_disconnected,mediate_deleted) {
/var/lib/directpv/** w,
/var/lib/kubelet/** w,
/csi/** w,
/sys/fs/xfs/**/error/metadata/{EIO,ENOSPC}/retry_timeout_seconds rw,

# only a limited set of binaries can be executed
/usr/sbin/mkfs ix,
Expand Down
2 changes: 1 addition & 1 deletion pkg/installer/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func getVolumesAndMounts(pluginSocketDir string) (volumes []corev1.Volume, volum
newVolumeMount(volumeNameMountpointDir, kubeletDirPath+"/pods", corev1.MountPropagationBidirectional, false),
newVolumeMount(volumeNamePluginDir, kubeletDirPath+"/plugins", corev1.MountPropagationBidirectional, false),
newVolumeMount(volumeNameAppRootDir, appRootDir, corev1.MountPropagationBidirectional, false),
newVolumeMount(volumeNameSysDir, volumePathSysDir, corev1.MountPropagationBidirectional, true),
newVolumeMount(volumeNameSysDir, volumePathSysDir, corev1.MountPropagationBidirectional, false),
newVolumeMount(volumeNameDevDir, volumePathDevDir, corev1.MountPropagationHostToContainer, true),
newVolumeMount(volumeNameRunUdevData, volumePathRunUdevData, corev1.MountPropagationBidirectional, true),
newVolumeMount(volumeNameLegacyAppRootDir, legacyAppRootDir, corev1.MountPropagationBidirectional, false),
Expand Down
2 changes: 1 addition & 1 deletion pkg/installer/psp.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func createPodSecurityPolicy(ctx context.Context, args *Args) (err error) {
Volumes: []policy.FSType{policy.HostPath},
AllowedHostPaths: []policy.AllowedHostPath{
{PathPrefix: "/proc", ReadOnly: true},
{PathPrefix: volumePathSysDir, ReadOnly: true},
{PathPrefix: volumePathSysDir},
{PathPrefix: consts.UdevDataDir, ReadOnly: true},
{PathPrefix: consts.AppRootDir},
{PathPrefix: socketDir},
Expand Down
32 changes: 30 additions & 2 deletions pkg/xfs/mount_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,44 @@ package xfs
import (
"errors"
"os"
"path"

"github.com/minio/directpv/pkg/sys"
"k8s.io/klog/v2"
)

func mount(device, target string) error {
if err := os.Mkdir(target, 0o777); err != nil && !errors.Is(err, os.ErrExist) {
if err := sys.Mkdir(target, 0o777); err != nil && !errors.Is(err, os.ErrExist) {
return err
}

return sys.Mount(device, target, "xfs", []string{"noatime"}, "prjquota")
if err := sys.Mount(device, target, "xfs", []string{"noatime"}, "prjquota"); err != nil {
return err
}

name := path.Base(device)
if name == "/" || name == "." {
klog.Errorf("unable to get device name from device %v", device)
return nil
}

if err := os.WriteFile("/sys/fs/xfs/"+name+"/error/metadata/EIO/max_retries", []byte("1"), 0o644); err != nil {
klog.ErrorS(err, "unable to set EIO max_retires device", "name", name)
}

if err := os.WriteFile("/sys/fs/xfs/"+name+"/error/metadata/EIO/retry_timeout_seconds", []byte("5"), 0o644); err != nil {
klog.ErrorS(err, "unable to set EIO retry_timeout_seconds for device", "name", name)
}

if err := os.WriteFile("/sys/fs/xfs/"+name+"/error/metadata/ENOSPC/max_retries", []byte("1"), 0o644); err != nil {
klog.ErrorS(err, "unable to set ENOSPC max_retires device", "name", name)
}

if err := os.WriteFile("/sys/fs/xfs/"+name+"/error/metadata/ENOSPC/retry_timeout_seconds", []byte("5"), 0o644); err != nil {
klog.ErrorS(err, "unable to set ENOSPC retry_timeout_seconds for device", "name", name)
}

return nil
}

func bindMount(source, target string, readOnly bool) error {
Expand Down