How do I share a namespace between snap commands?

David Garrod dgarrod at extremenetworks.com
Wed Jul 27 15:50:38 UTC 2016


I'm very new to snappy so please excuse me for any questions that seem obvious.

I have snapcraft.yaml that looks as follows:

--------------------------------------------------------------------------------------------------------------------------------------------
% cat snapcraft.yaml
name: openswitch-appliance
version: 0.3.0-rc0-1
summary: OpenSwitch NOS for the Appliance.
description: A standalone version of the OpenSwitch NOS (www.openswitch.net) Appliance targeted at an Oracle VirtualBox running Ubuntu-Core with one management interface and seven "front-panel" network adapters.
confinement: devmode

apps:
  start-openswitch:
    command: usr/sbin/start-openswitch
    plugs: [ network, network-control, network-bind, network-manager, network-observe, gsettings ]
  stop-openswitch:
    command: usr/sbin/stop-openswitch
    plugs: [ network, network-control, network-bind, network-manager, network-observe, gsettings ]
  vtysh:
    command: usr/sbin/start-vtysh
  shell:
    command: bin/bash
    plugs: [ network, network-control, network-bind, network-manager, network-observe, gsettings ]

parts:

  ops-init:
   plugin: make
    source: src/ops-init
    stage-packages: [ binutils, file, strace, bash, iputils-ping, traceroute ]

  openswitch:
    plugin: x-openswitch
#    source: https://github.com/ops-snappy/ops-build.git
#    source: ../ops-build
    source: /builds/dgarrod/ops-build
    platform: appliance
#    skip-native-build: true
    skip-native-build: true
    stage-packages: [ resolvconf ]
    after: [ ops-init ]
--------------------------------------------------------------------------------------------------------------------------------------------

The important point here is that there are multiple commands that are part of the snap. I start our snap using the command:

sudo /snap/bin/openswitch-appliance.start-openswitch

Inside the SNAP this creates a couple of namespaces (swns and nonet):

/sbin/ip netns add swns
/sbin/ip netns add nonet

The problem is that if I then start up another command in the SNAP, specifically a bash shell using:

sudo /snap/bin/openswitch-appliance.bash

I can't get at the swns or nonet namespaces from the bash shell that gets started. I get errors like:

root at Snappy-Appliance:/home/netop# ip netns exec swns bash
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
setting the network namespace "swns" failed: Invalid argument
root at Snappy-Appliance:/home/netop# ip netns pids swns
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument

Why is this? I thought all commands for my "snap" are somehow part of the same "snap", even though they are in different process trees. It apparently isn't the case. How do I get namespaces to play across these commands.

Note that currently I'm installing my SNAP --devmode and I'm also connecting all the network related plug/slots.

  sudo snap connect openswitch-appliance:network-control ubuntu-core:network-control
  sudo snap connect openswitch-appliance:network-manager ubuntu-core:network-manager
  sudo snap connect openswitch-appliance:network-observe ubuntu-core:network-observe

The only way I've sort of worked around this is to start up a "bash" shell using my snap bash command and then actually starting my subsystem from within this bash shell. So now all processes only went through the one "command". But for a number of reasons this isn't going to work for me.

Another way of asking my questions is how do I get all my "apps" in my SNAP to be able to play nicely together? Are they one "snap" or not, even when started separately?

Thanks,

Dave Garrod



________________________________

DISCLAIMER:
This e-mail and any attachments to it may contain confidential and proprietary material and is solely for the use of the intended recipient. Any review, use, disclosure, distribution or copying of this transmittal is prohibited except by or on behalf of the intended recipient. If you have received this transmittal in error, please notify the sender and destroy this e-mail and any attachments and all copies, whether electronic or printed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/snapcraft/attachments/20160727/7b0dda48/attachment.html>


More information about the Snapcraft mailing list