Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Add an endpoint to run the server processes end-to-end. #3544

Merged
merged 7 commits into from
Mar 6, 2020

Conversation

kevensen
Copy link
Contributor

@kevensen kevensen commented Dec 16, 2019

Resolves #3342

@kevensen kevensen self-assigned this Dec 16, 2019
@kevensen kevensen changed the title Server run path [WIP] Server run path Dec 16, 2019
@kevensen
Copy link
Contributor Author

@gkowalski-google just FYI, I am going to close this PR in favor of another which I will open this morning.

@kevensen
Copy link
Contributor Author

@gkowalski-google Please disregard my last. I want to complete this PR. I'll make the fix you suggested.

@kevensen kevensen changed the title [WIP] Server run path Server run path Dec 20, 2019
@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@kevensen
Copy link
Contributor Author

/gcbrun


if model_status in ['SUCCESS', 'PARTIAL_SUCCESS']:
for progress in client.scanner.run(scanner_name=None):
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are just passing here, can we just do below, instead of looping?

client.scanner.run(scanner_name=None)
client.notifier.run(inventory_id, 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would certainly be cleaner. Because the gRPC reply to a run request is a stream, we need to consume the entire stream before proceeding. Without the loop, the execution would continue without waiting for the scan to complete, for example.

google/cloud/forseti/services/server_config/service.py Outdated Show resolved Hide resolved
google/cloud/forseti/services/server_config/service.py Outdated Show resolved Hide resolved
google/cloud/forseti/services/server_config/service.py Outdated Show resolved Hide resolved
@kevensen kevensen changed the title Server run path Add an endpoint to run the server processes end-to-end. Mar 5, 2020
Copy link
Contributor

@blueandgold blueandgold left a comment

Choose a reason for hiding this comment

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

Thanks for this new endpoint! Just a couple of nits to fix before merge. Otherwise, LGTM

client.switch_model(model_handle)

if model_status not in ['SUCCESS', 'PARTIAL_SUCCESS']:
message = 'ERROR: Model status is {}'.format(model_status)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that you need to add a step to delete model here. And also a return the message step.

@@ -728,6 +735,13 @@ def do_get_configuration():
"""Get the configuration of the server."""
output.write(client.get_server_configuration())

def do_server_run():
"""Run the Forseti server, end-to-end"""
# for message in client.server_run():
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need these codes to be commented out? If not, remove.

@blueandgold
Copy link
Contributor

@kevensen please test this functionally before merging, thanks.

@kevensen
Copy link
Contributor Author

kevensen commented Mar 5, 2020

Will do

@kevensen kevensen merged commit 720f836 into forseti-security:master Mar 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server Side Run Logic
4 participants