cmd/snap,tests/main: add confinement switch instead of spread system blacklisting #3274

Merged
merged 14 commits into from May 22, 2017

Conversation

Projects
None yet
5 participants
Contributor

morphis commented May 5, 2017

No description provided.

One fundamental comment about asking snapd vs telling locally. Others are simple suggestions.

cmd/snap/cmd_forced_devmode.go
+ }
+
+ fmt.Println("Before check")
+ fmt.Fprintf(Stdout, "%v\n", release.ReleaseInfo.ForceDevMode())
@zyga

zyga May 8, 2017

Contributor

I think this should be asking snapd (via the /info) URL as snap and snapd may disagree, if one is local and one is remote.

@morphis

morphis May 8, 2017

Contributor

Done.

cmd/snap/cmd_forced_devmode.go
+
+ fmt.Println("Before check")
+ fmt.Fprintf(Stdout, "%v\n", release.ReleaseInfo.ForceDevMode())
+ return nil
@zyga

zyga May 8, 2017

Contributor

In addition, to simplify scripting I would convey the result in the exit code. If we are in forced devmode return zero, return nonzero otherwise.

@morphis

morphis May 8, 2017

Contributor

Done.

- exit 1
- fi
- grep -q "Permission denied" fuse.error
+ if [ "$(snap forced-devmode)" = "false" ]; then
@zyga

zyga May 8, 2017

Contributor

You can then use more natural if snap !forced-devmode; then ... fi` syntax.

@morphis

morphis May 8, 2017

Contributor

Done.

@@ -66,6 +62,10 @@ execute: |
echo "Then the service is accessible by a client"
nc -w 2 -q 2 localhost "$PORT" < $REQUEST_FILE | grep -Pqz "ok\n"
+ if ! snap forced-devmode ; then
@zyga

zyga May 8, 2017

Contributor

Is the ! expected?

@morphis

morphis May 8, 2017

Contributor

No.

zyga approved these changes May 8, 2017

+1

@@ -5,8 +5,6 @@ systems:
# no support for fuse on 14.04
- -ubuntu-14.04-64
- -ubuntu-14.04-32
- # No confinement (AppArmor, Seccomp) available on these systems
- - -debian-*
@zyga

zyga May 8, 2017

Contributor

❤️

@@ -1,9 +1,5 @@
summary: Ensure that the network-bind interface works
-systems:
@zyga

zyga May 8, 2017

Contributor

❤️

@@ -2,8 +2,6 @@ summary: Ensure that the openvswitch interface works.
systems:
- -ubuntu-core-*
- # No confinement (AppArmor, Seccomp) available on these systems
- - -debian-*
@zyga

zyga May 8, 2017

Contributor

❤️

@@ -1,9 +1,5 @@
summary: Ensure that the process-control interface works.
-systems:
@zyga

zyga May 8, 2017

Contributor

❤️

@@ -4,8 +4,6 @@ systems:
- -ubuntu-core-16-*
# ppc64el disabled because of https://github.com/snapcore/snapd/issues/2504
- -ubuntu-*-ppc64el
- # No confinement (AppArmor, Seccomp) available on these systems
@zyga

zyga May 8, 2017

Contributor

❤️

zyga approved these changes May 9, 2017

Looks good, though the diff is painful to read as it is so repetitive :-)

Simon Fels added some commits May 5, 2017

Collaborator

mvo5 commented May 12, 2017

The code looks great. My main wondering is if should move this new command under snap debug - so snap debug forced-devmode or alternatively if we should have something like snap sysinfo which could display some more info like forced-devmode, on-classic, managed. Maybe @niemeyer has some suggestion for this?

Contributor

morphis commented May 12, 2017

The code looks great. My main wondering is if should move this new command under snap debug - so snap debug forced-devmode or alternatively if we should have something like snap sysinfo which could display some more info like forced-devmode, on-classic, managed. Maybe @niemeyer has some suggestion for this?

Good idea. I am open for any of these and will wait for @niemeyer to comment.

Contributor

niemeyer commented May 18, 2017

I would actually prefer the original approach. It seems much simpler, even in terms of terseness, and also means we know for sure what is being tested where, instead of relying runtime behavior of the system at test.

(note above)

Simon commented that the point is having tests partially executing, so here is an updated review. LGTM assuming these points are addressed.

daemon/api.go
@@ -256,6 +256,7 @@ func sysInfo(c *Command, r *http.Request, user *auth.UserState) Response {
"os-release": release.ReleaseInfo,
"on-classic": release.OnClassic,
"managed": len(users) > 0,
+ "forced-devmode": release.ReleaseInfo.ForceDevMode(),
@niemeyer

niemeyer May 18, 2017

Contributor

This is a mechanism to get us going but that we want to kill over time. It's also pretty bogus, because lack of apparmor does not mean lack of entire confinement, and definitely doesn't mean devmode. So we shouldn't be making it official by exposing it in a public API.

Here is a suggested alternative: let's have a command named:

$ snap debug confinement

the output should be one of: strict, partial, or none

For the implementation, let's call release.ReleaseInfo.ForceDevMode directly in the client command, instead of exposing it via the API. That buys us time to polish this without promising a public API.

@morphis

morphis May 19, 2017

Contributor

OK, will rework this and will introduce a new debug command for the snap binary.

tests/main/confinement-classic/task.yaml
- # if confinement is supported on the platform we're running.
- if [[ "$SPREAD_SYSTEM" = debian-* ]]; then
+ if snap forced-devmode; then
+ echo "WARNING: Skipping confinement checks as snapd runs in forced devmode"
@niemeyer

niemeyer May 18, 2017

Contributor

These warnings may be dropped. They won't go anywhere useful, so it's just adding noise to the test text.

@morphis

morphis May 19, 2017

Contributor

Done.

tests/main/install-sideload/task.yaml
+ expected="^test-snapd-devmode +.* +jailmode"
+ snap list | grep -Pq "$expected"
+ else
+ echo "WARNING: Skipping confinement checks as snapd runs in forced devmode"
@niemeyer

niemeyer May 18, 2017

Contributor

Same here and in other tasks.

@morphis

morphis May 19, 2017

Contributor

Done.

tests/main/interfaces-home/task.yaml
- echo "When the plug is disconnected"
- snap disconnect home-consumer:home
- snap interfaces | grep -Pzq "$DISCONNECTED_PATTERN"
+ if ! snap forced-devmode ; then
@niemeyer

niemeyer May 18, 2017

Contributor

We can just exit 0 here as done in prior tasks, instead of indenting everything else.

@morphis

morphis May 19, 2017

Contributor

Done.

Simon Fels added some commits May 19, 2017

Contributor

morphis commented May 19, 2017

@niemeyer @zyga Reworked the implementation now to have a client side only snap debug confinement command which all tests are using now.

Codecov Report

Merging #3274 into master will increase coverage by 0.13%.
The diff coverage is 28.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3274      +/-   ##
==========================================
+ Coverage   77.59%   77.72%   +0.13%     
==========================================
  Files         364      366       +2     
  Lines       24980    25445     +465     
==========================================
+ Hits        19382    19778     +396     
- Misses       3871     3905      +34     
- Partials     1727     1762      +35
Impacted Files Coverage Δ
client/client.go 81.88% <ø> (+1%) ⬆️
daemon/api.go 76.35% <100%> (+3.47%) ⬆️
cmd/snap/cmd_forced_devmode.go 23.07% <23.07%> (ø)
cmd/snap/cmd_confinement.go 20% <0%> (ø)
overlord/ifacestate/helpers.go 63.71% <0%> (+0.84%) ⬆️
cmd/snap/cmd_aliases.go 96% <0%> (+2%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 57df132...d39020f. Read the comment docs.

@morphis morphis changed the title from cmd/snap,tests/main: add force-devmode switch instead of spread system blacklisting to cmd/snap,tests/main: add confinement switch instead of spread system blacklisting May 22, 2017

@zyga zyga merged commit 2380588 into snapcore:master May 22, 2017

6 of 7 checks passed

xenial-ppc64el autopkgtest finished (failure)
Details
artful-amd64 autopkgtest finished (success)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
xenial-i386 autopkgtest finished (success)
Details
yakkety-amd64 autopkgtest finished (success)
Details
zesty-amd64 autopkgtest finished (success)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment