fix(cluster): Alle Placeholder-Rows bei autoRegister bereinigen

AgentRegisterPeer löschte bisher nur den neuen prenode-{fqdn}-Placeholder.
Alte pre-{timestamp}-Rows (aus Versionen vor 1.1.158) blieben stehen und
zeigten dauerhaft status=joining.

Fix: DeletePlaceholdersByFQDN löscht ALLE ha_nodes-Rows mit gleicher FQDN
außer der echten Node-ID — unabhängig vom ID-Format.

Auch preRegisterByFQDN nutzt jetzt das stabile prenode-{fqdn}-Format.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-05-29 18:33:50 +02:00
parent 8d83de6b0f
commit 357113e7be
6 changed files with 18 additions and 11 deletions

View File

@@ -115,6 +115,16 @@ func (s *Store) Delete(ctx context.Context, id string) error {
return nil
}
// DeletePlaceholdersByFQDN removes all ha_nodes rows that share the given
// FQDN but do NOT have the specified keepID. Used to clean up pre-registered
// placeholder rows (both old "pre-{timestamp}" and new "prenode-{fqdn}"
// style) after a real autoRegister arrives via mTLS.
func (s *Store) DeletePlaceholdersByFQDN(ctx context.Context, fqdn, keepID string) error {
_, err := s.Pool.Exec(ctx,
`DELETE FROM ha_nodes WHERE fqdn = $1 AND id != $2`, fqdn, keepID)
return err
}
// EnsureSelfRegistered mints the node-id if needed, builds the row
// from setup.json + os.Hostname + node.conf, and upserts it. Called
// on edgeguard-api boot AFTER the DB pool is reachable.