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

Merged
merged 2 commits into from
Sep 23, 2024

Conversation

zyga
Copy link
Contributor

@zyga zyga commented Sep 12, 2024

This is stacked on top of #14491

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 zyga marked this pull request as ready for review September 12, 2024 11:16
@zyga zyga force-pushed the fix/order-of-saved-profile-SNAPDENG-31644 branch from 15335e7 to aaceabb Compare September 12, 2024 13:14
cmd/snap-update-ns/change.go Outdated Show resolved Hide resolved
cmd/snap-update-ns/update.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I said looking at how NeededChanges works at the moment it appears this will mostly affect the order of unmounting of things we kept that we cannot keep anymore the next time around, it looks the right direction but it's hard to predict the general effects, as the logic in NeededChanges is helpful to an extent but as we know has limitations and is hard to predict atm

cmd/snap-update-ns/update.go Show resolved Hide resolved
@ernestl ernestl added this to the 2.66 milestone Sep 19, 2024
Copy link
Contributor

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

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]>
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 zyga force-pushed the fix/order-of-saved-profile-SNAPDENG-31644 branch from 9e187a7 to 4404ec1 Compare September 23, 2024 09:48
Copy link

codecov bot commented Sep 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.85%. Comparing base (ac897ee) to head (4404ec1).
Report is 22 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #14494   +/-   ##
=======================================
  Coverage   78.85%   78.85%           
=======================================
  Files        1079     1079           
  Lines      145615   145636   +21     
=======================================
+ Hits       114828   114847   +19     
- Misses      23601    23602    +1     
- Partials     7186     7187    +1     
Flag Coverage Δ
unittests 78.85% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zyga zyga merged commit bedc1f1 into canonical:master Sep 23, 2024
54 of 56 checks passed
@zyga zyga deleted the fix/order-of-saved-profile-SNAPDENG-31644 branch September 23, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants