mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-11-22 00:27:38 +08:00
d8d33ff14f6ece9b31d24990326282367f9df25f
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d8d33ff14f |
feat: page the VM list on the server when the API supports it (#1261) (#1273)
* feat: page the VM list on the server when the API supports it
On clusters whose API serves lists from the Steve SQL cache, the VM list
uses PaginatedResourceTable: it loads one page of VMs, and the VMIs, pods,
PVCs, PVs, migrations, restores and backups of those VMs only. Sorting,
search and the namespace filter run on the server, so CPU, memory, IP and
node can't be sorted or searched there.
The feature is gated by the vmListPagination feature flag and enabled for
the VM list only, through a pagination context. Older clusters keep the
current list.
* feat: enable the VM list pagination from v1.10.0
The backend change that serves API lists from the SQL cache has to be on
the v1.10 branch before this is merged.
* fix: keep the paged VM list when adding a volume
The Add Volume dialog loaded every VM to find the volumes in use, which
replaced the page the VM list keeps in the store and emptied the list.
When the list is paged, the dialog now reads only the VMs of the
namespace and doesn't store them.
The requests for the resources of a page use one IN filter instead of
one filter per value, which keeps the URLs about a third as long.
* fix: keep the paged VM list intact in its dialogs and on older APIs
The Add Volume, Storage Migration and Restore dialogs read the VMs, PVCs
and backups of the VM's namespace through the VM. While the list keeps a
page of a type in the store they read the namespace without storing it,
so the list keeps its page and the dialogs' own lists don't shrink when
the page reloads. Storage Migration no longer offers volumes of VMs on
other pages as targets.
The list is paged only when the API lists the VM's printer columns as
metadata.fields, which the SQL cache does, so a missing or non-semver
server version can't turn it on against an API that can't filter.
One failed request for a page's resources no longer stops the others.
* fix: show the restart notice only when its VMs change
The list rebuilds the names of the VMs that need a restart on every
refresh, and when it pages also on every page, sort and search, so the
notice popped up again each time even when nothing new needed a
restart. Show it only when the set of VMs changes.
While paging it still covers only the VMs on the current page: the API
can't filter VMs by their RestartRequired condition.
* fix: find the launcher pods of every VM on the page
The paged list loaded the page's launcher pods by the harvesterhci.io/vmName
label, which only the Harvester VM form writes into a VM's template. VMs
created any other way, like an imported VM or one applied with kubectl,
got no pod, so their rows lost View Logs and the starting and pod error
states.
Load the pods after the page's VMIs instead, by the kubevirt.io/created-by
label KubeVirt puts on every launcher pod (the VMI's UID).
Also cover the paged mode in the tests: it must not load every VMI,
migration or pod, and a forced refresh must reach every request.
* fix: notify about restarts again when coming back to the VM list
The restart notice compared the VMs that need a restart with the
previous value of the list. Coming back from a page that loads every VM,
like Volumes or a VM's detail page, that previous value already held the
same VMs, so the notice didn't show. Remember what was notified on the
list itself instead, so each visit starts fresh, and compare by namespace
and name, so a VM of the same name in another namespace counts as a
change.
Also say which VMs lack Harvester's vmName label: the ones from Forklift
or plain manifests, not every VM created outside the UI.
* refactor: keep the VM list's paging helpers in the component
Only canPaginate stays outside, because ResourceList calls
$loadingResources(route, store) on the component options, where there is
no `this`. The pagination headers become a computed property and the
printer column lookup a method.
* refactor: always list VMs with PaginatedResourceTable
PaginatedResourceTable handles both modes. fetchSecondaryResources loads
every pod, volume, restore, backup, VMI and migration when the list isn't
paged, and only what every row shares when it is. VMIs without a VM are
added back through localFilter, which only runs without pagination.
The list passes the pagination context only when the cluster's API can
page, so older clusters keep the full list.
* refactor: register the VM list's columns with the product
Both column sets go through the product's headers(), with the paged set
next to the unpaged one in config/table-headers.js. The list only adds the
node and restore progress columns, which the API can't sort or search when
paging. State sorts by the VM's Status printer column, metadata.fields.2.
* fix: show the restart notice when coming back to the VM list
Since the list always uses PaginatedResourceTable it reads the VMs from
the store. Coming back to the list the store already holds them, so the
restart watcher never saw a change and the notice didn't show. Run it
when the list is created too.
While paging, the store can still hold the VMs another view loaded, like
every VM after Volumes or a VM's detail, so wait for the list's own page
before notifying.
* fix: let the namespace filter know the VM list is paged
The VMs were registered for pagination with a context that only the VM
list passed. The header's namespace filter asks without one, so it didn't
know the list was paged and kept offering "Not in a Project", which the
paged API can't filter by: picking it hid every VM.
Register the VMs in every context and answer per cluster in the store's
paginationEnabled getter instead: only when the feature is on and the
API lists the VM's printer columns as metadata.fields, as the SQL cache
does. The filter, the list and the store now agree, and clusters whose
API can't page keep the full list.
The filter is shared by every list, so Not in a Project can still be
picked on a list that doesn't page. The paged VM list then asks for
another option, like the shell's generic lists do, instead of showing
no rows.
* fix: keep the paged VM list when showing a VM's configuration
The Config tab of the Show Configuration drawer renders the VM form,
which loads every VM, PVC, PV, VMI and migration, and its device tabs
every VM again. On a paged list that replaced the list's page in the
store and emptied the list.
Hide the Config tab while the store keeps a page of VMs, so the drawer
shows the YAML. The VM's own page still shows its configuration, and a
drawer opened where every VM is loaded keeps its Config tab.
* refactor: define the VM list's node and restore columns with the others
The node and restore progress columns are now in VM_HEADERS, so the paged
set turns their sort and search off through VM_PAGINATION_FIELDS, like the
other columns the API can't index. The list only leaves them out when they
don't apply: the node column when the cluster's nodes can't be seen, the
restore progress while no backup is being restored.
---------
(cherry picked from commit
|
||
|
|
95921c85cd |
feat: add the Kube-OVN VPC Egress Gateways page (#1263) (#1269)
* feat: add the Kube-OVN VPC Egress Gateways page
List, create and edit VpcEgressGateway resources under Overlay Networks >
NAT & Internet, right below the NAT gateways, which are now labeled NAT
Gateways. The form covers the VPC, replicas, internal and external
subnets, SNAT policies, internal and external IPs, BFD and the bandwidth
limit, and keeps the fields it does not show.
* feat: add the VPC BFD port and link the Egress Gateway BFD warning to it
The VPC form gets a BFD Port tab with the enabled switch and its IP,
which an Egress Gateway with BFD needs. The gateway form now checks the
VPC's spec.bfdPort instead of a spec.bfd field that VPCs don't have, and
its warning links to the VPC. Bandwidth also takes quantities such as
1Gi, and a gateway that only uses selectors no longer needs a policy.
* feat: check the Egress Gateway and BFD port against what Kube-OVN accepts
Kube-OVN runs as a secondary CNI in Harvester, so an Egress Gateway's
internal subnet has to sit on a virtual machine network and its external
subnet on a network attachment; the subnet lists now offer only those.
The internal and external IPs must be unique and inside their subnet,
other than its gateway, and the two subnets must differ. Selectors don't
work in that mode, so a gateway needs a policy again. Policies set with
IP blocks show them, and BFD intervals hidden while BFD is off fall back
to their defaults.
Save stays disabled while either form is invalid, each field shows its
own error, and a tab with errors is marked. The VPC's BFD port IP can't
be in one of its subnets, its tab warns when it is turned off while
gateways of the VPC use BFD, and the gateway's BFD warning opens the
VPC's BFD Port tab in a new tab.
* fix: show why Save is disabled on the Egress Gateway and VPC forms
Every field that can block Save shows its own message once touched:
the name, the VPC and both subnets, which have none when left empty.
When the chosen VPC has no subnet on a virtual machine network, the
Internal Subnet placeholder says so.
A subnet can only be in one policy: the gateway leaves a source out of
SNAT when any policy has SNAT off for it, so the same subnet in a second
policy would silently ignore one of them. Enable SNAT explains what
turning it off needs.
* fix: keep one Egress Gateway policy for each SNAT setting
Kube-OVN merges the sources of every policy with the same SNAT setting,
so a second policy with SNAT on (or off) only adds to the first one.
The form now flags it on the second policy, Add Policy adds the setting
that isn't used yet and goes away once both exist, and the Policies tab
says a gateway has at most two policies. Policies with IP blocks are
left out of the check, since the form can't move those.
* refactor: ask for the Egress Gateway subnets with and without SNAT
Kube-OVN puts the sources of every policy into two sets, with SNAT and
without, and leaves a source out of SNAT when any policy has SNAT off
for it. A list of policies with a checkbox each let the form build
policies that only repeated or silently overrode each other, so the
Policies tab now asks for those two sets: Subnets with SNAT and Subnets
without SNAT, a subnet in one list only and at least one subnet in all.
Saving writes one policy for each list that has subnets.
Editing reads existing policies the way Kube-OVN applies them, so a
subnet that was in both lands in Subnets without SNAT, and IP blocks
set outside the form are kept and shown read-only.
* refactor: go back to the Egress Gateway policy list
The VpcEgressGateway CRD and the issue describe policies as a list,
each with snat and subnets, and Kube-OVN accepts any number of them:
policies with the same SNAT setting just work together. The two subnet
lists hid that shape and rewrote existing policies, and they couldn't
mark "one of these two" as required. This puts back the policy list,
where each policy needs a subnet and a subnet can be in one policy
only, which is the one case that changes what the gateway does. The
Policies tab now says how policies work together.
* refactor: ask for the Egress Gateway subnets with and without SNAT again
Kube-OVN only uses which subnets have SNAT and which don't, so two
lists, Subnets with SNAT and Subnets without SNAT, hold the same data
as the policy list, are clearer to fill in, and can't build a policy
that repeats or overrides another. Saving writes one policy for each
list that has subnets. Neither list is marked required: the Policies
tab says one subnet in either list is needed, and both lists show that
message once touched while they're empty.
* fix: show the Egress Gateway policy rule once for both subnet lists
One subnet in either list is enough, but a warning on each list read as
if both lists were required. The lists no longer show a warning; one
message under them says to select at least one subnet in either list
while both are empty, next to the tab mark and the disabled Save.
* fix: say why the Egress Gateway subnet lists are empty
The policy lists only offer subnets of the VPC chosen on the Basic tab,
so before a VPC is chosen they were empty with no reason given. They
now say to select a VPC on the Basic tab first, or that the chosen VPC
has no subnets.
* fix: make the Egress Gateway fields that need a VPC say so
Internal Subnet and both policy lists only offer subnets of the chosen
VPC, so they're disabled until a VPC is chosen and say to select one
first. The policy lists keep their dropdown attached to the field, so
it follows the field when a chip is removed instead of leaving a gap.
The BFD intervals are labeled Receive Interval and Transmit Interval,
which fit next to their unit, with a tooltip each.
* fix: keep the external subnet out of Egress Gateway policies and check usable IPs
Kube-OVN reroutes a policy's sources to the gateway, so the gateway's
own external subnet as a source would send its outbound traffic back
into it; the policy lists no longer offer it and the form flags it.
Static IPs must also be usable addresses: Kube-OVN assigns from the
network address + 1 to the broadcast address - 1, so those two are
rejected along with the gateway.
The policy rule is an error banner like the IP count rule, the BFD
multiplier has its own message, the IP Addresses and Bandwidth
instructions are hidden on the read-only page, and the VPC's warning
about gateways that need its BFD port reads right for one gateway.
* chore: declare ipaddr.js, which the subnet model imports
It was only installed as a dependency of webpack-dev-server.
* feat: support PrimaryCNI Egress Gateways
Kube-OVN v1.17 can send a gateway's traffic out through the pod network
when it isn't the primary CNI, as on Harvester. Such a gateway takes no
external subnet, external IPs or bandwidth, so the form couldn't save one.
The Basic tab now picks the external network, locked after creation, and
hides the fields PrimaryCNI doesn't take.
* fix: offer Primary CNI only when the cluster's CRD has it
Kube-OVN v1.16, in Harvester v1.10.0-rc1 and older, has no
externalNetworkMode and requires an external subnet, so a Primary CNI
gateway was rejected there. The form reads the CRD's schema definition
and only shows the External Network choice when the field exists.
---------
(cherry picked from commit
|
||
|
|
5406c08f76 |
perf: speed up the VM list with many VMs (#1189)
* perf: speed up the VM list with many VMs The VM list scanned whole store lists for every row and re-evaluated the same values per row on every render and sort. With several hundred VMs this blocked the browser on sorting and on every VM update. Performance: - look up launcher pods and migrations through shared indexes (namespace/name -> resource) instead of scanning per row; the indexes are computed per store list, so they stay in sync with in-place store updates - use the same migration lookup (getLatestMigration) in the VM model and on the VM detail page - look up PVCs, PVs, VMIs and restore backups by id - merge VMs and VMIs with a Set - evaluate the VM state once when sorting by state - check the unschedulable condition before the pod based state checks - cache feature flag results and per-schema/per-setting values that are the same for every row Bug fixes: - the launcher pod map was never rebuilt, because the store keeps the same array - pods, volumes and migrations of a VM with the same name in another namespace could be picked up The order of the volumes of a VM (vm.volumes) now follows the VM spec instead of the store order. Nothing depends on it. Measured in a synthetic setup, 100 rows per page, sorting by state (Chrome, dev build): - ~490 VMs, ~500 PVCs/PVs: 1.9 s -> 1.0 s - ~490 VMs, 600 PVs, 200 migrations: 6.0 s -> 0.7 s, main thread blocked during VM updates 78% -> 32% With few volumes the gain is much smaller (8-20%). Related to: https://github.com/harvester/harvester/issues/9513 Signed-off-by: Volker Theile <vtheile@suse.com> * fix: read VM data from the store of the resource instead of a fixed one The migrations of a VMI and the migration badge of the state column were read from the hardcoded `harvester` store. In the Rancher explorer (embedded and standalone) the data is loaded into the `cluster` store, so a running migration was shown neither in the VM state nor as badge. The VM model remembered the store of the current product in a module variable on first use and never updated it. The same model is used in the Harvester product (`harvester` store) and in the Rancher explorer (`cluster` store), and Rancher keeps the page loaded when going from the explorer of a Harvester cluster to Virtualization Management and into the Harvester product. The VM list then read the VMIs, launcher pods, volumes and restores from the wrong store, and running VMs were shown as Starting until the page was reloaded. Read the data from the store the resource lives in (`this.$getters`, in the formatter the store of the current product). In the Harvester product this is still the `harvester` store, so nothing changes there. Not covered: volume details like the lock icon of encrypted volumes. The explorer uses the generic Rancher PVC model, which does not know them, and settings based checks (feature flags, backup target) are not loaded there either. Related to: https://github.com/harvester/harvester/issues/11882 Signed-off-by: Volker Theile <vtheile@suse.com> --------- Signed-off-by: Volker Theile <vtheile@suse.com> |
||
|
|
71141b257a |
feat: Add a unit test target (jest) to the UI extension and run it in CI (#1192)
- Introduce test targets. - Adding additional tests. Related to: https://github.com/harvester/harvester/issues/11892 Signed-off-by: Volker Theile <vtheile@suse.com> |