@@ -18,6 +18,13 @@ type temporaryPreparation struct {
1818 staging bool
1919}
2020
21+ // temporaryRecoveryGate carries only source-defined descriptions, so the
22+ // readiness timeout can report the last failed check without native diagnostics.
23+ type temporaryRecoveryGate string
24+
25+ func (g temporaryRecoveryGate ) Error () string { return "temporary recovery waiting for " + string (g ) }
26+ func (g temporaryRecoveryGate ) Unwrap () error { return errInventory }
27+
2128// prepare advances the separately journaled unused-worker profile, recording reset
2229// intent before its single request and accepting recovery only after native proof.
2330// A resumed reset request observes recovery without issuing another reset.
@@ -51,7 +58,15 @@ func (p *temporaryPreparation) prepare(ctx context.Context) error {
5158 }
5259 }
5360 if p .j .Phase == "reset-requested" {
54- if err := waitReady (ctx , func (ctx context.Context ) error { _ , err := p .unusedPostState (ctx ); return err }); err != nil {
61+ var checkErr error
62+ if err := waitReady (ctx , func (ctx context.Context ) error {
63+ _ , checkErr = p .unusedPostState (ctx )
64+ return checkErr
65+ }); err != nil {
66+ var gate temporaryRecoveryGate
67+ if errors .As (checkErr , & gate ) {
68+ return errors .Join (err , gate )
69+ }
5570 return err
5671 }
5772 var stagedUUID string
@@ -433,27 +448,27 @@ func (p *temporaryPreparation) resetUnused(ctx context.Context) error {
433448func (p temporaryPreparation ) unusedPostState (ctx context.Context ) (node object , err error ) {
434449 n , address , err := p .node (ctx , true )
435450 if err != nil {
436- return nil , err
451+ return nil , temporaryRecoveryGate ( "the original worker and hardware identity" )
437452 }
438453 status := valueObject (n , "status" )
439454 boot := text (n , "status" , "nodeInfo" , "bootID" )
440455 if ! ready (status ) || ! hugepagesReady (n ) || ! inventoryBoot .MatchString (boot ) || boot == p .j .OriginalBootID {
441- return nil , errInventory
456+ return nil , temporaryRecoveryGate ( "a ready worker with huge pages and a new boot" )
442457 }
443458 if p .retainsRaw () {
444459 if _ , err = p .readRetainedRecovery (ctx , address , boot , false ); err != nil && p .j .Phase == "reset-requested" {
445460 _ , err = p .readRetainedRecovery (ctx , address , boot , true )
446461 }
447462 if err != nil {
448- return nil , err
463+ return nil , temporaryRecoveryGate ( "the retained raw partition and staged layout" )
449464 }
450465 lh , err := p .storageNode (ctx )
451466 if err != nil || ! unusedStorageFenced (lh ) {
452- return nil , errInventory
467+ return nil , temporaryRecoveryGate ( "the empty fenced Longhorn node" )
453468 }
454469 current , currentAddress , err := p .node (ctx , true )
455470 if err != nil || currentAddress != address || text (current , "status" , "nodeInfo" , "bootID" ) != boot {
456- return nil , errInventory
471+ return nil , temporaryRecoveryGate ( "a stable worker identity and boot" )
457472 }
458473 return current , nil
459474 }
@@ -463,50 +478,50 @@ func (p temporaryPreparation) unusedPostState(ctx context.Context) (node object,
463478 }
464479 reader , closeReader , err := factory (ctx , address )
465480 if err != nil || reader == nil || closeReader == nil {
466- return nil , errInventory
481+ return nil , temporaryRecoveryGate ( "a node-bound native reader" )
467482 }
468483 defer func () {
469484 if closeReader () != nil {
470485 node = nil
471- err = errInventory
486+ err = temporaryRecoveryGate ( "clean native reader shutdown" )
472487 }
473488 }()
474489 actualBoot , err := reader .BootID (ctx )
475490 if err != nil || actualBoot != boot {
476- return nil , errInventory
491+ return nil , temporaryRecoveryGate ( "the native boot identity matching Kubernetes" )
477492 }
478493 if err = p .verifyUnusedLayout (ctx , address ); err != nil {
479- return nil , err
494+ return nil , temporaryRecoveryGate ( "the reviewed staged volume configuration" )
480495 }
481496 raw , err := p .c .talosVolume (ctx , address , "r-longhorn" )
482497 if err != nil {
483- return nil , err
498+ return nil , temporaryRecoveryGate ( "readable raw volume status" )
484499 }
485500 eph , err := p .c .talosVolume (ctx , address , "EPHEMERAL" )
486501 if err != nil {
487- return nil , err
502+ return nil , temporaryRecoveryGate ( "readable EPHEMERAL volume status" )
488503 }
489504 rawGiB := uint64 (permanentRawDiskGiB )
490505 if p .staging {
491506 rawGiB = stagingRawDiskGiB
492507 }
493508 if err = verifyEncryptedRawDisk (raw , eph , rawGiB ); err != nil {
494- return nil , err
509+ return nil , temporaryRecoveryGate ( "the expected encrypted partition geometry" )
495510 }
496511 uuid , err := recoveredEphemeralUUID (ctx , address , eph , factory )
497512 if err != nil || p .j .EphemeralUUID == "" || strings .EqualFold (uuid , p .j .EphemeralUUID ) {
498- return nil , errInventory
513+ return nil , temporaryRecoveryGate ( "the new encrypted EPHEMERAL identity" )
499514 }
500515 recheckedBoot , err := reader .BootID (ctx )
501516 if err != nil || recheckedBoot != actualBoot {
502- return nil , errInventory
517+ return nil , temporaryRecoveryGate ( "the same native boot after reading storage" )
503518 }
504519 lh , err := p .storageNode (ctx )
505520 if err != nil {
506- return nil , err
521+ return nil , temporaryRecoveryGate ( "the original Longhorn node identity" )
507522 }
508523 if ! unusedStorageFenced (lh ) {
509- return nil , errInventory
524+ return nil , temporaryRecoveryGate ( "the empty fenced Longhorn node" )
510525 }
511526 return n , nil
512527}
0 commit comments