-
Notifications
You must be signed in to change notification settings - Fork 582
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/fdestate/fdestate.go: fix path to data mount point on hybrid #14734
base: fde-manager-features
Are you sure you want to change the base?
overlord/fdestate/fdestate.go: fix path to data mount point on hybrid #14734
Conversation
That should make |
6f19bb3
to
39ad1ff
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## fde-manager-features #14734 +/- ##
=======================================================
Coverage ? 78.84%
=======================================================
Files ? 1093
Lines ? 147888
Branches ? 0
=======================================================
Hits ? 116599
Misses ? 24010
Partials ? 7279
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the PR description?
overlord/fdestate/fdestate.go
Outdated
@@ -218,7 +219,12 @@ func initializeState(st *state.State) error { | |||
|
|||
// FIXME mount points will be different in recovery or factory-reset modes | |||
// either inspect degraded.json, or use boot.HostUbuntuDataForMode() | |||
dataUUID, dataErr := disksDMCryptUUIDFromMountPoint(dirs.SnapdStateDir(dirs.GlobalRootDir)) | |||
dataDir := dirs.GlobalRootDir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this true on hybrid as well? Unless, I'm misunderstanding what the problem is and which path exists in which scenario.
dataDir := dirs.GlobalRootDir | |
dataDir := dirs.SnapdStateDir(dirs.GlobalRootDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think it is a mount point on hybrid. On core it is a bind mount.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also tests/nested/manual/muinstaller-real
fails with this.
overlord/fdestate/fdestate.go
Outdated
if osutil.FileExists(writable) { | ||
dataDir = writable | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if osutil.FileExists(writable) { | |
dataDir = writable | |
} | |
if osutil.FileExists(writable) { | |
// appears be an Ubuntu Core device, where /writable exists | |
dataDir = writable | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking of it, I will test it is a mount point. Because someone could create /writable
and easily break it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we check whether release
indicates we are on Core and so choose the right path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. That might be just simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some suggestions about tweaks to the unit tests
overlord/fdestate/fdemgr_test.go
Outdated
defer fdestate.MockDMCryptUUIDFromMountPoint(func(mountpoint string) (string, error) { | ||
fmt.Printf("%s %s %s\n", mountpoint, dirs.GlobalRootDir, filepath.Join(dirs.GlobalRootDir, "writable")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c.Logf() ?
fmt.Printf("%s %s %s\n", mountpoint, dirs.GlobalRootDir, filepath.Join(dirs.GlobalRootDir, "writable")) | |
c.Logf("%s %s %s\n", mountpoint, dirs.GlobalRootDir, filepath.Join(dirs.GlobalRootDir, "writable")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that was some debug thing. I can just remove it.
overlord/fdestate/fdemgr_test.go
Outdated
@@ -101,10 +103,17 @@ func (u *instrumentedUnlocker) Relock() { | |||
u.relocked += 1 | |||
} | |||
|
|||
func (s *fdeMgrSuite) startedManager(c *C) *fdestate.FDEManager { | |||
func (s *fdeMgrSuite) startedManager(c *C, onClassic bool) *fdestate.FDEManager { | |||
s.AddCleanup(release.MockOnClassic(onClassic)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd move the mocking back to the actual test and have a MockOnClassic(true) in SetUpTest() so that we have a clear 'view' of the system state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Some small nitpicks
overlord/fdestate/fdestate.go
Outdated
@@ -218,7 +220,12 @@ func initializeState(st *state.State) error { | |||
|
|||
// FIXME mount points will be different in recovery or factory-reset modes | |||
// either inspect degraded.json, or use boot.HostUbuntuDataForMode() | |||
dataUUID, dataErr := disksDMCryptUUIDFromMountPoint(dirs.SnapdStateDir(dirs.GlobalRootDir)) | |||
dataDir := dirs.GlobalRootDir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes / the correct mount point to look at to find the data disk on classic? maybe a small comment is needed to explain this.
overlord/fdestate/fdemgr_test.go
Outdated
c.Check(primaryKey.Digest.Digest, DeepEquals, []byte{5, 6, 7, 8}) | ||
} | ||
|
||
func (s *fdeMgrSuite) TestGetManagerFromStateWithWritable(c *C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, both tests seem identical, maybe the could be merged
func (s *fdeMgrSuite) TestGetManagerFromStateWithWritable(c *C) { | |
func (s *fdeMgrSuite) testGetManagerFromState(c *C, onClassic bool) | |
st := s.st | |
defer release.MockOnClassic(onClassic)() | |
manager := s.startedManager(c, onClassic) | |
st.Lock() | |
defer st.Unlock() | |
foundManager := fdestate.FdeMgr(st) | |
c.Check(foundManager, Equals, manager) | |
var fdeSt fdestate.FdeState | |
err := st.Get("fde", &fdeSt) | |
c.Assert(err, IsNil) | |
primaryKey, hasPrimaryKey := fdeSt.PrimaryKeys[0] | |
c.Assert(hasPrimaryKey, Equals, true) | |
c.Check(crypto.Hash(primaryKey.Digest.Algorithm), Equals, crypto.Hash(crypto.SHA256)) | |
c.Check(primaryKey.Digest.Salt, DeepEquals, []byte{1, 2, 3, 4}) | |
c.Check(primaryKey.Digest.Digest, DeepEquals, []byte{5, 6, 7, 8}) | |
} | |
func (s *fdeMgrSuite) TestGetManagerFromState(c *C) { | |
const onClassic = true | |
s.testGetManagerFromState(c, onClassic) | |
} | |
func (s *fdeMgrSuite) TestGetManagerFromStateWithWritable(c *C) { | |
const onClassic = false | |
s.testGetManagerFromState(c, onClassic) | |
} | |
overlord/fdestate/fdemgr_test.go
Outdated
@@ -82,6 +84,8 @@ func (s *fdeMgrSuite) SetUpTest(c *C) { | |||
} | |||
err := m.WriteTo(dirs.GlobalRootDir) | |||
c.Assert(err, IsNil) | |||
|
|||
s.AddCleanup(release.MockOnClassic(true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bboozzoo asked for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
61223f5
to
a80d97c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick
overlord/fdestate/fdestate.go
Outdated
if !release.OnClassic { | ||
// If on Core /writable is a bind mount from data dir | ||
dataDir = filepath.Join(dirs.GlobalRootDir, "writable") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: it feels like this logic should be a function of the dirs package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
We used a path that is not a mount point on hybrid to discover the data disk. Instead we now use / for hybrid, and /writable on core.
491569b
to
1d6746f
Compare
We used a path that is not a mount point on hybrid to discover the data disk. Instead we now use / for hybrid, and /writable on core.