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

[Dashboard] Migrate Logs page to use state api. #41474

Merged
merged 10 commits into from
Nov 29, 2023

Conversation

alanwguo
Copy link
Contributor

@alanwguo alanwguo commented Nov 29, 2023

Why are these changes needed?

  1. Migrates to use state-api, to unify behavior with CLI and UI
  2. Delete log_proxy API, it's legacy and has some security issues.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Delete log_proxy API

Signed-off-by: Alan Guo <aguo@anyscale.com>
Signed-off-by: Alan Guo <aguo@anyscale.com>
Signed-off-by: Alan Guo <aguo@anyscale.com>
Copy link
Contributor

@rkooo567 rkooo567 left a comment

Choose a reason for hiding this comment

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

It seems good to me in my first look! I think for the frontend code, it'd be great other experience team members take a look at it. (I will wait for their approval)

@@ -296,7 +296,7 @@ async def ListLogs(self, request, context):
)
log_files = []
for p in path.glob(request.glob_filter):
log_files.append(str(p.relative_to(path)))
log_files.append(str(p.relative_to(path)) + ("/" if p.is_dir() else ""))
Copy link
Contributor

Choose a reason for hiding this comment

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

does it work with nested directory inside log dir btw?

Copy link
Contributor

Choose a reason for hiding this comment

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

(it doesn't have to work imo, but i'd like to just know)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, I tested this

</Button>
<SearchInput
defaultValue={fileName}
label="File Name"
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw, this doesn't seem to work when I used it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh shoot, I didn't test this. let me test thi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Signed-off-by: Alan Guo <aguo@anyscale.com>
Signed-off-by: Alan Guo <aguo@anyscale.com>
Signed-off-by: Alan Guo <aguo@anyscale.com>
Copy link
Contributor

@brycehuang30 brycehuang30 left a comment

Choose a reason for hiding this comment

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

Frontend code LGTM! Though I have limited context and I didn't test-run the code.

Comment on lines +185 to +187
const fileNameWithoutParent = fileName.startsWith(parentFolder)
? fileName.substring(parentFolder.length)
: fileName;
Copy link
Contributor

Choose a reason for hiding this comment

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

To confirm, the files listed by listStateApiLogs could be either filepath or filename, so that's why we need this branching, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the files listed by listStateApiLogs contains the full path of the logs relative to the log root. This logic just hides the parent directories from the file name when browsing through folders.

Signed-off-by: Alan Guo <aguo@anyscale.com>
@pcmoritz
Copy link
Contributor

@alanwguo Thanks a lot for doing this -- there is still a failing test, can you fix it? https://buildkite.com/ray-project/premerge/builds/13040#018c197d-5f5b-4abd-999b-08be7f0af010

Copy link
Contributor

@pcmoritz pcmoritz left a comment

Choose a reason for hiding this comment

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

I tried it locally and it is working :)

@alanwguo
Copy link
Contributor Author

verified that multi-node log viewing continues to work. will fix the faiiling test

Signed-off-by: Alan Guo <aguo@anyscale.com>
Signed-off-by: Alan Guo <aguo@anyscale.com>
@alanwguo
Copy link
Contributor Author

verified again with latest changes.
This should be good to merge as soon as tests pass

@pcmoritz
Copy link
Contributor

@alanwguo There seem to be a few more Javascript test assertions failing :)

Signed-off-by: Alan Guo <aguo@anyscale.com>
@alanwguo
Copy link
Contributor Author

alanwguo commented Nov 29, 2023

ugh. at least the test case is properly checking things. Okay. I've updated the test cases and it should be passing now...

@pcmoritz pcmoritz merged commit 2a6c6ee into ray-project:master Nov 29, 2023
8 of 15 checks passed
pcmoritz pushed a commit to pcmoritz/ray-1 that referenced this pull request Nov 30, 2023
Migrates to use state-api, to unify behavior with CLI and UI
Delete log_proxy API, it's legacy and has some security issues.

---------

Signed-off-by: Alan Guo <aguo@anyscale.com>
pcmoritz pushed a commit to pcmoritz/ray-1 that referenced this pull request Nov 30, 2023
Migrates to use state-api, to unify behavior with CLI and UI
Delete log_proxy API, it's legacy and has some security issues.

---------

Signed-off-by: Alan Guo <aguo@anyscale.com>
pcmoritz added a commit that referenced this pull request Nov 30, 2023
Migrates to use state-api, to unify behavior with CLI and UI
Delete log_proxy API, it's legacy and has some security issues.

---------

Signed-off-by: Alan Guo <aguo@anyscale.com>
Co-authored-by: Alan Guo <aguo@anyscale.com>
aslonnie pushed a commit that referenced this pull request Nov 30, 2023
* [Dashboard] Prevent Directory Traversal (#39018)

Ensure we can only go to subdirectories of logs and static resources.

* [core][state][log] State API should not allow reading files outside of the ray log directory on all ray nodes. (#41467)

State API log retrieval has a security bug where one could pass:

relative paths like "../../../xxx" to get file outside of ray's log dir
absolute path that's refers to other files to get file somewhere else.
This PR fixes both issues such that one could only read logs under the ray logs directory.

---------

Signed-off-by: rickyyx <rickyx@anyscale.com>

* [Dashboard] Migrate Logs page to use state api. (#41474)

Migrates to use state-api, to unify behavior with CLI and UI
Delete log_proxy API, it's legacy and has some security issues.

---------

Signed-off-by: Alan Guo <aguo@anyscale.com>

* [core][state][log] Enable following symlinks that point outside of the `root_log_dir` when resolving paths (#41502)

Follow-up to: #41467. The change incidentally broke log retrieval on mac os because /tmp is a symlink to /private/tmp.

This PR avoids resolving the symlink until after we do the subdir check. This solves the mac os problem and generically enables file paths that contain symlinks outside of the root_log_dir.

---------

Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>

---------

Signed-off-by: rickyyx <rickyx@anyscale.com>
Signed-off-by: Alan Guo <aguo@anyscale.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Ian Rodney <ian.rodney@gmail.com>
Co-authored-by: Ricky Xu <xuchen727@hotmail.com>
Co-authored-by: Alan Guo <aguo@anyscale.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
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.

None yet

4 participants