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

cmd/snap-update-ns: keep order of existing mount entries #14494

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Commits on Sep 12, 2024

  1. cmd/snap-update-ns: add test explaining content-layout bugs

    Snapd is affected by several bugs related to content-layout interaction.
    There's a very popular scheme where a snap has two interacting elements
    that only work in one special edge case and break regularly:
    
    - A content plug is used to receive content of another snap, typically
      under $SNAP/foo somewhere. Where foo exists and is not created with a
      mimic.
    - A layout entry is used to "distribute" $SNAP/foo to /usr/share/foo or
      other locations.
    
    This particular arrangement is used to share essential libraries from a
    common "runtime" snap which is not a dedicated base. Several basic tests
    explore the actual behavior in the following situations.
    
    - The content is initially connected and a mount namespace is
      constructed. This is the only correct behavior show in this group of
      tests. This is known as test case 1.
    - The content is initially connected and a mount namespace is
      constructed. The content is then disconnected. This shows several
      anomalies that are referenced in the code (ordering bug, propagation
      bug). This is known as test case 2.
    - The content is initially connected and a mount namespace is
      constructed. The content is then disconnected and re-connected.
      This is known as test case 3.
    - The content is initially disconnected and a mount namespace is
      constructed. The content is then connected.
      This is known as test case 4.
    - The content interface is initially connected and a mount namespace is
      constructed. The content snap is then refreshed.
      This is known as test case 5.
    - The content interface is initially connected and a mount namespace is
      constructed. The application snap is then refreshed.
      This is known as test case 6.
    
    This is related to issues:
    - https://warthogs.atlassian.net/browse/SNAPDENG-31644 (flip flop)
    - https://warthogs.atlassian.net/browse/SNAPDENG-31645 (propagation)
    
    A support makefile and a set of data files is provided to re-generate
    the test data once snapd is improved.
    
    Signed-off-by: Zygmunt Krynicki <[email protected]>
    zyga committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    74fc596 View commit details
    Browse the repository at this point in the history
  2. cmd/snap-update-ns: add Change.GoString

    Signed-off-by: Zygmunt Krynicki <[email protected]>
    zyga committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    42f4624 View commit details
    Browse the repository at this point in the history
  3. osutil: document MountEntry fields

    Signed-off-by: Zygmunt Krynicki <[email protected]>
    zyga committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    730370a View commit details
    Browse the repository at this point in the history
  4. cmd/snap-update-ns: keep order of existing mount entries

    We recently realized that the order of saved mount profile, after
    performing mount namespace update, was subtly incorrect. The order was
    seemingly swapped after each operation. In reality, the order reflected
    the order of performed changes, including the special change type of
    "keep", which means that an entry is kept intact.
    
    Fix the problem by storing "kept" changes in the original order, which
    is back-to-front compared to the order of changes computed by the
    algorithm. At the same time, keep track of mount changes in the order of
    their execution.
    
    This probably fixes a hell lot of edge cases and weird behaviors that
    went undiagnosed for many years. Interestingly a test case had a TODO
    that hinted at the problem, but it was not clear what the problem was at
    the time. The TODO is now gone and the test case is now up-to-date.
    
    Test data for cmd/snap-update-ns/testdata was re-generated.
    
    Jira: https://warthogs.atlassian.net/browse/SNAPDENG-31644
    
    Signed-off-by: Zygmunt Krynicki <[email protected]>
    zyga committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    aaceabb View commit details
    Browse the repository at this point in the history

Commits on Sep 19, 2024

  1. cmd/snap-update-ns: add CurrentProfileFromChanges made

    The new function takes the previously existing algorithm out of
    executeMountProfileUpdate, as the original location makes it very tricky
    to test due to the presence of all the system interactions through
    change.Perform.
    
    Add some simple tests that show how keep, mount and unmount changes are
    preserved.
    
    Signed-off-by: Zygmunt Krynicki <[email protected]>
    zyga committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    09137ba View commit details
    Browse the repository at this point in the history

Commits on Sep 20, 2024

  1. cmd/snap-update-ns: document CurrentProfileFromChangesMade

    Signed-off-by: Zygmunt Krynicki <[email protected]>
    zyga committed Sep 20, 2024
    Configuration menu
    Copy the full SHA
    9e187a7 View commit details
    Browse the repository at this point in the history