Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

EX-1850 - Implement Report query and deletion #2304

Merged
merged 5 commits into from
Oct 6, 2020
Merged

EX-1850 - Implement Report query and deletion #2304

merged 5 commits into from
Oct 6, 2020

Conversation

johnsonw
Copy link
Contributor

@johnsonw johnsonw commented Oct 2, 2020

Implement Report query and deletion in graphql

Signed-off-by: johnsonw wjohnson@whamcloud.com


This change is Reviewable

@johnsonw johnsonw self-assigned this Oct 2, 2020
@johnsonw
Copy link
Contributor Author

johnsonw commented Oct 2, 2020

image

image

[root@adm report]# touch file1.txt
[root@adm report]# ls
file1.txt
[root@adm report]# ls
[root@adm report]#

iml-api/src/graphql.rs Outdated Show resolved Hide resolved
iml-api/src/graphql.rs Outdated Show resolved Hide resolved
@johnsonw
Copy link
Contributor Author

johnsonw commented Oct 5, 2020

Docker test:

Displaying files:
image

[root@iml-api report]# ls
[root@iml-api report]# ls
expiring_fids-fs-32621d4c-9b38-4d22-8d4a-9a45d96f5667.txt

Deleting a file:
image

[root@iml-api report]# ls
expiring_fids-fs-52ee437c-646a-402a-9df3-e90810a77a68.txt
[root@iml-api report]# ls
[root@iml-api report]#

johnsonw and others added 2 commits October 5, 2020 12:52
Implement Report query and deletion in graphql

Signed-off-by: johnsonw <wjohnson@whamcloud.com>
Signed-off-by: Joe Grund <jgrund@whamcloud.io>
@johnsonw
Copy link
Contributor Author

johnsonw commented Oct 5, 2020

Trying to delete a file maliciously:

image

@johnsonw johnsonw marked this pull request as ready for review October 5, 2020 16:58
@jgrund jgrund self-requested a review October 5, 2020 17:45
…ndpoints to view and remove reports under /var/spool/iml/report.

Signed-off-by: johnsonw <wjohnson@whamcloud.com>
Signed-off-by: johnsonw <wjohnson@whamcloud.com>
mkpankov
mkpankov previously approved these changes Oct 6, 2020
Copy link
Contributor

@mkpankov mkpankov left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r4.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @johnsonw)

@johnsonw
Copy link
Contributor Author

johnsonw commented Oct 6, 2020

Integration tests passed here: https://build.whamcloud.com/view/IML/job/manager-for-lustre/2489/

@johnsonw
Copy link
Contributor Author

johnsonw commented Oct 6, 2020

Also, I've updated the query to return both the filesize and modified time. The data returned now looks like this:

{
  "data": {
    "stratagemReports": [
      {
        "filename": "/var/spool/iml/report/test.txt",
        "modifyTime": "2020-10-05T21:51:57.887528595+00:00",
        "size": 0
      }
    ]
  }
}

@johnsonw
Copy link
Contributor Author

johnsonw commented Oct 6, 2020

The CodeQL failure is unrelated and I see it in other patches as well.

@jgrund
Copy link
Member

jgrund commented Oct 6, 2020

Does this now print the whole file path or just the name?

@johnsonw
Copy link
Contributor Author

johnsonw commented Oct 6, 2020

It's printing the whole file path. I thought it might be useful to show the whole path in case they weren't aware of the report being under /var/spool/iml. However, we could always print a note above indicating where the file lives and then just show the filename. What are your thoughts?

@jgrund
Copy link
Member

jgrund commented Oct 6, 2020

Probably just the filename. The reports can be downloaded at /report/<filename>, so it's probably not important to know the full path. In addition, if we are running in containers, that path will exist inside a container only and will be confusing to users that it's not on the host.

@johnsonw
Copy link
Contributor Author

johnsonw commented Oct 6, 2020

Sure, makes sense. I will update it to be the filename only.

…te path.

Signed-off-by: johnsonw <wjohnson@whamcloud.com>
@johnsonw
Copy link
Contributor Author

johnsonw commented Oct 6, 2020

Here is an updated screenshot. I created three files under /var/spool/iml/report. Notice that only the filename is now displayed:
test1.txt = 1Kib
test2.txt = 1Mib
test3.txt = 1Gib

image

@johnsonw johnsonw requested a review from mkpankov October 6, 2020 16:18
let path = tokio::fs::canonicalize(report_base.join(filename)).await?;

if !path.starts_with(report_base) {
return Err(FieldError::new("Invalid path", Value::null()));
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
return Err(FieldError::new("Invalid path", Value::null()));
return Err(FieldError::new("Invalid filename", Value::null()));

.await?
.into_iter()
.map(|filename| {
fs::canonicalize(get_report_path().join(filename.clone()))
Copy link
Member

@ip1981 ip1981 Oct 6, 2020

Choose a reason for hiding this comment

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

Could call let report_dir = get_report_path() just once at the beginning?

@jgrund jgrund merged commit 3a7da93 into master Oct 6, 2020
@jgrund jgrund deleted the EX-1850 branch October 6, 2020 17:03
/// List completed Stratagem reports that currently reside on the manager node.
/// Note: All report names must be valid unicode.
async fn stratagem_reports(_context: &Context) -> juniper::FieldResult<Vec<StratagemReport>> {
let paths = tokio::fs::read_dir(get_report_path()).await?;
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
let paths = tokio::fs::read_dir(get_report_path()).await?;
let paths = fs::read_dir(get_report_path()).await?;

.await?
.into_iter()
.map(|filename| {
fs::canonicalize(get_report_path().join(filename.clone()))
Copy link
Member

Choose a reason for hiding this comment

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

Is clone() needed?

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

Successfully merging this pull request may close these issues.

4 participants