Skip to content

Commit 43f21c0

Browse files
authored
Improve LUKS escrow trigger error messages (#24030)
- [x] Added/updated tests ~~- [ ] Manual QA for all new/changed functionality~~ Testing as part of E2E QA
1 parent fa93f34 commit 43f21c0

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

ee/server/service/devices.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (svc *Service) TriggerLinuxDiskEncryptionEscrow(ctx context.Context, host *
182182

183183
func (svc *Service) validateReadyForLinuxEscrow(ctx context.Context, host *fleet.Host) error {
184184
if !host.IsLUKSSupported() {
185-
return &fleet.BadRequestError{Message: "Host platform does not support key escrow"}
185+
return &fleet.BadRequestError{Message: "Fleet does not yet support creating LUKS disk encryption keys on this platform."}
186186
}
187187

188188
ac, err := svc.ds.AppConfig(ctx)
@@ -192,20 +192,20 @@ func (svc *Service) validateReadyForLinuxEscrow(ctx context.Context, host *fleet
192192

193193
if host.TeamID == nil {
194194
if !ac.MDM.EnableDiskEncryption.Value {
195-
return &fleet.BadRequestError{Message: "Disk encryption is not enabled for hosts not assigned to a team"}
195+
return &fleet.BadRequestError{Message: "Disk encryption is not enabled for hosts not assigned to a team."}
196196
}
197197
} else {
198198
tc, err := svc.ds.TeamMDMConfig(ctx, *host.TeamID)
199199
if err != nil {
200200
return err
201201
}
202202
if !tc.EnableDiskEncryption {
203-
return &fleet.BadRequestError{Message: "Disk encryption is not enabled for this host's team"}
203+
return &fleet.BadRequestError{Message: "Disk encryption is not enabled for this host's team."}
204204
}
205205
}
206206

207207
if host.DiskEncryptionEnabled == nil || !*host.DiskEncryptionEnabled {
208-
return &fleet.BadRequestError{Message: "Host's disk is not encrypted. Please enable disk encryption for this host."}
208+
return &fleet.BadRequestError{Message: "Host's disk is not encrypted. Please encrypt your disk first."}
209209
}
210210

211211
// We have to pull Orbit info because the auth context doesn't fill in host.OrbitVersion
@@ -215,7 +215,7 @@ func (svc *Service) validateReadyForLinuxEscrow(ctx context.Context, host *fleet
215215
}
216216

217217
if orbitInfo == nil || !fleet.IsAtLeastVersion(orbitInfo.Version, fleet.MinOrbitLUKSVersion) {
218-
return &fleet.BadRequestError{Message: "Host's Orbit version does not support this feature. Please upgrade Orbit to the latest version."}
218+
return &fleet.BadRequestError{Message: "Your version of fleetd does not support creating disk encryption keys on Linux. Please upgrade fleetd, then click Refetch, then try again."}
219219
}
220220

221221
return svc.ds.AssertHasNoEncryptionKeyStored(ctx, host.ID)

server/service/devices_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ func TestTriggerLinuxDiskEncryptionEscrow(t *testing.T) {
514514

515515
// invalid platform
516516
err := svc.TriggerLinuxDiskEncryptionEscrow(ctx, host)
517-
require.ErrorContains(t, err, "Host platform does not support key escrow")
517+
require.ErrorContains(t, err, "Fleet does not yet support creating LUKS disk encryption keys on this platform.")
518518
require.True(t, ds.IsHostPendingEscrowFuncInvoked)
519519

520520
// valid platform, no-team, encryption not enabled
@@ -524,7 +524,7 @@ func TestTriggerLinuxDiskEncryptionEscrow(t *testing.T) {
524524
return appConfig, nil
525525
}
526526
err = svc.TriggerLinuxDiskEncryptionEscrow(ctx, host)
527-
require.ErrorContains(t, err, "Disk encryption is not enabled for hosts not assigned to a team")
527+
require.ErrorContains(t, err, "Disk encryption is not enabled for hosts not assigned to a team.")
528528

529529
// valid platform, team, encryption not enabled
530530
host.TeamID = ptr.Uint(1)
@@ -534,15 +534,15 @@ func TestTriggerLinuxDiskEncryptionEscrow(t *testing.T) {
534534
return teamConfig, nil
535535
}
536536
err = svc.TriggerLinuxDiskEncryptionEscrow(ctx, host)
537-
require.ErrorContains(t, err, "Disk encryption is not enabled for this host's team")
537+
require.ErrorContains(t, err, "Disk encryption is not enabled for this host's team.")
538538

539539
// valid platform, team, host disk is not encrypted or unknown encryption state
540540
teamConfig = &fleet.TeamMDM{EnableDiskEncryption: true}
541541
err = svc.TriggerLinuxDiskEncryptionEscrow(ctx, host)
542-
require.ErrorContains(t, err, "Host's disk is not encrypted. Please enable disk encryption for this host.")
542+
require.ErrorContains(t, err, "Host's disk is not encrypted. Please encrypt your disk first.")
543543
host.DiskEncryptionEnabled = ptr.Bool(false)
544544
err = svc.TriggerLinuxDiskEncryptionEscrow(ctx, host)
545-
require.ErrorContains(t, err, "Host's disk is not encrypted. Please enable disk encryption for this host.")
545+
require.ErrorContains(t, err, "Host's disk is not encrypted. Please encrypt your disk first.")
546546

547547
// No Fleet Desktop
548548
host.DiskEncryptionEnabled = ptr.Bool(true)
@@ -551,7 +551,7 @@ func TestTriggerLinuxDiskEncryptionEscrow(t *testing.T) {
551551
return orbitInfo, nil
552552
}
553553
err = svc.TriggerLinuxDiskEncryptionEscrow(ctx, host)
554-
require.ErrorContains(t, err, "Host's Orbit version does not support this feature. Please upgrade Orbit to the latest version.")
554+
require.ErrorContains(t, err, "Your version of fleetd does not support creating disk encryption keys on Linux. Please upgrade fleetd, then click Refetch, then try again.")
555555

556556
// Encryption key is already escrowed
557557
orbitInfo.Version = fleet.MinOrbitLUKSVersion

0 commit comments

Comments
 (0)