Skip to content

Commit ff521c1

Browse files
committed
gw: preserve cached port_attrs on legacy CVM re-register
A re-registration from a legacy CVM carries port_attrs=None, which previously wiped any value learned at an earlier registration or lazy fetch. Gateway restart + CVM re-register would then force a redundant Info() fetch. Keep cached attrs unless the caller actively reports new ones; same instance_id implies same compose_hash, so the cache cannot go stale.
1 parent 87ce31c commit ff521c1

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

gateway/src/main_service.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,10 +848,14 @@ impl ProxyState {
848848
// Update reg_time so other nodes will pick up the change
849849
existing.reg_time = SystemTime::now();
850850
}
851-
// Always update port_attrs from the latest registration so changes
852-
// take effect across re-registrations. A `None` here (legacy CVM)
853-
// wipes any previously-cached attrs so the lazy fetch path runs again.
854-
existing.port_attrs = port_attrs.clone();
851+
// Only override cached port_attrs when the caller actually reports
852+
// them. A `None` request (legacy CVM) means "I don't know" — don't
853+
// wipe attrs learned at an earlier registration or lazy fetch. Same
854+
// instance_id implies same compose_hash, so cached attrs can't be
855+
// stale relative to the real app-compose.
856+
if port_attrs.is_some() {
857+
existing.port_attrs = port_attrs.clone();
858+
}
855859
let existing = existing.clone();
856860
if self.valid_ip(existing.ip) {
857861
// Sync existing instance to KvStore (might be from legacy state)

0 commit comments

Comments
 (0)