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

[core][dashboard] Update nodes on delta. #47367

Merged
merged 17 commits into from
Aug 29, 2024

Conversation

rynewang
Copy link
Contributor

@rynewang rynewang commented Aug 27, 2024

Like actor_head.py, we now update DataSource.nodes on delta. It first queries all node infos, then subscribes node deltas. Each delta updates:

  1. DataSource.nodes[node_id]
  2. DataSource.agents[node_id]
  3. a warning generated after RAY_DASHBOARD_HEAD_NODE_REGISTRATION_TIMEOUT = 10s

Note on (2) agents: it's read from internal kv, and is not readily available until the agent.py is spawned and writes its own port to internal kv. So we make an async task for each node to poll this port every 1s.

It occurs that the get-all-then-subscribe code has a TOCTOU problem, so also updated actor_head.py to first subscribe then get all actors.

Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
@rynewang rynewang added the go add ONLY when ready to merge, run all tests label Aug 27, 2024
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
@rynewang rynewang marked this pull request as ready for review August 27, 2024 22:14
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
@rynewang rynewang changed the title [core][dashboard] Update nodes on delta. [core][dashboard] Update nodes on delta and message_to_dict in TPE. Aug 27, 2024
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
python/ray/dashboard/modules/node/node_consts.py Outdated Show resolved Hide resolved
python/ray/_private/gcs_pubsub.py Outdated Show resolved Hide resolved
python/ray/_private/gcs_pubsub.py Outdated Show resolved Hide resolved
python/ray/dashboard/datacenter.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/state_aggregator.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
subscriber = GcsAioNodeInfoSubscriber(address=gcs_addr)
await subscriber.subscribe()

# Get all node info from GCS. For TOCTOU, it happens after the subscription.
Copy link
Contributor

Choose a reason for hiding this comment

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

What's TOCTOU?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if you do:

  1. get all
  2. subscribe
  3. for each update, ...

between 1 and 2 you can miss some nodes. so we do

  1. subscribe
  2. get all
  3. for each update, ...

https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use#:~:text=In%20software%20development%2C%20time%2Dof,the%20results%20of%20that%20check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's expand the acronym as it's not a commonly used one

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think actor_head is not doing that, it's doing get all and then subscribe so it has the TOCTOU problem?

python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/state_aggregator.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
@rynewang
Copy link
Contributor Author

Fixed all comments, reverted state_aggregator.py TPE changes (will be in another PR). PTAL! @jjyao @alexeykudinkin

python/ray/dashboard/modules/node/node_consts.py Outdated Show resolved Hide resolved
subscriber = GcsAioNodeInfoSubscriber(address=gcs_addr)
await subscriber.subscribe()

# Get all node info from GCS. For TOCTOU, it happens after the subscription.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think actor_head is not doing that, it's doing get all and then subscribe so it has the TOCTOU problem?

Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Copy link
Contributor

@alexeykudinkin alexeykudinkin left a comment

Choose a reason for hiding this comment

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

LGTM, minor comments

python/ray/_private/gcs_pubsub.py Outdated Show resolved Hide resolved
python/ray/_private/gcs_pubsub.py Outdated Show resolved Hide resolved
for actor_id, actor_table_data in actors.items()
}

def convert(actors) -> Dict[str, dict]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we duplicating the changes already made in https://github.com/anyscale/runtime/pull/928?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I can leave this to you.

subscriber = GcsAioNodeInfoSubscriber(address=gcs_addr)
await subscriber.subscribe()

# Get all node info from GCS. For TOCTOU, it happens after the subscription.
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's expand the acronym as it's not a commonly used one

python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/tests/test_node.py Outdated Show resolved Hide resolved
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
@rynewang rynewang changed the title [core][dashboard] Update nodes on delta and message_to_dict in TPE. [core][dashboard] Update nodes on delta. Aug 28, 2024
@rynewang
Copy link
Contributor Author

Thanks for the quick turn around! Let's do another round of reviews @jjyao @alexeykudinkin

Copy link
Collaborator

@jjyao jjyao left a comment

Choose a reason for hiding this comment

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

lg

@@ -136,6 +136,20 @@ def __init__(self, dashboard_head):
self.accumulative_event_processing_s = 0

async def _update_actors(self):
"""
Yields actor info. First yields all actors from GCS, then subscribes to
Copy link
Collaborator

Choose a reason for hiding this comment

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

this method doesn't yield anything?

Copy link
Collaborator

Choose a reason for hiding this comment

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

we should make the code consistent for actor_head and node_head: e.g. both use AsyncGenerator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes but let's make it another PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

we should at least fix the comment to match the current PR

python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_head.py Outdated Show resolved Hide resolved
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
@@ -136,6 +136,20 @@ def __init__(self, dashboard_head):
self.accumulative_event_processing_s = 0

async def _update_actors(self):
"""
Yields actor info. First yields all actors from GCS, then subscribes to
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should at least fix the comment to match the current PR

python/ray/dashboard/modules/node/node_consts.py Outdated Show resolved Hide resolved
python/ray/dashboard/modules/node/node_consts.py Outdated Show resolved Hide resolved
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
@rynewang rynewang enabled auto-merge (squash) August 28, 2024 23:02
@github-actions github-actions bot disabled auto-merge August 28, 2024 23:03
@rynewang rynewang enabled auto-merge (squash) August 28, 2024 23:03
Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
@github-actions github-actions bot disabled auto-merge August 29, 2024 05:00
@rynewang rynewang enabled auto-merge (squash) August 29, 2024 05:00
@rynewang rynewang merged commit 811f98e into ray-project:master Aug 29, 2024
6 checks passed
@rynewang rynewang deleted the node_head_delta branch August 29, 2024 20:22
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 12, 2024
Like actor_head.py, we now update DataSource.nodes on delta. It first
queries all node infos, then subscribes node deltas. Each delta updates:

1. DataSource.nodes[node_id]
2. DataSource.agents[node_id]
3. a warning generated after
RAY_DASHBOARD_HEAD_NODE_REGISTRATION_TIMEOUT = 10s

Note on (2) agents: it's read from internal kv, and is not readily
available until the agent.py is spawned and writes its own port to
internal kv. So we make an async task for each node to poll this port
every 1s.

It occurs that the get-all-then-subscribe code has a TOCTOU problem, so
also updated actor_head.py to first subscribe then get all actors.

Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: ujjawal-khare <ujjawal.khare@dream11.com>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
Like actor_head.py, we now update DataSource.nodes on delta. It first
queries all node infos, then subscribes node deltas. Each delta updates:

1. DataSource.nodes[node_id]
2. DataSource.agents[node_id]
3. a warning generated after
RAY_DASHBOARD_HEAD_NODE_REGISTRATION_TIMEOUT = 10s

Note on (2) agents: it's read from internal kv, and is not readily
available until the agent.py is spawned and writes its own port to
internal kv. So we make an async task for each node to poll this port
every 1s.

It occurs that the get-all-then-subscribe code has a TOCTOU problem, so
also updated actor_head.py to first subscribe then get all actors.

Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: ujjawal-khare <ujjawal.khare@dream11.com>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
Like actor_head.py, we now update DataSource.nodes on delta. It first
queries all node infos, then subscribes node deltas. Each delta updates:

1. DataSource.nodes[node_id]
2. DataSource.agents[node_id]
3. a warning generated after
RAY_DASHBOARD_HEAD_NODE_REGISTRATION_TIMEOUT = 10s

Note on (2) agents: it's read from internal kv, and is not readily
available until the agent.py is spawned and writes its own port to
internal kv. So we make an async task for each node to poll this port
every 1s.

It occurs that the get-all-then-subscribe code has a TOCTOU problem, so
also updated actor_head.py to first subscribe then get all actors.

Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: ujjawal-khare <ujjawal.khare@dream11.com>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
Like actor_head.py, we now update DataSource.nodes on delta. It first
queries all node infos, then subscribes node deltas. Each delta updates:

1. DataSource.nodes[node_id]
2. DataSource.agents[node_id]
3. a warning generated after
RAY_DASHBOARD_HEAD_NODE_REGISTRATION_TIMEOUT = 10s

Note on (2) agents: it's read from internal kv, and is not readily
available until the agent.py is spawned and writes its own port to
internal kv. So we make an async task for each node to poll this port
every 1s.

It occurs that the get-all-then-subscribe code has a TOCTOU problem, so
also updated actor_head.py to first subscribe then get all actors.

Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: ujjawal-khare <ujjawal.khare@dream11.com>
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Oct 15, 2024
Like actor_head.py, we now update DataSource.nodes on delta. It first
queries all node infos, then subscribes node deltas. Each delta updates:

1. DataSource.nodes[node_id]
2. DataSource.agents[node_id]
3. a warning generated after
RAY_DASHBOARD_HEAD_NODE_REGISTRATION_TIMEOUT = 10s

Note on (2) agents: it's read from internal kv, and is not readily
available until the agent.py is spawned and writes its own port to
internal kv. So we make an async task for each node to poll this port
every 1s.

It occurs that the get-all-then-subscribe code has a TOCTOU problem, so
also updated actor_head.py to first subscribe then get all actors.

Signed-off-by: Ruiyang Wang <rywang014@gmail.com>
Signed-off-by: ujjawal-khare <ujjawal.khare@dream11.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants