@@ -970,35 +970,38 @@ impl AdminApp {
970970 #[ cfg( not( feature = "privacy-mode" ) ) ]
971971 log:: info!(
972972 target: "fluxheim::load_balancer" ,
973- "load balancer member state updated vhost={} route={} scope={} member={} state={} address={} alias={} persistent=false " ,
973+ "load balancer member state updated vhost={} route={} scope={} member={} state={} address={} alias={} persistent={} " ,
974974 result. vhost,
975975 result. route. as_deref( ) . unwrap_or( "" ) ,
976976 scope,
977977 result. member,
978978 result. state. as_str( ) ,
979979 result. address,
980- result. alias. as_deref( ) . unwrap_or( "" )
980+ result. alias. as_deref( ) . unwrap_or( "" ) ,
981+ result. persistent
981982 ) ;
982983 #[ cfg( feature = "privacy-mode" ) ]
983984 log:: info!(
984985 target: "fluxheim::load_balancer" ,
985- "load balancer member state updated vhost={} route={} scope={} member={} state={} alias={} persistent=false " ,
986+ "load balancer member state updated vhost={} route={} scope={} member={} state={} alias={} persistent={} " ,
986987 result. vhost,
987988 result. route. as_deref( ) . unwrap_or( "" ) ,
988989 scope,
989990 result. member,
990991 result. state. as_str( ) ,
991- result. alias. as_deref( ) . unwrap_or( "" )
992+ result. alias. as_deref( ) . unwrap_or( "" ) ,
993+ result. persistent
992994 ) ;
993995 log:: info!(
994996 target: "fluxheim::audit" ,
995- "load balancer member state updated vhost={} route={} scope={} member={} state={} alias={} persistent=false " ,
997+ "load balancer member state updated vhost={} route={} scope={} member={} state={} alias={} persistent={} " ,
996998 result. vhost,
997999 result. route. as_deref( ) . unwrap_or( "" ) ,
9981000 scope,
9991001 result. member,
10001002 result. state. as_str( ) ,
1001- result. alias. as_deref( ) . unwrap_or( "" )
1003+ result. alias. as_deref( ) . unwrap_or( "" ) ,
1004+ result. persistent
10021005 ) ;
10031006 record_load_balancer_event (
10041007 & result. vhost ,
@@ -1019,7 +1022,7 @@ impl AdminApp {
10191022 #[ cfg( not( feature = "privacy-mode" ) ) ]
10201023 body. insert ( "address" . to_owned ( ) , json ! ( result. address) ) ;
10211024 body. insert ( "alias" . to_owned ( ) , json ! ( result. alias) ) ;
1022- body. insert ( "persistent" . to_owned ( ) , json ! ( false ) ) ;
1025+ body. insert ( "persistent" . to_owned ( ) , json ! ( result . persistent ) ) ;
10231026 json_response_value ( StatusCode :: OK , & Value :: Object ( body) )
10241027 }
10251028 Err ( error) if error. kind ( ) == io:: ErrorKind :: InvalidInput => {
@@ -1090,7 +1093,7 @@ impl AdminApp {
10901093 #[ cfg( not( feature = "privacy-mode" ) ) ]
10911094 log:: info!(
10921095 target: "fluxheim::load_balancer" ,
1093- "load balancer member weight updated vhost={} route={} scope={} member={} configured_weight={} effective_weight={} runtime_weight_override={} address={} alias={} persistent=false " ,
1096+ "load balancer member weight updated vhost={} route={} scope={} member={} configured_weight={} effective_weight={} runtime_weight_override={} address={} alias={} persistent={} " ,
10941097 result. vhost,
10951098 result. route. as_deref( ) . unwrap_or( "" ) ,
10961099 scope,
@@ -1102,12 +1105,13 @@ impl AdminApp {
11021105 . map( |weight| weight. to_string( ) )
11031106 . unwrap_or_else( || "none" . to_owned( ) ) ,
11041107 result. address,
1105- result. alias. as_deref( ) . unwrap_or( "" )
1108+ result. alias. as_deref( ) . unwrap_or( "" ) ,
1109+ result. persistent
11061110 ) ;
11071111 #[ cfg( feature = "privacy-mode" ) ]
11081112 log:: info!(
11091113 target: "fluxheim::load_balancer" ,
1110- "load balancer member weight updated vhost={} route={} scope={} member={} configured_weight={} effective_weight={} runtime_weight_override={} alias={} persistent=false " ,
1114+ "load balancer member weight updated vhost={} route={} scope={} member={} configured_weight={} effective_weight={} runtime_weight_override={} alias={} persistent={} " ,
11111115 result. vhost,
11121116 result. route. as_deref( ) . unwrap_or( "" ) ,
11131117 scope,
@@ -1118,11 +1122,12 @@ impl AdminApp {
11181122 . runtime_weight_override
11191123 . map( |weight| weight. to_string( ) )
11201124 . unwrap_or_else( || "none" . to_owned( ) ) ,
1121- result. alias. as_deref( ) . unwrap_or( "" )
1125+ result. alias. as_deref( ) . unwrap_or( "" ) ,
1126+ result. persistent
11221127 ) ;
11231128 log:: info!(
11241129 target: "fluxheim::audit" ,
1125- "load balancer member weight updated vhost={} route={} scope={} member={} configured_weight={} effective_weight={} runtime_weight_override={} alias={} persistent=false " ,
1130+ "load balancer member weight updated vhost={} route={} scope={} member={} configured_weight={} effective_weight={} runtime_weight_override={} alias={} persistent={} " ,
11261131 result. vhost,
11271132 result. route. as_deref( ) . unwrap_or( "" ) ,
11281133 scope,
@@ -1133,7 +1138,8 @@ impl AdminApp {
11331138 . runtime_weight_override
11341139 . map( |weight| weight. to_string( ) )
11351140 . unwrap_or_else( || "none" . to_owned( ) ) ,
1136- result. alias. as_deref( ) . unwrap_or( "" )
1141+ result. alias. as_deref( ) . unwrap_or( "" ) ,
1142+ result. persistent
11371143 ) ;
11381144 record_load_balancer_event (
11391145 & result. vhost ,
@@ -1165,7 +1171,7 @@ impl AdminApp {
11651171 #[ cfg( not( feature = "privacy-mode" ) ) ]
11661172 body. insert ( "address" . to_owned ( ) , json ! ( result. address) ) ;
11671173 body. insert ( "alias" . to_owned ( ) , json ! ( result. alias) ) ;
1168- body. insert ( "persistent" . to_owned ( ) , json ! ( false ) ) ;
1174+ body. insert ( "persistent" . to_owned ( ) , json ! ( result . persistent ) ) ;
11691175 json_response_value ( StatusCode :: OK , & Value :: Object ( body) )
11701176 }
11711177 Err ( error) if error. kind ( ) == io:: ErrorKind :: InvalidInput => {
@@ -1217,11 +1223,12 @@ impl AdminApp {
12171223 } ;
12181224 log:: info!(
12191225 target: "fluxheim::load_balancer" ,
1220- "load balancer persistence table cleared vhost={} route={} scope={} cleared_entries={} persistent=false " ,
1226+ "load balancer persistence table cleared vhost={} route={} scope={} cleared_entries={} persistent={} " ,
12211227 result. vhost,
12221228 result. route. as_deref( ) . unwrap_or( "" ) ,
12231229 scope,
1224- result. cleared_entries
1230+ result. cleared_entries,
1231+ result. persistent
12251232 ) ;
12261233 record_load_balancer_event (
12271234 & result. vhost ,
@@ -1237,7 +1244,7 @@ impl AdminApp {
12371244 "route" : result. route,
12381245 "scope" : scope,
12391246 "cleared_entries" : result. cleared_entries,
1240- "persistent" : false ,
1247+ "persistent" : result . persistent ,
12411248 } ) ,
12421249 )
12431250 }
@@ -3814,7 +3821,7 @@ mod tests {
38143821 use crate :: config_route:: RouteConfig ;
38153822 use crate :: proxy:: { FluxProxy , ProxyHealthReporter , ProxyHealthSignal } ;
38163823 use crate :: snapshot:: SnapshotStore ;
3817- use crate :: test_support:: unique_temp_path;
3824+ use crate :: test_support:: { safe_child_path , unique_temp_path} ;
38183825 #[ cfg( unix) ]
38193826 use crate :: test_support:: { unique_group_writable_child, unique_world_writable_child} ;
38203827
@@ -3911,6 +3918,16 @@ mod tests {
39113918 }
39123919 }
39133920
3921+ #[ cfg( feature = "load-balancer" ) ]
3922+ fn load_balancer_persistent_admin_config ( ) -> Config {
3923+ let root = unique_temp_path ( "admin-lb-runtime-state" ) ;
3924+ std:: fs:: create_dir_all ( & root) . unwrap ( ) ;
3925+ let mut config = load_balancer_admin_config ( ) ;
3926+ config. vhosts [ 0 ] . proxy . load_balance . runtime_state_file =
3927+ Some ( safe_child_path ( & root, "lb-state.json" ) ) ;
3928+ config
3929+ }
3930+
39143931 fn set_test_runtime_state (
39153932 app : & AdminApp ,
39163933 runtime_snapshot : Option < String > ,
@@ -4170,6 +4187,45 @@ mod tests {
41704187 assert_eq ! ( body[ "runtime_weight_override" ] , Value :: Null ) ;
41714188 }
41724189
4190+ #[ cfg( feature = "load-balancer" ) ]
4191+ #[ test]
4192+ fn load_balancer_mutation_endpoints_report_persistent_state_file ( ) {
4193+ #[ cfg( feature = "tls-rustls-backend" ) ]
4194+ let _ = crate :: tls:: install_rustls_crypto_provider ( ) ;
4195+
4196+ let app = app_with_config ( load_balancer_persistent_admin_config ( ) ) ;
4197+
4198+ let response = app. handle (
4199+ "POST" ,
4200+ "/_fluxheim/load-balancer/member-state" ,
4201+ Some ( "vhost=one&member=app-a&state=disable" ) ,
4202+ & auth_headers ( ) ,
4203+ ) ;
4204+ assert_eq ! ( response. status, StatusCode :: OK ) ;
4205+ let body: Value = serde_json:: from_slice ( & response. body ) . unwrap ( ) ;
4206+ assert_eq ! ( body[ "persistent" ] , true ) ;
4207+
4208+ let response = app. handle (
4209+ "POST" ,
4210+ "/_fluxheim/load-balancer/member-weight" ,
4211+ Some ( "vhost=one&member=app-a&weight=5" ) ,
4212+ & auth_headers ( ) ,
4213+ ) ;
4214+ assert_eq ! ( response. status, StatusCode :: OK ) ;
4215+ let body: Value = serde_json:: from_slice ( & response. body ) . unwrap ( ) ;
4216+ assert_eq ! ( body[ "persistent" ] , true ) ;
4217+
4218+ let response = app. handle (
4219+ "POST" ,
4220+ "/_fluxheim/load-balancer/persistence/clear" ,
4221+ Some ( "vhost=one" ) ,
4222+ & auth_headers ( ) ,
4223+ ) ;
4224+ assert_eq ! ( response. status, StatusCode :: OK ) ;
4225+ let body: Value = serde_json:: from_slice ( & response. body ) . unwrap ( ) ;
4226+ assert_eq ! ( body[ "persistent" ] , true ) ;
4227+ }
4228+
41734229 #[ cfg( feature = "load-balancer" ) ]
41744230 #[ test]
41754231 fn load_balancer_runtime_weight_parser_documents_all_reset_keywords ( ) {
0 commit comments