Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

sort nodes by dedicated nodes #312

Merged
merged 1 commit into from
Apr 2, 2023

Conversation

alichaddad
Copy link
Contributor

Description

When listing node using available_for option show dedicated node first in the result

Changes

Related Issues

#311

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstrings

@@ -464,6 +464,9 @@ func (d *PostgresDatabase) GetNodes(filter types.NodeFilter, limit types.Limit)
q = q.Limit(int(limit.Size)).
Offset(int(rand.Intn(int(count)) - int(limit.Size)))
} else {
if filter.AvailableFor != nil {
q = q.Order("(case when farm.dedicated_farm then 1 else 2 end)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the dedicated nodes can be a node in a dedicated farm or a node with no contracts. can't we depend on the rent contract of the node? if it has a positive number, it means dedicated and rented so it can go to the top of the list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what is the value we are depending on in the contract. Twin id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also another thought, since dedicated property is the farm.dedicated_farm does that mean that we can't depend on that value to know if a node is dedicated or not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a bit confusing but will try to explain
dedicated -> farm.dedicated_farm: no deployments can go to this node unless it got rented
rentable -> dedicated node or node with no contracts: can be rented, also the nodes with no contracts can take deployments without a rent contract.
rented: one of the rentable nodes got rented, and then it will take a rentContractId. this rent contract id is 0 if the node is not rented. this one I mean to use to sort the nodes

using dedicated in the issue wasn't the correct word, it should be rented so I gonna rephrase it

@alichaddad alichaddad force-pushed the development_order_dedicated_node branch from db07f8e to 1b890c6 Compare March 30, 2023 14:23
@AhmedHanafy725 AhmedHanafy725 merged commit f39a7d7 into development Apr 2, 2023
@AhmedHanafy725 AhmedHanafy725 deleted the development_order_dedicated_node branch April 2, 2023 09:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants