@@ -87,8 +87,8 @@ impl Service {
8787 let short_key = instance. get_short_key ( ) ;
8888 let old_instance = self . instances . get ( & key) ;
8989 let mut replace_old_client_id = None ;
90- let mut mark_add_perpetual_instance = !instance . ephemeral ;
91- let mut mark_remove_perpetual_instance = instance . ephemeral ;
90+ let mut mark_add_perpetual_instance = false ;
91+ let mut mark_remove_perpetual_instance = false ;
9292 let mut perpetual_changed = false ;
9393 if let Some ( old_instance) = old_instance {
9494 instance. register_time = old_instance. register_time ;
@@ -172,14 +172,11 @@ impl Service {
172172 rtype = UpdateInstanceType :: UpdateTime ;
173173 }
174174 }
175- mark_add_perpetual_instance = !instance. ephemeral ;
176- mark_remove_perpetual_instance = instance. ephemeral ;
177- if old_instance. ephemeral {
178- mark_remove_perpetual_instance = false ;
179- } else {
180- mark_add_perpetual_instance = false ;
181- }
175+ mark_add_perpetual_instance = !instance. ephemeral && old_instance. ephemeral ;
176+ mark_remove_perpetual_instance = instance. ephemeral && !old_instance. ephemeral ;
182177 } else {
178+ mark_add_perpetual_instance = !instance. ephemeral ;
179+ mark_remove_perpetual_instance = false ;
183180 //新增的尝试使用高优先级metadata
184181 if let Some ( priority_metadata) = self . instance_metadata_map . get ( & short_key) {
185182 instance. metadata = priority_metadata. clone ( ) ;
@@ -208,8 +205,7 @@ impl Service {
208205 self . perpetual_host_set . insert ( short_key) ;
209206 }
210207 perpetua_type = UpdatePerpetualType :: New ;
211- }
212- if mark_remove_perpetual_instance {
208+ } else if mark_remove_perpetual_instance {
213209 let short_key = new_instance. get_short_key ( ) ;
214210 self . perpetual_host_set . remove ( & short_key) ;
215211 perpetua_type = UpdatePerpetualType :: Remove ;
0 commit comments