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

UI to interact with Relay server #3484

Merged
merged 7 commits into from Jul 11, 2023

Conversation

MVarshini
Copy link
Contributor

PBENCH-1141

Develop UI to interact with Relay server 'pull' API

@MVarshini MVarshini added the Dashboard Of and relating to the Dashboard GUI label Jul 7, 2023
@MVarshini MVarshini added this to the v0.73 milestone Jul 7, 2023
@MVarshini MVarshini requested a review from dbutenhof July 7, 2023 10:21
@MVarshini MVarshini self-assigned this Jul 7, 2023
@MVarshini MVarshini added this to In progress in v0.72 via automation Jul 7, 2023
Copy link
Member

@dbutenhof dbutenhof left a comment

Choose a reason for hiding this comment

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

This is great; you seem to have some duplicate code to clean up, plus we need to finalize the header in the dialog.

dashboard/src/App.js Outdated Show resolved Hide resolved
uri: fileURI,
});
const response = await API.post(uri, null, null);
if (response.status >= 200 && response.status < 300) {
Copy link
Member

Choose a reason for hiding this comment

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

That's interesting. Does that mean that the axios response object doesn't have an ok attribute or method? Too bad.

This is probably fine, although the server will only return 201 (CREATED) or 200 (OK) on success. But anything else will be >= 400, so this will work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In axios, there is ok attribute in the response object

Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why you didn't use if (response.ok) here, then? It's not a problem, and I think this will work just fine.

Copy link
Member

Choose a reason for hiding this comment

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

I think this will work just fine.

Yes, but ok would be better.... 🙂

dashboard/src/actions/relayActions.js Outdated Show resolved Hide resolved
v0.72 automation moved this from In progress to Review in progress Jul 7, 2023
@dbutenhof dbutenhof requested review from ndokos and webbnh July 7, 2023 12:08
dbutenhof
dbutenhof previously approved these changes Jul 7, 2023
uri: fileURI,
});
const response = await API.post(uri, null, null);
if (response.status >= 200 && response.status < 300) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why you didn't use if (response.ok) here, then? It's not a problem, and I think this will work just fine.

v0.72 automation moved this from Review in progress to Reviewer approved Jul 7, 2023
webbnh
webbnh previously approved these changes Jul 10, 2023
Copy link
Member

@webbnh webbnh left a comment

Choose a reason for hiding this comment

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

This looks good (and so I'm approving), but I've pointed out some opportunities for polishing if you feel inclined.

};
const handleClose = () => {
dispatch(handleInputChange(""));
dispatch(toggleRelayModal(false));
Copy link
Member

Choose a reason for hiding this comment

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

Not a huge deal, but I think that toggleRelayModal() is misnamed -- "toggle" generally refers to inverting an existing state, like switching from "true" to "false" and "false" to "true", and, therefore, a toggle function would not require an parameter, because its behavior would be based on the existing state -- so this function really should be named something more like "setRelayModalState()".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed the function

Comment on lines 62 to 64
const pullServerData = () => {
dispatch(uploadFile());
};
Copy link
Member

Choose a reason for hiding this comment

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

It's not obvious what the benefit of wrapping this dispatch() call in a function is. I would in-line its body in the place where it is called and omit this definition (like what you did at line 97). Failing that, you know my bias toward expressions, so, if you don't in-line it, I would express this as:

  const pullServerData = () => dispatch(uploadFile());

which is simpler here, but I don't know if it will make a difference at the invocation site (i.e., my code would evaluate to a Promise while I think yours throws away the Promise and evaluates to undefined).

<p>
When a firewall prevents this direct access, the Pbench Agent can store a
dataset tarball and a manifest file on a file relay server which can be
reached by both the Pbench Agent and the Pbench Server.{" "}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want or need the trailing {" "}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it

Comment on lines 38 to 39
Enter the relay server URI reported by the Pbench Agent and press Submit
to begin the import.
Copy link
Member

Choose a reason for hiding this comment

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

Do we like "import"? I would recommend "upload". 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced

Comment on lines 43 to 44
const PopoverComponent = () => {
return (
Copy link
Member

Choose a reason for hiding this comment

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

Using a code blob which does nothing but invoke a return statement is pointless -- just remove the brances and the return statement and let the expression to be returned stand as the value of the arrow function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 15 to 17
const uri = uriTemplate(endpoints, "relay", {
uri: fileURI,
});
Copy link
Member

Choose a reason for hiding this comment

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

If you remove the trailing comma from line 16, I bet Prettier will combine these three lines into one, which would be nicer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha

uri: fileURI,
});
const response = await API.post(uri, null, null);
if (response.status >= 200 && response.status < 300) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this will work just fine.

Yes, but ok would be better.... 🙂

Comment on lines +23 to +24
if (response.status === 201) {
// need to remove once response returns the uploaded dataset
dispatch(getDatasets());
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the code comment at line 24. (Should this instead be applied to line 21, which removes the modal dialog display?)

Copy link
Member

Choose a reason for hiding this comment

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

@MVarshini : despite this comment, it's probably best to leave the code alone for now and come back later.

However, for what it's worth, if you want to think about your refresh optimization ideas, I've updated the staging server with the latest code from main. I restarted the relay and pushed a dataset, and now (omitting the internal hostnames from GitHub comments):

POST https://<staging-server>/api/v1/relay/http://<relay>:8002/RELAY/4bcada96aff3b1d9a62540962204c833c12cd9266b10d747e1ef71b278d23a09

will return:

{
    "message": "File successfully uploaded",
    "name": "pbench-user-benchmark_newrelay_2023.07.11T12.04.37",
    "resource_id": "a9b1daaa5549c4063c00e1d62115c9e5"
}

Comment on lines +31 to +30
);
dispatch({ type: TYPES.NETWORK_ERROR });
Copy link
Member

Choose a reason for hiding this comment

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

What does the NETWORK_ERROR action do? (I don't see a reducer which actually handles it.)

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand that, either: I haven't noticed anything that sets a payload value, but the actions here and in the visualizer PR both use this unconditionally when errors occur, but I don't see any implementation of that type code.

@MVarshini MVarshini dismissed stale reviews from webbnh and dbutenhof via 7d7a222 July 11, 2023 10:39
v0.72 automation moved this from Reviewer approved to Review in progress Jul 11, 2023
Comment on lines +23 to +24
if (response.status === 201) {
// need to remove once response returns the uploaded dataset
dispatch(getDatasets());
}
Copy link
Member

Choose a reason for hiding this comment

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

@MVarshini : despite this comment, it's probably best to leave the code alone for now and come back later.

However, for what it's worth, if you want to think about your refresh optimization ideas, I've updated the staging server with the latest code from main. I restarted the relay and pushed a dataset, and now (omitting the internal hostnames from GitHub comments):

POST https://<staging-server>/api/v1/relay/http://<relay>:8002/RELAY/4bcada96aff3b1d9a62540962204c833c12cd9266b10d747e1ef71b278d23a09

will return:

{
    "message": "File successfully uploaded",
    "name": "pbench-user-benchmark_newrelay_2023.07.11T12.04.37",
    "resource_id": "a9b1daaa5549c4063c00e1d62115c9e5"
}

Comment on lines +31 to +30
);
dispatch({ type: TYPES.NETWORK_ERROR });
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand that, either: I haven't noticed anything that sets a payload value, but the actions here and in the visualizer PR both use this unconditionally when errors occur, but I don't see any implementation of that type code.

v0.72 automation moved this from Review in progress to Reviewer approved Jul 11, 2023
@dbutenhof dbutenhof merged commit 32c6c5c into distributed-system-analysis:main Jul 11, 2023
4 checks passed
v0.72 automation moved this from Reviewer approved to Done Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dashboard Of and relating to the Dashboard GUI
Projects
v0.72
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants