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

Add rented by me and include rentable nodes filter #3852

Merged
merged 13 commits into from
Feb 23, 2025
1 change: 1 addition & 0 deletions packages/grid_client/src/modules/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ class FilterOptions {
@Expose() @IsOptional() @IsBoolean() hasGPU?: boolean;
@Expose() @IsOptional() @IsBoolean() rentable?: boolean;
@Expose() @IsOptional() @IsInt() @Min(1) rentedBy?: number;
@Expose() @IsOptional() @IsBoolean() rentedByMe?: boolean;
@Expose() @IsOptional() @IsBoolean() randomize?: boolean;
@Expose() @IsOptional() @IsBoolean() ret_count?: boolean;
@Expose() @IsOptional() @Transform(({ value }) => NodeStatus[value]) @IsEnum(NodeStatus) status?: NodeStatus;
Expand Down
13 changes: 11 additions & 2 deletions packages/playground/src/components/caprover_worker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@
v-model:mycelium="$props.modelValue.mycelium"
v-model:wireguard="$props.modelValue.wireguard"
/>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented by me" v-model="$props.modelValue.rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Dedicated" v-model="$props.modelValue.dedicated" hide-details />
<v-switch
color="primary"
inset
label="Include rentable nodes"
v-model="$props.modelValue.dedicated"
hide-details
/>
</input-tooltip>
<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch color="primary" inset label="Certified" v-model="$props.modelValue.certified" hide-details />
Expand All @@ -47,6 +55,7 @@
ipv6: $props.modelValue.ipv6,
certified: $props.modelValue.certified,
dedicated: $props.modelValue.dedicated,
rentedByMe: $props.modelValue.rentedByMe,
cpu: $props.modelValue.solution?.cpu,
solutionDisk: $props.modelValue.solution?.disk,
memory: $props.modelValue.solution?.memory,
Expand Down
14 changes: 12 additions & 2 deletions packages/playground/src/components/k8s_worker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,17 @@
v-model.number="$props.modelValue.rootFsSize"
/>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented by me" v-model="$props.modelValue.rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Dedicated" v-model="$props.modelValue.dedicated" hide-details />
<v-switch
color="primary"
inset
label="Include rentable nodes"
v-model="$props.modelValue.dedicated"
hide-details
/>
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
Expand All @@ -100,6 +109,7 @@
ipv4: $props.modelValue.ipv4,
certified: $props.modelValue.certified,
dedicated: $props.modelValue.dedicated,
rentedByMe: $props.modelValue.rentedByMe,
cpu: $props.modelValue.cpu,
ssdDisks: [$props.modelValue.diskSize],
memory: $props.modelValue.memory,
Expand Down Expand Up @@ -139,8 +149,8 @@ export function createWorker(name: string = generateName({ prefix: "wr" })): K8S
wireguard: true,
rootFsSize: 2,
dedicated: false,
rentedByMe: false,
certified: false,
rentedBy: undefined,
};
}

Expand Down
2 changes: 2 additions & 0 deletions packages/playground/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface K8SWorker {
rootFsSize: number;
rentedBy?: number;
dedicated: boolean;
rentedByMe: boolean;
certified: boolean;
selectionDetails?: SelectionDetails;
}
Expand All @@ -71,6 +72,7 @@ export interface CaproverWorker {
name: string;
solution?: solutionFlavor;
dedicated?: boolean;
rentedByMe?: boolean;
certified?: boolean;
selectionDetails?: SelectionDetails;
ipv4: boolean;
Expand Down
3 changes: 3 additions & 0 deletions packages/playground/src/types/nodeSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export interface SelectionDetailsFilters {
solutionDisk?: number;
certified?: boolean;
dedicated?: boolean;
rentedBy?: number;
rentedByMe?: boolean;
rentable?: boolean;
exclusiveFor?: string;
rentable_or_rented_by?: number;
planetary?: boolean;
Expand Down
1 change: 1 addition & 0 deletions packages/playground/src/utils/deploy_vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export interface Machine {
hasGPU?: boolean;
certified?: boolean;
rentedBy?: number;
rentedByMe?: boolean;
nodeId?: number;
}

Expand Down
6 changes: 5 additions & 1 deletion packages/playground/src/utils/nodeSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ export function normalizeNodeFilters(
filters: SelectionDetailsFilters,
options?: NormalizeNodeFiltersOptions,
): FilterOptions {
const bothRentalFiltersActive = filters.dedicated && filters.rentedByMe;

return {
page: Math.max(1, options?.page || 1),
size: options?.size,
Expand All @@ -207,7 +209,9 @@ export function normalizeNodeFilters(
country: options?.location.country,
gateway: options?.gateway,
healthy: true,
rentableOrRentedBy: filters.dedicated ? options?.twinId : undefined,
rentable: bothRentalFiltersActive ? undefined : filters.dedicated || undefined,
rentedBy: bothRentalFiltersActive ? undefined : filters.rentedByMe ? options?.twinId : undefined,
rentableOrRentedBy: bothRentalFiltersActive ? options?.twinId : undefined,
planetary: filters.planetary,
mycelium: filters.mycelium,
wireguard: filters.wireguard,
Expand Down
10 changes: 8 additions & 2 deletions packages/playground/src/weblets/full_vm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:memory="solution?.memory"
:disk="disks.reduce((total, disk) => total + disk.size, solution?.disk + 2)"
:ipv4="ipv4"
:rentedByMe="rentedByMe"
:dedicated="dedicated"
:SelectedNode="selectionDetails?.node"
:valid-filters="selectionDetails?.validFilters"
Expand Down Expand Up @@ -61,8 +62,11 @@
>
<v-switch color="primary" inset label="GPU" v-model="hasGPU" hide-details />
</input-tooltip>
<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented by me" v-model="rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Dedicated" v-model="dedicated" hide-details />
<v-switch color="primary" inset label="Include rentable nodes" v-model="dedicated" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
Expand All @@ -76,6 +80,7 @@
hasGPU,
certified,
dedicated,
rentedByMe,
cpu: solution?.cpu,
ssdDisks: disks.map(disk => disk.size),
solutionDisk: solution?.disk,
Expand Down Expand Up @@ -196,6 +201,7 @@ const name = ref(generateName({ prefix: "vm" }));
const flist = ref<Flist>();
const { ipv4, ipv6, mycelium, planetary, wireguard } = useNetworks();
const dedicated = ref(false);
const rentedByMe = ref(false);
const certified = ref(false);
const disks = ref<Disk[]>([]);
const hasGPU = ref(false);
Expand Down Expand Up @@ -267,7 +273,7 @@ async function deploy() {
hasGPU: hasGPU.value,
nodeId: selectionDetails.value?.node?.nodeId,
gpus: hasGPU.value ? selectionDetails.value?.gpuCards.map(card => card.id) : undefined,
rentedBy: dedicated.value ? grid!.twinId : undefined,
rentedByMe: rentedByMe.value,
certified: certified.value,
},
],
Expand Down
10 changes: 8 additions & 2 deletions packages/playground/src/weblets/jenkins.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:disk="solution?.disk"
:ipv4="ipv4"
:dedicated="dedicated"
:rentedByMe="rentedByMe"
:SelectedNode="selectionDetails?.node"
:valid-filters="selectionDetails?.validFilters"
title-image="images/icons/jenkins.png"
Expand Down Expand Up @@ -78,8 +79,11 @@
require-domain
/>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented by me" v-model="rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Dedicated" v-model="dedicated" hide-details />
<v-switch color="primary" inset label="Include rentable nodes" v-model="dedicated" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
Expand All @@ -92,6 +96,7 @@
ipv6,
certified,
dedicated,
rentedByMe,
cpu: solution?.cpu,
solutionDisk: solution?.disk,
memory: solution?.memory,
Expand Down Expand Up @@ -148,6 +153,7 @@ const flist: Flist = {
entryPoint: "/sbin/zinit init",
};
const dedicated = ref(false);
const rentedByMe = ref(false);
const certified = ref(false);
const { ipv4, ipv6, mycelium, planetary, wireguard } = useNetworks();
const selectionDetails = ref<SelectionDetails>();
Expand Down Expand Up @@ -213,7 +219,7 @@ async function deploy() {
{ key: "JENKINS_ADMIN_PASSWORD", value: password.value },
],
nodeId: selectionDetails.value!.node!.nodeId,
rentedBy: dedicated.value ? grid!.twinId : undefined,
rentedByMe: rentedByMe.value,
certified: certified.value,
rootFilesystemSize: rootFilesystemSize.value,
},
Expand Down
12 changes: 10 additions & 2 deletions packages/playground/src/weblets/micro_vm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:disk="disks.reduce((total, disk) => total + disk.size, solution?.disk ?? 0)"
:ipv4="ipv4"
:dedicated="dedicated"
:rentedByMe="rentedByMe"
:SelectedNode="selectionDetails?.node"
:valid-filters="selectionDetails?.validFilters"
title-image="images/icons/vm.png"
Expand Down Expand Up @@ -54,8 +55,13 @@
v-model:mycelium="mycelium"
v-model:wireguard="wireguard"
/>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented by me" v-model="rentedByMe" hide-details />
<!-- </input-tooltip> -->

<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Dedicated" v-model="dedicated" hide-details />
<v-switch color="primary" inset label="Include rentable nodes" v-model="dedicated" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
Expand All @@ -68,6 +74,7 @@
ipv6,
certified,
dedicated,
rentedByMe,
cpu: solution?.cpu,
ssdDisks: disks.map(disk => disk.size),
memory: solution?.memory,
Expand Down Expand Up @@ -249,6 +256,7 @@ const { ipv4, ipv6, planetary, mycelium, wireguard } = useNetworks();
const envs = ref<Env[]>([]);
const disks = ref<Disk[]>([]);
const dedicated = ref(false);
const rentedByMe = ref(false);
const certified = ref(false);
const selectionDetails = ref<SelectionDetails>();
const selectedSSHKeys = ref("");
Expand Down Expand Up @@ -305,7 +313,7 @@ async function deploy() {
publicIpv6: ipv6.value,
rootFilesystemSize: solution.value?.disk,
nodeId: selectionDetails.value?.node?.nodeId,
rentedBy: dedicated.value ? grid!.twinId : undefined,
rentedByMe: rentedByMe.value,
certified: certified.value,
},
],
Expand Down
10 changes: 8 additions & 2 deletions packages/playground/src/weblets/tf_algorand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:disk="storage + (type === 'indexer' ? 50 : 0)"
:ipv4="ipv4"
:dedicated="dedicated"
:rentedByMe="rentedByMe"
:SelectedNode="selectionDetails?.node"
:valid-filters="selectionDetails?.validFilters"
title-image="images/icons/algorand.png"
Expand Down Expand Up @@ -67,8 +68,11 @@
</input-tooltip>
</AlgorandCapacity>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented by me" v-model="rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Dedicated" v-model="dedicated" hide-details />
<v-switch color="primary" inset label="Include rentable nodes" v-model="dedicated" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
Expand All @@ -91,6 +95,7 @@
ipv6,
certified,
dedicated,
rentedByMe,
cpu,
ssdDisks: [storage],
solutionDisk: type === 'indexer' ? 50 : undefined,
Expand Down Expand Up @@ -143,6 +148,7 @@ const type = ref("default");
const firstRound = ref(24000000);
const lastRound = ref(26000000);
const dedicated = ref(false);
const rentedByMe = ref(false);
const certified = ref(false);
const rootFilesystemSize = computed(() => storage.value);
const selectionDetails = ref<SelectionDetails>();
Expand Down Expand Up @@ -190,7 +196,7 @@ async function deploy() {
mycelium: mycelium.value,
planetary: planetary.value,
nodeId: selectionDetails.value!.node!.nodeId,
rentedBy: dedicated.value ? grid!.twinId : undefined,
rentedByMe: rentedByMe.value,
certified: certified.value,

envs: [
Expand Down
3 changes: 2 additions & 1 deletion packages/playground/src/weblets/tf_caprover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
)
"
:ipv4="true"
:rentedByMe="leader.rentedByMe"
:dedicated="leader.dedicated"
:SelectedNode="leader.selectionDetails?.node"
:valid-filters="leader.selectionDetails?.validFilters"
Expand Down Expand Up @@ -205,7 +206,7 @@ function normalizeCaproverWorker(worker: CW, envs: Env[]): Machine {
],
envs,
nodeId: worker.selectionDetails!.node!.nodeId,
rentedBy: worker.dedicated ? profileManager.profile?.twinId : undefined,
rentedByMe: worker.rentedByMe,
certified: worker.certified,
};
}
Expand Down
10 changes: 8 additions & 2 deletions packages/playground/src/weblets/tf_casperlabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:disk="solution?.disk"
:ipv4="ipv4"
:dedicated="dedicated"
:rentedByMe="rentedByMe"
:SelectedNode="selectionDetails?.node"
:valid-filters="selectionDetails?.validFilters"
title-image="images/icons/casperlabs.png"
Expand Down Expand Up @@ -46,8 +47,11 @@
require-domain
/>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented by me" v-model="rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Dedicated" v-model="dedicated" hide-details />
<v-switch color="primary" inset label="Include rentable nodes" v-model="dedicated" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
Expand All @@ -60,6 +64,7 @@
ipv6,
certified,
dedicated,
rentedByMe,
cpu: solution?.cpu,
solutionDisk: solution?.disk,
memory: solution?.memory,
Expand Down Expand Up @@ -112,6 +117,7 @@ const flist: Flist = {
entryPoint: "/sbin/zinit init",
};
const dedicated = ref(false);
const rentedByMe = ref(false);
const certified = ref(false);
const { ipv4, ipv6, planetary, mycelium, wireguard } = useNetworks();
const rootFilesystemSize = computed(() =>
Expand Down Expand Up @@ -173,7 +179,7 @@ async function deploy() {
{ key: "CASPERLABS_HOSTNAME", value: domain },
],
nodeId: selectionDetails.value!.node!.nodeId,
rentedBy: dedicated.value ? grid!.twinId : undefined,
rentedByMe: rentedByMe.value,
certified: certified.value,
rootFilesystemSize: rootFilesystemSize.value,
},
Expand Down
Loading
Loading