project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

[Bug] Add Cluster dialog keeps the previous cluster's name and credentials

Open Drauku opened this issue 2 months ago • 2 comments

Describe the bug

The Add Cluster dialog keeps the previous submission's values. AddClusterModal is mounted permanently and hides itself with if (!isOpen) return null, but its four form states (Proxmox, XCP-ng, PBS, ESXi) are created once with useState and never reset. Nothing clears them on submit, on close, or on the next open.

Two consequences:

  1. Wrong cluster name. Reopening Add Cluster shows the previous cluster's Name, Host, User and settings. If the operator changes Host and credentials but does not notice Name is already filled, the new cluster is saved under the previous cluster's name. On my instance three clusters ended up with name = pxve0. The sidebar hid this because Rename writes a separate display_name. Side effects: cluster pickers that render name (see #787) show identical entries, and because the per-cluster logger is keyed on name, all three clusters write into each other's log files.
  2. Credentials retained. The previous cluster's root password and SSH key stay in component state for the life of the tab and are pre-filled into the next Add form, so they are sent to whatever host is typed next unless the operator retypes them. The same applies after Re-configure: the dialog pre-fills from that cluster's config and keeps it after close.

Steps to Reproduce

  1. Add a cluster: Name alpha, Host a.example, password secret.
  2. Open Add Cluster again. All fields still show alpha, a.example, and the password field is filled.
  3. Change Host to b.example, enter its password, submit without touching Name.
  4. The second cluster is saved with name = alpha. Both cluster log files carry the PegaProx_alpha tag and mirror each other.

Expected behavior

Every field is empty (defaults only) each time Add Cluster opens. Nothing typed into a previous Add or Re-configure survives closing the dialog.

Environment

  • PegaProx Version: 1.1.1
  • Installation Method: Docker (official image, Swarm service)
  • OS: Docker Swarm host on Proxmox VE; client on Nobara (latest)
  • Browser: Firefox (latest)
  • Behind Reverse Proxy? Traefik (no container ports published)
  • UI? Modern Layout

Logs

Three clusters, three log files, all tagged with the first cluster's name; two of the files are byte-identical in size because they receive the same stream.

##### 3435a719.log
[2026-09-07 20:52:21,904] [PegaProx_pxve0] INFO: Starting balance check for cluster: pxve0
##### a6707432.log
[2026-09-07 20:52:21,904] [PegaProx_pxve0] INFO: Starting balance check for cluster: pxve0
##### a7ab8805.log
[2026-09-07 20:52:00,431] [PegaProx_pxve0] DEBUG: Node pxve4: CPU 0.88%, RAM 79.43% (49.51 GB/62.33 GB), Score 104.42, Status: online

Checklist

  • [x] I have searched existing issues to make sure this is not a duplicate
  • [x] I am using the latest version of PegaProx

I have a fix ready (reset all four form objects when the dialog closes) and will open a PR referencing this issue.

Drauku avatar Sep 08 '26 00:09 Drauku

Reproduced — you nailed the cause. The modal stays mounted and hides itself, and the only setConfig on open sits behind the reconfigure branch, so a plain Add → close → Add keeps the whole previous form including pass and ssh_key. The name collision falling out of that (and the per-cluster logger being keyed on name) matches what you saw with the three pxve0 entries.

#787 hangs together with it, same root. Thanks for filing both with the repro steps and then sending PRs on top, that saves us a lot — we will go through 789/790 rather than writing our own version of it.

https://opencollective.com/pegaprox if you feel like it.

Marcus

mkellermann97 avatar Sep 08 '26 07:09 mkellermann97

Also fixed in 1.2.0 — the Add Cluster dialog resets on close, so it no longer hands you the previous cluster's name and credentials. Thanks for both reports on the same day, and for the PR.

— MK

mkellermann97 avatar Sep 21 '26 07:09 mkellermann97