Skip to content
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

overlord,daemon,cmd: re-map snap names around the edges of snapd #5491

Merged
merged 20 commits into from
Jul 17, 2018

Commits on Jul 12, 2018

  1. overlord/ifacestate: add re-mapping function for plugs and slots

    This patch adds re-mapping functions for plugs and slots. The idea with
    re-mapping is that snapd can provide the appearance of a particular plug
    and slot placement as observed in the on-disk state and over-the-wire
    communication while having a different actual placement in memory. In
    practice this is designed to allow us to place implicit slots on the
    snapd snap.
    
    Re-mapping is implemented by a golang interface. Currently only a no-op
    mapper is used. The mapper is global but could be moved to the interface
    manager after changing a large number of functions to become methods on
    the interface manager. This can be done in a follow-up, if desired.
    
    Apart from the golang interface, which provides the low-level
    operations, a number of helpers for other data types are provided. This
    includes connection references and plug and slot information objects.
    Those helpers are used by the daemon API layer in one of the subsequent
    patches.
    
    Two real mappers are implemented: a no-op mapper and a core<=>snapd
    mapper. For testing a upper<=>lower case mapper is used, for extra
    clarity. Everything is accompanied by unit tests.
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 12, 2018
    Configuration menu
    Copy the full SHA
    ff972c7 View commit details
    Browse the repository at this point in the history
  2. overlord/ifacestate: drop re-mapping snap.{Plug,Slog}Info

    The helpers for re-mapping the aforementioned types are no longer
    necessary due to re-factoring and cleanup of the daemon code.
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 12, 2018
    Configuration menu
    Copy the full SHA
    004aea1 View commit details
    Browse the repository at this point in the history
  3. overlord/ifacestate: re-map connection state on load/store from state

    This patch changes getConns and setConns to re-map connection state just
    after loading from the state and just before being saved to the state.
    This is coupled with explicit tests for {get,set}Conns that we apparently
    didn't have.
    
    Note that at this stage the code is still dormant since re-mapping is
    a no-op until the "snapd" snap becomes the host of the implicit slots.
    
    This is the "back" side of the re-mapping. The "front" side applies to
    re-mapping of the API layer. It is provided in the follow-up patch.
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 12, 2018
    Configuration menu
    Copy the full SHA
    0a53fdc View commit details
    Browse the repository at this point in the history
  4. daemon: re-map interface state in API requests/responses

    This patch changes interface connection, disconnection and query APIs to
    apply re-mapping on incoming requests and outgoing responses. This
    allows code to issue explicit connect and disconnect API requests for
    the "core" snap even though implicit slots are on the "snapd" snap.
    Similarly the API for querying interface connections (both the legacy,
    as used by "snap interfaces" and the per-interface as used by "snap
    interface") are updated to take advantage of this feature.
    
    Note that at this stage the code is still dormant since re-mapping is a
    no-op until the "snapd" snap becomes the host of the implicit slots.
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 12, 2018
    Configuration menu
    Copy the full SHA
    24c2448 View commit details
    Browse the repository at this point in the history
  5. daemon: drop unused, commented-out test

    We don't need a test that doesn't work. I added tests for this in the
    previous patch anyway.
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 12, 2018
    Configuration menu
    Copy the full SHA
    72f358b View commit details
    Browse the repository at this point in the history

Commits on Jul 13, 2018

  1. overlord,daemon: drop return values from interface mappers

    The re-mapping helper functions were returning a boolean if a mapping
    was actually applied (something changed) but this value is actually no
    longer used anywhere. In the spirit of YAGNI let's remove it.
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 13, 2018
    Configuration menu
    Copy the full SHA
    b7f95f0 View commit details
    Browse the repository at this point in the history
  2. overlord,daemon: make re-mapping helpers functional

    The remaping functions were modifying their arguments. This patch makes
    them return a modified copy instead.
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 13, 2018
    Configuration menu
    Copy the full SHA
    dc43dd3 View commit details
    Browse the repository at this point in the history
  3. daemon,api: separate mappings for state and API

    This patch changes a number of things, the main concept is that
    the mapping system can now offer separate replacements for state
    handling, where we want to stick to the word "core" for compatibility,
    and the API layer where we want to start using the "system" word
    as a nickname to whatever is providing implicit slots.
    
    As such the mapping functions are duplicated, once for state and once
    for request/response. The intermediate helpers for working with
    connection references are dropped because this just multiplies trivial
    functions that don't need to be used.
    
    The existing NilMapper is expanded to cover the new API. The existing
    CoreSnapdMapper is split into two new mappers: CoreSnapdSystemMapper
    which uses core in the state, snapd in memory and system in the API layer
    and a new CoreCoreSystemMapper which uses core in the state and in memory
    but system in the API layer.
    
    That last new mapper is a candidate for transition of spread tests
    that could start to talk about "system" natively (without the hacks in
    the client) and would then work without change once the core-snapd-system
    mapper can be used, which will happen once snapd starts to host implicit
    slots.
    
    The daemon and state are obviously updated to switch to the appopriate
    mapping helper.
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 13, 2018
    Configuration menu
    Copy the full SHA
    d3c1040 View commit details
    Browse the repository at this point in the history
  4. overlord/ifacestate: move mapper closer to related functions

    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 13, 2018
    Configuration menu
    Copy the full SHA
    8197c6b View commit details
    Browse the repository at this point in the history
  5. overlord/ifacestate: rename NilMapper to IdentityMapper

    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 13, 2018
    Configuration menu
    Copy the full SHA
    e414445 View commit details
    Browse the repository at this point in the history
  6. cmd,overlord,daemon: merge snap nickname with iface mapper

    While testing the interface mapper I realized the nickname system is
    still in use and actually clashes with the interface mapper. Looking at
    it close it is obvious that the nickname system must be folded into the
    interface mapper for consistency and that the interface mapper must be
    able to map snap names more than than plug or slot references.
    
    Without this change we can never have implicit slots on the "snapd" snap
    because implicit gadget connections would resolve to "core" (which can
    be absent) and because the nickname handling is would clash with the
    idea of using "system" in the API layer but "snapd" in the memory
    (because nicknames would effectively change "system" to "core".
    
    To fix this I extended the interface mapper to also be a snap name
    mapper and removed the nickname system entirely. This also allows us to
    drop the ever-growing list of special cases in the client (for interface
    abbreviation logic).
    
    More precisely this patch:
     - drops the {Use,Drop}Nick functions from the snap package
     - changes the default mapper to CoreCoreSystem mapper
     - adds a SnapMapper that has request/response state save/load functions
     - makes InterfaceMapper a superset of SnapMapper
     - refactors CoreCoreSystemMapper and CoreSnapdSystemMapper
     - makes the daemon use RemapSnapFromRequest instead of the nick
     - makes gadget resolver use RemapSnapFromRequest to resolve "system"
     - makes the client abbreviate just "system" slots
    
    This comes without a full array of tests but without breaking any
    existing test (woot). It also passes spread which is promising.
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 13, 2018
    Configuration menu
    Copy the full SHA
    6b7a168 View commit details
    Browse the repository at this point in the history
  7. overlord,daemon: reduce InteraceMapper to SnapMapper

    With the insight from the previous patch I have now simplified all of
    the interface mapper to just a SnapMapper wich can be thought as
    server-side nickname system.
    
    This mostly cuts the amount of boilerplate code that doesn't do anything
    we currently need by limiting the re-mapping to just snap names and to
    not be able to differentiate plugs and slots anymore.
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 13, 2018
    Configuration menu
    Copy the full SHA
    23dca54 View commit details
    Browse the repository at this point in the history
  8. overlord/ifacestate: add extra tests for better coverage

    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 13, 2018
    Configuration menu
    Copy the full SHA
    a950542 View commit details
    Browse the repository at this point in the history
  9. overlord/ifacestate: remove uneeded teardown method

    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 13, 2018
    Configuration menu
    Copy the full SHA
    df33bd3 View commit details
    Browse the repository at this point in the history
  10. daemon: avoid changing existing ConnRef

    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 13, 2018
    Configuration menu
    Copy the full SHA
    039be9e View commit details
    Browse the repository at this point in the history
  11. daemon: undo needless patch delta

    This patch just restores original code where it doesn't make any
    meaningful changes.
    
    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 13, 2018
    Configuration menu
    Copy the full SHA
    360ad8e View commit details
    Browse the repository at this point in the history

Commits on Jul 16, 2018

  1. Configuration menu
    Copy the full SHA
    292c38b View commit details
    Browse the repository at this point in the history

Commits on Jul 17, 2018

  1. Configuration menu
    Copy the full SHA
    61e4d18 View commit details
    Browse the repository at this point in the history
  2. overlord/ifacestate: update comments to refer to identity mapper

    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 17, 2018
    Configuration menu
    Copy the full SHA
    4f71891 View commit details
    Browse the repository at this point in the history
  3. overlord/confistate: add tests for remappers

    Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
    zyga committed Jul 17, 2018
    Configuration menu
    Copy the full SHA
    339a091 View commit details
    Browse the repository at this point in the history