Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Make snap-discard-ns fail gracefully #151
Conversation
jdstrand
requested changes
Sep 22, 2016
Please adjust sc_open_ns_group() to take an arg instead as per inline comments
| + if (errno == ENOENT) { | ||
| + free(group); | ||
| + return NULL; | ||
| + } |
jdstrand
Sep 22, 2016
•
Contributor
This function is identical to sc_open_ns_group() except for this ENOENT check. It would be more maintainable to instead modify sc_open_ns_group() to take a flag and decide how to error based on the flag. Eg:
struct sc_ns_group *sc_open_ns_group(const char *group_name, const int graceful_enoent)
{
...
if (group->dir_fd < 0) {
if (graceful_enoent == 1 && errno == ENOENT) {
free(group);
return NULL;
}
die("cannot open directory for namespace group %s", group_name);
}
...
Then sc-main.c uses:
group = sc_open_ns_group(group_name, 0);
and snap-discard-ns.c uses:
group = sc_open_ns_group(group_name, 1);
Obviously feel free to rename graceful_enoent and be sure to document this argument.
zyga
added some commits
Sep 22, 2016
|
Spread failure looks related to packaging. I will fix this separately and improve spread setup so that we see what actually failed. |
| @@ -155,7 +155,7 @@ static struct sc_ns_group *sc_test_open_ns_group(const char *group_name) | ||
| if (group_name == NULL) { | ||
| group_name = "test-group"; | ||
| } | ||
| - group = sc_open_ns_group(group_name); | ||
| + group = sc_open_ns_group(group_name, 0); | ||
| g_test_queue_destroy((GDestroyNotify) sc_close_ns_group, group); | ||
| // Check if the returned group data looks okay | ||
| g_assert_nonnull(group); |
jdstrand
Sep 22, 2016
Contributor
+1 provided you add a test for sc_open_ns_group(group_name, SC_NS_FAIL_GRACEFULLY)
zyga
added some commits
Sep 23, 2016
zyga
merged commit 2b0ae9e
into
master
Sep 23, 2016
1 check was pending
|
I'm merging this because the test failures are not really related to the change being made. Analysis indicates that ubuntu-core is being unmounted at some (random) point during the test process and depending on how fast or slow the VM is, tests just randomly fail when that happens. Snap-confine has no code that performs sanity checks on the presence of the core snap. |
zyga commentedSep 22, 2016
This patch changes snap-discard-ns to gracefully fail (as in, return
successfully) when any of the following three conditions happen:
This allows snapd to check for abnormal errors from snap-discard-ns.
Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com