@@ -792,7 +792,8 @@ def _validate_and_pair_ha(
792792 4. Interface speed validation (hsci vs data plane)
793793 5. Pre-flight compatibility checks (resource_class, roles)
794794
795- Sets extra.ha_operational = True only when ALL checks pass.
795+ Sets extra.ha_operational = True only when ALL checks pass;
796+ otherwise the reason goes in last_error.
796797 Does NOT modify mate node's extra fields or transition states.
797798 The enroll-fw workflow will read ha_operational from both devices
798799 and decide whether to promote.
@@ -815,7 +816,7 @@ def _validate_and_pair_ha(
815816 f"ha1-b={ ha1_b_state } , hsci={ hsci_state } "
816817 )
817818 LOG .info ("[node:%s] %s" , node .uuid , reason )
818- extra [ "ha_check_reason" ] = reason
819+ node . last_error = reason
819820 return
820821
821822 LOG .info ("[node:%s] HA interfaces operational" , node .uuid )
@@ -831,7 +832,7 @@ def _validate_and_pair_ha(
831832 f"conn={ peer_conn } , peer_serial={ peer_serial } "
832833 )
833834 LOG .info ("[node:%s] %s" , node .uuid , reason )
834- extra [ "ha_check_reason" ] = reason
835+ node . last_error = reason
835836 return
836837
837838 if peer_serial != mate_serial :
@@ -840,7 +841,7 @@ def _validate_and_pair_ha(
840841 f"expected { mate_serial } "
841842 )
842843 LOG .warning ("[node:%s] %s" , node .uuid , reason )
843- extra [ "ha_check_reason" ] = reason
844+ node . last_error = reason
844845 return
845846
846847 LOG .info ("[node:%s] HA peer connected: %s" , node .uuid , peer_serial )
@@ -850,7 +851,7 @@ def _validate_and_pair_ha(
850851 if not mate :
851852 reason = f"Mate node { mate_serial } not found in Ironic"
852853 LOG .info ("[node:%s] %s" , node .uuid , reason )
853- extra [ "ha_check_reason" ] = reason
854+ node . last_error = reason
854855 return
855856
856857 # Step 4: Pre-flight compatibility checks
@@ -865,7 +866,7 @@ def _validate_and_pair_ha(
865866 f"my serial is { my_serial } "
866867 )
867868 LOG .warning ("[node:%s] %s" , node .uuid , reason )
868- extra [ "ha_check_reason" ] = reason
869+ node . last_error = reason
869870 return
870871
871872 # Check resource class match
@@ -875,7 +876,7 @@ def _validate_and_pair_ha(
875876 f"mate={ mate .resource_class } "
876877 )
877878 LOG .warning ("[node:%s] %s" , node .uuid , reason )
878- extra [ "ha_check_reason" ] = reason
879+ node . last_error = reason
879880 return
880881
881882 # Check opposite HA roles
@@ -884,13 +885,13 @@ def _validate_and_pair_ha(
884885 if not my_role or not mate_role :
885886 reason = f"Missing HA roles: self={ my_role } , mate={ mate_role } "
886887 LOG .warning ("[node:%s] %s" , node .uuid , reason )
887- extra [ "ha_check_reason" ] = reason
888+ node . last_error = reason
888889 return
889890
890891 if my_role == mate_role :
891892 reason = f"Same HA role on both devices: { my_role } "
892893 LOG .warning ("[node:%s] %s" , node .uuid , reason )
893- extra [ "ha_check_reason" ] = reason
894+ node . last_error = reason
894895 return
895896
896897 LOG .info (
@@ -906,7 +907,7 @@ def _validate_and_pair_ha(
906907 if not mate_address :
907908 reason = "Mate has no management_ip"
908909 LOG .warning ("[node:%s] %s" , node .uuid , reason )
909- extra [ "ha_check_reason" ] = reason
910+ node . last_error = reason
910911 return
911912
912913 mate_client = panos_api .PanosClient (mate_address )
@@ -921,13 +922,13 @@ def _validate_and_pair_ha(
921922 f"got { mate_peer_serial } , expected { my_serial } "
922923 )
923924 LOG .warning ("[node:%s] %s" , node .uuid , reason )
924- extra [ "ha_check_reason" ] = reason
925+ node . last_error = reason
925926 return
926927
927928 if mate_peer_conn != "up" :
928929 reason = f"Mate peer connection not up: { mate_peer_conn } "
929930 LOG .warning ("[node:%s] %s" , node .uuid , reason )
930- extra [ "ha_check_reason" ] = reason
931+ node . last_error = reason
931932 return
932933
933934 LOG .info ("[node:%s] Bidirectional HA validation passed" , node .uuid )
@@ -955,7 +956,7 @@ def _validate_and_pair_ha(
955956 "HA pair must be on different switches."
956957 )
957958 LOG .error ("[node:%s] %s" , node .uuid , error_msg )
958- extra [ "ha_check_reason" ] = error_msg
959+ node . last_error = error_msg
959960 raise exception .HardwareInspectionFailure (error_msg )
960961
961962 LOG .info (
@@ -980,7 +981,7 @@ def _validate_and_pair_ha(
980981 LOG .info ("[node:%s] All HA validation checks passed" , node .uuid )
981982 extra ["ha_operational" ] = True
982983 # Clear any previous failure reason
983- extra . pop ( "ha_check_reason" , None )
984+ node . last_error = None
984985
985986 except Exception as e :
986987 LOG .exception (
@@ -989,7 +990,7 @@ def _validate_and_pair_ha(
989990 e ,
990991 )
991992 # Set failure reason for troubleshooting
992- extra [ "ha_check_reason" ] = str (e )
993+ node . last_error = str (e )
993994 # Don't raise - allow inspection to complete even if pairing fails
994995 finally :
995996 # Always save ha_operational status (True if all checks passed, False otherwise)
0 commit comments