Skip to content

Commit 5998f0f

Browse files
authored
overlord/devicestate: fix do-install-setup-storage-encryption check for preinstall context availability (canonical#16584)
* overlord/devicestate: fix do-install-setup-storage-encryption check for preinstall context availability * fixup! overlord/devicestate: fix do-install-setup-storage-encryption check for preinstall context availability
1 parent 6fd1bba commit 5998f0f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

overlord/devicestate/devicestate_systems_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,12 +3037,18 @@ func mockHelperForEncryptionAvailabilityCheck(s suiteWithAddCleanup, c *C, isSup
30373037
}
30383038
}
30393039

3040-
if isSupportedUbuntuHybrid && cacheLabel != "" {
3040+
if cacheLabel != "" {
30413041
// populate the cache with encryption support information that
3042-
// includes a check context similar to having performed an
3043-
// initial preinstall check
3042+
// mimics what would happen when a preinstall check takes place
3043+
// as per usual installer flow
30443044
encInfo := &install.EncryptionSupportInfo{}
3045-
encInfo.SetAvailabilityCheckContext(&secboot.PreinstallCheckContext{})
3045+
if isSupportedUbuntuHybrid {
3046+
// hybrid installation flow populates the preinstall check context
3047+
encInfo.SetAvailabilityCheckContext(&secboot.PreinstallCheckContext{})
3048+
}
3049+
// non-hydrid install flow uses the simple availability check that does not produce
3050+
// a preinstall check context
3051+
30463052
s.DeviceManager().SetEncryptionSupportInfoInCacheUnlocked(cacheLabel, encInfo)
30473053
}
30483054

overlord/devicestate/handlers_install.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,9 @@ func (m *DeviceManager) doInstallSetupStorageEncryption(t *state.Task, _ *tomb.T
13711371
}
13721372

13731373
var checkAction *secboot.PreinstallAction
1374-
if m.readCacheEncryptionSupportInfoLocked(systemLabel) != nil {
1374+
cachedEncInfo := m.readCacheEncryptionSupportInfoLocked(systemLabel)
1375+
1376+
if cachedEncInfo != nil && cachedEncInfo.CheckContext() != nil {
13751377
// If a cached context is available, the preinstall check was previously run
13761378
// and must be repeated. Set an action to signal reuse of the preinstall check
13771379
// context. Use the inert "ActionNone" to repeat the check without requesting

0 commit comments

Comments
 (0)