-
Notifications
You must be signed in to change notification settings - Fork 837
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 ds-identify's read_fs_info() to work on FreeBSD #625
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.
needs tests in test_dsidentify.
also... maybe we consider trying to render different versions ? freebsd and linux ?
rather than trying linux then trying freebsd.
probably that is not necessary if we're doing it based on uname.
7c3c875
to
56e522b
Compare
tools/ds-identify
Outdated
} | ||
|
||
read_fs_info() { | ||
cached "${DI_BLKID_OUTPUT}" && return 0 |
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.
bah. this needs fixing. we dont actually do anything to set that variable.
the intent of the variable is to say we've already run blkid and cached its output.
this isn't your fault. the intent of DI_BLKID_OUTPUT was to store the result of calling 'blkid', so that we didn't call that external program more than once. So I guess what I'd like from you:
a.) a comment in read_fs_info stating what variables it sets (DI_FS_LABELS, DI_ISO9660_DEVS, DI_FS_UUIDS)
b.) drop of the DI_BLKID_OUTPUT cache here
c.) add caching of call to 'geom'. the easiest way to do this might be just adding a variable 'DI_GEOM' and put the call to 'geom' in a function, something like:
geom_label_status_as() {
# call the bsd program geom '-as', set DI_GEOM_LABEL_STATUS_OUT
cached "$DI_GEOM_LABEL_STATUS_OUT" && return 0
local out=""
out=$(geom -as label status) && DI_GEOM_LABEL_STATUS="$out" ||
DI_GEOM_LABEL_STATUS="$UNAVAILABLE"
return
}
d.) fixing of the caching of 'blkid' output (i realize i'm asking you to fix a bug that isn't your fault... go ahead and git blame this and see that it is mine. 😉 ), but having this variable/cache that doesn't do anything is just confusing.
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.
i realize i'm asking you to fix a bug that isn't your fault...
i'm perfectly happy to do that, it just means this patch will take as long as all my other patches usually do 😅
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.
i think this is done now
tools/ds-identify
Outdated
read_geom() { | ||
local oifs="$IFS" line="" delim="," | ||
local ret=0 out="" labels="" dev="" label="" ftype="" isodevs="" | ||
out=$(geom label status -as) || { |
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.
after adding the 'geom_label_status_as' function, then you'll just use the variable, so here this would look like:
geom_label_status_as
local out="$DI_GEOM_LABEL_STATUS_OUT"
...
[ "$out" ] = "$UNAVAILABLE" && return 0
and the rest of your function here.
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.
you mean
[ "$out" = "$UNAVAILABLE" ] && return 0
right?
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.
yes. good lint'ing.
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.
hmmmm…
for now i'm passing on the return value instead of return 0… not sure that's a sensible thing to do
@smoser any comments on the test? |
Sure, 2 comments: |
99d890d
to
2542a64
Compare
@@ -807,6 +830,19 @@ def _print_run_output(rc, out, err, cfg, files): | |||
'dev/vdb': 'pretend iso content for cidata\n', | |||
} | |||
}, | |||
'NoCloud-fbsd': { |
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.
@smoser i naïvely assumed this would add a test case
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.
still no test, right?
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.
gimme a day or two, while i work my way thru https://pythontesting.net/start-here/
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.
ℹ️
6ae4ef4
to
1630980
Compare
11891e6
to
a53e001
Compare
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.
I like it. good work.
FreeBSD doesn't have blkid, so we want to use geom to list devices and their fstypes and labels. This PR also adds `jail` to the list of is_container() And we now also properly cache geom and blkid output! A test is added to verify the new behaviour by correctly identifying NoCloud on FreeBSD.
c359b99
to
27a402e
Compare
previously, ds-identify would mostly just guess that the system in question is
maybe
OpenStack.This patch makes it correctly recognize NoCloud.
Proposed Commit Message
Additional Context
This fixes LP 1901174
Checklist: