Ensure NFSv4 data is parsed correctly #14120
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed on my TrueNAS Scale 24.04.2 install that A) the display of active NFSv4 sessions isn't working and B) I get the following errors in the log:
Error log
This is because the code currently assumes that that data coming from the Linux kernel is valid YAML, but there's one parameter in that data that's not. Here's an example from my machine:
As you can see, the callback address isn't quoted despite having multiple colons in the data, so it's not valid YAML.
This causes middlewared to fail to parse that as YAML, which results in the error "Can not retrieve response" when trying to list NFS4 sessions in the WebUI.
A good, long-term solution would probably be to no longer parse this data as YAML and write a custom parser instead.
For the meantime, because it was easier, I added a check for "callback address" and then just add quotation marks myself before parsing it as YAML. Not sure if that's an acceptable solution, but it's a heck of a lot better than a broken page with an error message as soon as a client is connected using NFSv4, and I was able to reproduce the issue (and confirm the fix works) even on a fully new stock install of TrueNAS Scale).