-
Notifications
You must be signed in to change notification settings - Fork 145
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
fix(csi): add node info to failed mount logging. #2686
fix(csi): add node info to failed mount logging. #2686
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log looks good to me, but we already have similar util functions in go-common-libs. Please use them directly.
P.S. Please also add distro name as well.
func GetKernelRelease() (string, error) {
utsname := &syscall.Utsname{}
if err := syscall.Uname(utsname); err != nil {
logrus.WithError(err).Warn("Failed to get kernel release")
return "", err
}
// Extract the kernel release from the Utsname structure
release := make([]byte, 0, len(utsname.Release))
for _, b := range utsname.Release {
if b == 0x00 {
logrus.Trace("Found end of kernel release string [0x00]")
break
}
release = append(release, byte(b))
}
return string(release), nil
}
// GetOSDistro reads the /etc/os-release file and returns the ID field.
func GetOSDistro(osReleaseContent string) (string, error) {
var err error
defer func() {
err = errors.Wrapf(err, "failed to get host OS distro")
}()
lines := strings.Split(osReleaseContent, "\n")
for _, line := range lines {
if strings.HasPrefix(line, "ID=") {
id := strings.TrimPrefix(line, "ID=")
id = strings.Trim(id, `"`)
logrus.Tracef("Found OS distro: %v", id)
return id, nil
}
}
return "", errors.Errorf("failed to find ID field in %v", types.OsReleaseFilePath)
}
Right, the first draft of this PR used I figured I would just use the result from
and so I borrowed the parsing code from sys.GetKernelRelease and did the equivalent of If I read the contents of the local
which is clearly wrong, so I'll need to do an equivalent
BTW, |
c06d8cf
to
e03df9e
Compare
Revised to use the go-common-libs/sys utilities. I had to make a local copy of RunFunc to use the CSI plugin's different location for |
One other option: Mount the host's It appears that it is, though, looking at, say, |
I think we can change to |
e03df9e
to
9c8bb29
Compare
That's right. Manual and regression testing are happy with the change to mount host's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except for an inconsequential nit.
I like this a lot better than the previous implementation. It's good to standardize our mounting conventions.
…t of host root conformant to standard and ns utils Signed-off-by: James Munson <james.munson@suse.com>
9c8bb29
to
124c53b
Compare
@mergify backport v1.6.x v1.5.x |
✅ Backports have been created
|
Which issue(s) this PR fixes:
Issue # longhorn/longhorn#7931
What this PR does / why we need it:
Log with kernel release and OS info when an NFS mount fails, to aid in troubleshooting.
Special notes for your reviewer:
Additional documentation or context