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

Select rented node in automated selection in case of its existence #3749

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

maayarosama
Copy link
Contributor

Description

Select rented node in automated selection in case of its existence

Related Issues

Tested Scenarios

  • Go to any solution and check the automated selection incase there's a rented node and when there's not

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstrings
  • Screenshots/Video attached (needed for UI changes)

Comment on lines 339 to 340
const profileManager = useProfileManager();
let node;
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to include the profile manager here, we can pass it from the caller component TfAutoNodeSelector as it already has the gridstore.grid.twinID

Comment on lines 341 to 350
node = nodes.find(n => {
return n.rentedByTwinId === profileManager?.profile?.twinId;
});

if (node && isNodeValid(getFarm, node, selectedMachines, filters)) {
if (nodesLock && !locked) {
release(nodesLock);
}
return node;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

in this case we will always override the old selected node if there is a rented node is that the required case ?

and i suggest for reduce code redundancy :

const rentedNode = nodes.find(n => n.rentedByTwinId == twinId);
  if (oldSelectedNodeId || rentedNode) {
    const node = rentedNode || nodes.find(n => n.nodeId === oldSelectedNodeId);

    if (node && isNodeValid(getFarm, node, selectedMachines, filters)) {
      if (nodesLock && !locked) {
        release(nodesLock);
      }
      return node;
    }
  }

@maayarosama maayarosama requested a review from 0oM4R December 16, 2024 14:23
@amiraabouhadid
Copy link
Contributor

please fix build error

@amiraabouhadid
Copy link
Contributor

amiraabouhadid commented Dec 16, 2024

it shows the rented node (id 271) at the top of the list but then it autoscrolls to another node
https://www.loom.com/share/c84d8cabb086427a83b3a19a4d420fc4?sid=61387c83-df17-4a79-891a-cc5a50c648fb

Copy link
Contributor

@ramezsaeed ramezsaeed left a comment

Choose a reason for hiding this comment

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

Update test scenarios:

  • test if more than one rented node is available (maybe two or three)
  • test if the user has more than one rented, which one will be suggested and on which conditions.
  • un-reserv one or more rented node and the automation selection should get back to the normal behavior.
  • test if the rented node is in grace period; (should not be selected in this case)

@maayarosama
Copy link
Contributor Author

it shows the rented node (id 271) at the top of the list but then it autoscrolls to another node https://www.loom.com/share/c84d8cabb086427a83b3a19a4d420fc4?sid=61387c83-df17-4a79-891a-cc5a50c648fb

Was node 271 rented by you?

@amiraabouhadid
Copy link
Contributor

it shows the rented node (id 271) at the top of the list but then it autoscrolls to another node https://www.loom.com/share/c84d8cabb086427a83b3a19a4d420fc4?sid=61387c83-df17-4a79-891a-cc5a50c648fb

Was node 271 rented by you?

Yes

if (oldSelectedNodeId) {
const node = nodes.find(n => n.nodeId === oldSelectedNodeId);
if (oldSelectedNodeId || rentedNode) {
const node = rentedNode || nodes.find(n => n.nodeId === oldSelectedNodeId);
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to keep the old selected node if it exists.

Suggested change
const node = rentedNode || nodes.find(n => n.nodeId === oldSelectedNodeId);
const node = nodes.find(n => n.nodeId === oldSelectedNodeId) || rentedNode ;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remember in Th BAM we agreed on always choosing the rented node, @AhmedHanafy725 can you confirm that we'll choose the old selected node even if there's a rented node?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes we should select the old selected node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants