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

Add retry to reading /proc/mounts #234

Merged
merged 4 commits into from
Jul 30, 2024
Merged
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
32 changes: 30 additions & 2 deletions pkg/driver/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ const (
awsMaxAttemptsOption = "--aws-max-attempts"
)

const (
// Due to some reason that we haven't been able to identify, reading `/host/proc/mounts`
// fails on newly spawned Karpenter/GPU nodes with "invalid argument".
// It's reported that reading `/host/proc/mounts` works after some retries,
// and we decided to add retry mechanism until we find and fix the root cause of this problem.
// See https://github.com/awslabs/mountpoint-s3-csi-driver/issues/174.
procMountsReadMaxRetry = 3
procMountsReadRetryBackoff = 100 * time.Millisecond
)

type MountCredentials struct {
AccessKeyID string
SecretAccessKey string
Expand Down Expand Up @@ -157,10 +167,28 @@ func NewS3Mounter(mpVersion string, kubernetesVersion string) (*S3Mounter, error
}

func (pml *ProcMountLister) ListMounts() ([]mount.MountPoint, error) {
mounts, err := os.ReadFile(pml.ProcMountPath)
var (
mounts []byte
err error
)

for i := 1; i <= procMountsReadMaxRetry; i += 1 {
mounts, err = os.ReadFile(pml.ProcMountPath)
if err == nil {
if i > 1 {
klog.V(4).Infof("Successfully read %s after %d retries", pml.ProcMountPath, i)
}
break
}

klog.Errorf("Failed to read %s on try %d: %v", pml.ProcMountPath, i, err)
time.Sleep(procMountsReadRetryBackoff)
}

if err != nil {
return nil, fmt.Errorf("Failed to read %s: %w", procMounts, err)
return nil, fmt.Errorf("Failed to read %s after %d tries: %w", pml.ProcMountPath, procMountsReadMaxRetry, err)
}

return parseProcMounts(mounts)
}

Expand Down
Loading