Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort solutions nodes by free CRU #2882

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions packages/grid_client/src/primitives/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SortBy, SortOrder } from "@threefold/gridproxy_client";
import { Client as RMBClient } from "@threefold/rmb_direct_client";
import { QueryClient } from "@threefold/tfchain_client";
import {
Expand Down Expand Up @@ -135,13 +136,22 @@ class Nodes {
let nodes: NodeInfo[] = [];
let page = 1;
do {
nodes = await this.filterNodes({ accessNodeV4: true, accessNodeV6: true, availableFor, page });
nodes = await this.filterNodes({
accessNodeV4: true,
accessNodeV6: true,
availableFor,
page,
});
for (const node of nodes) {
const ipv4 = node.publicConfig.ipv4;
const ipv6 = node.publicConfig.ipv6;
const domain = node.publicConfig.domain;
if (PrivateIp(ipv4.split("/")[0]) === false) {
accessNodes[+node.nodeId] = { ipv4: ipv4, ipv6: ipv6, domain: domain };
accessNodes[+node.nodeId] = {
ipv4: ipv4,
ipv6: ipv6,
domain: domain,
};
}
}
page++;
Expand Down Expand Up @@ -279,7 +289,13 @@ class Nodes {
.request([node_twin_id], "zos.statistics.get", "")
.then(res => {
const node: RMBNodeCapacity = res;
const ret: NodeResources = { cru: 0, mru: 0, hru: 0, sru: 0, ipv4u: 0 };
const ret: NodeResources = {
cru: 0,
mru: 0,
hru: 0,
sru: 0,
ipv4u: 0,
};

ret.cru = +node.total.cru;
ret.mru = +node.total.mru - +node.used.mru;
Expand Down Expand Up @@ -408,6 +424,8 @@ class Nodes {
ret_count: options.ret_count,
region: options.region,
healthy: options.healthy,
sort_by: SortBy.FreeCRU,
sort_order: SortOrder.Desc,
};

if (options.gateway) {
Expand Down
4 changes: 2 additions & 2 deletions packages/playground/src/views/nodes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ export default {
domain: filters.value.gateway || undefined,
freeIps: +filters.value.publicIPs || undefined,
dedicated: filters.value.dedicated || undefined,
sortBy: SortBy.FreeCRU,
sortOrder: SortOrder.Desc,
sortBy: SortBy.Status,
sortOrder: SortOrder.Asc,
numGpu: +filters.value.numGpu || undefined,
rentable: filters.value.rentable && profileManager.profile ? filters.value.rentable : undefined,
availableFor: filters.value.rentable && profileManager.profile ? profileManager.profile.twinId : undefined,
Expand Down
Loading