Public bug reported: My use case: one snap needs expose a rw path to the other one so that a unix socket can be created over which the two applications can communicate.
The problem: I need a directory to be used by the 'content' interface in the target snap. Attempt #1: https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1681068 Attempt #2: tried creating a directory under target's $SNAP_COMMON via a configure hook. None of the changes are propagated from the source's directory to the target's $SNAP_COMMON/<dirname> (seems like a bind mount is not set up properly). As soon as I remove <dirname> from the target argument in snapcraft.yaml, remove the configure hook, and just put the target's $SNAP_COMMON snap into target, remove the snap and do a fresh install of a rebuilt one changes from the provider snap get propagated (note: removing is mandatory for some reason, looks like some state is not cleared if I just install the new snap 'over' the old one). Description: Following this, I've created a 'configure' hook to do a 'mkdir -p <dirname>' on target snap's installation: https://snapcraft.io/docs/build-snaps/hooks https://github.com/snapcore/snapd/wiki/hooks https://github.com/snapcore/snapcraft/blob/master/demos/hooks/snap/hooks/configure Provider: https://github.com/dshcherb/snap-consul/tree/891375978197b0cacbf5d108c2006262d4ac5968 Consumer (with a hook): https://github.com/dshcherb/snap-vault/tree/bug-1681099 Result: ➜ snap-vault git:(master) ✗ snapcraft ... Snapped vault-dmitriis_0.6.5_amd64.snap ➜ snap-vault git:(master) ✗ sudo snap install vault-dmitriis_0.6.5_amd64.snap --dangerous vault-dmitriis 0.6.5 installed апр 08 17:03:04 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1932 on Do: Run configure hook of "vault-dmitriis" snap if present ➜ snap-consul git:(master) ✗ snapcraft ... Snapped consul-dmitriis_0.8.0_amd64.snap ➜ snap-consul git:(master) ✗ sudo snap install consul-dmitriis_0.8.0_amd64.snap --dangerous consul-dmitriis 0.8.0 installed ➜ snap-vault git:(master) ✗ sudo snap connect vault-dmitriis:consul-tmp consul-dmitriis:consul-tmp апр 08 17:06:31 blade /usr/lib/snapd/snapd[6067]: daemon.go:176: DEBUG: uid=0;@ POST /v2/interfaces 48.067502ms 202 апр 08 17:06:31 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1944 on Do: Run hook prepare-plug-consul-tmp of snap "vault-dmitriis" апр 08 17:06:32 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1945 on Do: Run hook prepare-slot-consul-tmp of snap "consul-dmitriis" апр 08 17:06:32 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1943 on Do: Connect vault-dmitriis:consul-tmp to consul-dmitriis:consul-tmp апр 08 17:06:32 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1946 on Do: Run hook connect-slot-consul-tmp of snap "consul-dmitriis" апр 08 17:06:32 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1947 on Do: Run hook connect-plug-consul-tmp of snap "vault-dmitriis" root@blade:/home/dima/src/canonical/snap-consul# touch $SNAP_COMMON/testfile ➜ snap-vault git:(master) ✗ sudo snap run --shell vault-dmitriis.vault root@blade:/home/dima/src/canonical/snap-vault# ls -l $SNAP_COMMON/consul/ total 0 While `sudo snap run --shell vault-dmitriis.vault` is still running: pgrep -f 'shell vault' 27353 # mountinfo for a specific process - output in the paste below cat /proc/`pgrep -f 'shell vault'`/mountinfo https://paste.ubuntu.com/24340865/ --- Neither does it work when a file is created before connecting the two snaps (though propagation should work in any case - it would be pointless without it). The only workaround now is to use the whole $SNAP_COMMON target directory. This is a terrible workaround as I might need $SNAP_COMMON for something else and I don't want snapd to 'shadow' the contents of that directory in case a bind mount is done. ** Affects: snapd (Ubuntu) Importance: Undecided Status: New ** Description changed: My use case: one snap needs expose a rw path to the other one so that a unix socket can be created over which the two applications can communicate. The problem: I need a directory to be used by the 'content' interface in the target snap. Attempt #1: https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1681068 Attempt #2: tried creating a directory under target's $SNAP_COMMON via a configure hook. None of the changes are propagated from the source's directory to the target's $SNAP_COMMON/<dirname> (seems like a bind mount is not set up properly). As soon as I remove <dirname> from the target argument in snapcraft.yaml, remove the configure hook, and just put the target's $SNAP_COMMON snap into target, remove the snap and do a fresh install of a rebuilt one changes from the provider snap get propagated (note: removing is mandatory for some reason, looks like some state is not cleared if I just install the new snap 'over' the old one). Description: Following this, I've created a 'configure' hook to do a 'mkdir -p <dirname>' on target snap's installation: https://snapcraft.io/docs/build-snaps/hooks https://github.com/snapcore/snapd/wiki/hooks https://github.com/snapcore/snapcraft/blob/master/demos/hooks/snap/hooks/configure - Provider: https://github.com/dshcherb/snap-consul/tree/891375978197b0cacbf5d108c2006262d4ac5968 Consumer (with a hook): - + https://github.com/dshcherb/snap-vault/tree/bug-1681099 Result: ➜ snap-vault git:(master) ✗ snapcraft ... Snapped vault-dmitriis_0.6.5_amd64.snap - ➜ snap-vault git:(master) ✗ sudo snap install vault-dmitriis_0.6.5_amd64.snap --dangerous + ➜ snap-vault git:(master) ✗ sudo snap install vault-dmitriis_0.6.5_amd64.snap --dangerous vault-dmitriis 0.6.5 installed апр 08 17:03:04 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1932 on Do: Run configure hook of "vault-dmitriis" snap if present - - ➜ snap-consul git:(master) ✗ snapcraft + ➜ snap-consul git:(master) ✗ snapcraft ... Snapped consul-dmitriis_0.8.0_amd64.snap ➜ snap-consul git:(master) ✗ sudo snap install consul-dmitriis_0.8.0_amd64.snap --dangerous consul-dmitriis 0.8.0 installed ➜ snap-vault git:(master) ✗ sudo snap connect vault-dmitriis:consul-tmp consul-dmitriis:consul-tmp апр 08 17:06:31 blade /usr/lib/snapd/snapd[6067]: daemon.go:176: DEBUG: uid=0;@ POST /v2/interfaces 48.067502ms 202 апр 08 17:06:31 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1944 on Do: Run hook prepare-plug-consul-tmp of snap "vault-dmitriis" апр 08 17:06:32 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1945 on Do: Run hook prepare-slot-consul-tmp of snap "consul-dmitriis" апр 08 17:06:32 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1943 on Do: Connect vault-dmitriis:consul-tmp to consul-dmitriis:consul-tmp апр 08 17:06:32 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1946 on Do: Run hook connect-slot-consul-tmp of snap "consul-dmitriis" апр 08 17:06:32 blade /usr/lib/snapd/snapd[6067]: taskrunner.go:353: DEBUG: Running task 1947 on Do: Run hook connect-plug-consul-tmp of snap "vault-dmitriis" root@blade:/home/dima/src/canonical/snap-consul# touch $SNAP_COMMON/testfile ➜ snap-vault git:(master) ✗ sudo snap run --shell vault-dmitriis.vault - root@blade:/home/dima/src/canonical/snap-vault# ls -l $SNAP_COMMON/consul/ + root@blade:/home/dima/src/canonical/snap-vault# ls -l $SNAP_COMMON/consul/ total 0 While `sudo snap run --shell vault-dmitriis.vault` is still running: pgrep -f 'shell vault' 27353 # mountinfo for a specific process - output in the paste below cat /proc/`pgrep -f 'shell vault'`/mountinfo https://paste.ubuntu.com/24340865/ --- Neither does it work when a file is created before connecting the two snaps (though propagation should work in any case - it would be pointless without it). The only workaround now is to use the whole $SNAP_COMMON target directory. This is a terrible workaround as I might need $SNAP_COMMON for something else and I don't want snapd to 'shadow' the contents of that directory in case a bind mount is done. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1681099 Title: Bind mounting is not performed when a directory created in a config hook is used with the content interface To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1681099/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
