Repository navigation
Conversation
…st first Containers missing from userprefs.cfg sorted as position 0 (array_search returns false, so '?? 999' never applied) and went to the top of the Docker tab, Dashboard, CPU pinning and autostart file, each in its own order. All readers now use one sort; a container without a stored position is appended once, oldest first by Docker's creation time, and its autostart line moves with it. Writes to userprefs.cfg take a lock; renames keep the position.
|
No actionable comments were generated in the recent review. WalkthroughDocker container ordering now uses persisted manual order and shared sorting methods across container actions, lists, and autostart entries. VM lists use a shared preference-ordering helper after natural sorting. ChangesDocker Container Ordering
VM Ordering
Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant UserPrefs
participant DockerUtil
participant OrderFile
participant DockerContainers
UserPrefs->>DockerUtil: saveUserOrder(names)
DockerUtil->>OrderFile: write indexed names
DockerContainers->>DockerUtil: sortContainers(containers)
DockerUtil->>OrderFile: read manual order
DockerUtil-->>DockerContainers: return ordered containers
Possibly related PRs
Suggested reviewers: Merge Risk:
|
…ned no details for The tab-order sort kept only containers listed by getDockerContainers(), which skips a container whose inspect fails. Such a running container was then left out of Stop all and Pause all. It is now kept, after the ordered ones; Start all still skips it, as before.
… page array_search returns false for a VM not in the VM userprefs.cfg, so '?? 999' never applied and the VM sorted as position 0 (top) on the VMs tab, Dashboard, CPU pinning and Start/Stop all. All four now use sort_by_order(): listed VMs in their order, then unlisted ones by name. Start all follows the tab order, Stop all the reverse.
97beb1c to
efec46e
Compare
Related pull requests
sort_by_order(), which fix(docker): one stored container order; new containers go last, oldest first #2844 adds to Wrappers.php, so this branch also contains fix(docker): one stored container order; new containers go last, oldest first #2844's commits. The change for this PR is the last commit, efec46e. Merge fix(docker): one stored container order; new containers go last, oldest first #2844 first; this diff then shrinks to the 4 VM files.Summary
VMs that the stored VM order (
/boot/config/plugins/dynamix.vm.manager/userprefs.cfg) does not list go after the listed ones, in name order. This is the same on the VMs tab, the Dashboard, CPU pinning, and Start/Stop all. Start all starts in tab order; Stop all stops in reverse.Why
It is the same bug as the Docker order PR, #2844. Each reader sorts with
array_search($vm, $prefs) ?? 999.array_searchreturnsfalsefor a VM that is not listed (https://www.php.net/manual/en/function.array-search.php), and??only replacesnull, so?? 999never fires. PHP comparesfalsewith an integer as booleans (https://www.php.net/manual/en/language.operators.comparison.php), so the VM ties with position 0 and goes to the top. The readers:Example data: the stored order is
win11, homeassistant, and you addpfsense. Todaypfsenseshows above both. Start all also starts it first, because Start/Stop all sorts the same way. The order is not cosmetic: what starts first and stops last has to be what others need, the rule systemd, Docker Compose and Kubernetes apply (sources in #2844).Same principle as the Docker order
Unraid owns the order; a plugin such as FolderView Plus only groups it. With folders removed, the VMs stay in the same order as one flat list. That needs every VM to have a defined place, and unlisted ones at the end is the place that changes nothing for the VMs the user already arranged.
Why last, and why by name here
Containers go last in creation order because an app is set up after the database it needs, and a dependency has to start first and stop last (see #2844 for the sources). libvirt keeps no creation time for a domain:
virDomainInfoholds state, memory, CPU count and CPU time only (https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainInfo). So there is no creation order to use, and unlisted VMs go last in name order, which is the order the tab already uses when no order is stored.Unlike containers, VMs are not written into the stored order automatically. The VM order file is only written when you drag, as today; this PR changes how it is read.
Testing
Tested on an Unraid 7.4 test server:
This change was written with the help of frontier AI. I reviewed and tested it.
Summary by CodeRabbit