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

[2/2][Serve] Support dynamic log #40735

Merged
merged 55 commits into from
Nov 9, 2023

Conversation

sihanwang41
Copy link
Contributor

@sihanwang41 sihanwang41 commented Oct 27, 2023

Why are these changes needed?

  • Follow up with the pr to implement the dynamic logging.

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 :(

Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
@sihanwang41 sihanwang41 marked this pull request as ready for review October 31, 2023 20:14
@sihanwang41 sihanwang41 changed the title [2/2][Serve][WIP] Support dynamic log [2/2][Serve] Support dynamic log Oct 31, 2023
python/ray/serve/_private/application_state.py Outdated Show resolved Hide resolved
python/ray/serve/_private/controller.py Outdated Show resolved Hide resolved
python/ray/serve/_private/controller.py Outdated Show resolved Hide resolved
python/ray/serve/_private/controller.py Outdated Show resolved Hide resolved
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
@edoakes edoakes requested a review from a team November 7, 2023 21:40
@edoakes
Copy link
Contributor

edoakes commented Nov 7, 2023

Update PR description please

Comment on lines 1043 to 1047
# When there is no deployment entries and app logging config is set,
# apply app logging config to all existing deployment logging config.
if not deployment_override_options and app_logging_config:
for deployment in list(deployment_infos.values()):
deployment.deployment_config.logging_config = app_logging_config
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 this logic is not comprehensive. If there are deployment_override_options, but the list is not complete, then the deployments not in the list will not have their logging config overridden. Am I correct?

Copy link
Contributor Author

@sihanwang41 sihanwang41 Nov 8, 2023

Choose a reason for hiding this comment

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

Updated logic:

  1. if application logging config is set, apply to all existing deployment config.
  2. if deployment logging config is set, will rely on existing for loop to update the logging config for each deployment.

python/ray/serve/_private/config.py Outdated Show resolved Hide resolved
python/ray/serve/_private/config.py Show resolved Hide resolved
Comment on lines 239 to 242
logger.debug(
"Configure the serve controller logger "
f"with logging config: {self.logging_config}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would make sure this only logs when the config is changed then make it info-level (it's useful)

Suggested change
logger.debug(
"Configure the serve controller logger "
f"with logging config: {self.logging_config}"
)
logger.debug(
f"Serve controller logging config updated to: {self.logging_config}."
)

python/ray/serve/_private/controller.py Outdated Show resolved Hide resolved
python/ray/serve/tests/test_api.py Outdated Show resolved Hide resolved
resp = requests.get("http:https://127.0.0.1:8000/")
assert resp.status_code == 200

def test_application_logging_overwrite(self, serve_instance):
Copy link
Contributor

Choose a reason for hiding this comment

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

please also add a test for overwriting per-deployment

Copy link
Contributor Author

@sihanwang41 sihanwang41 Nov 8, 2023

Choose a reason for hiding this comment

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

done! Check test_application_logging_overwrite

python/ray/serve/schema.py Outdated Show resolved Hide resolved
python/ray/serve/schema.py Outdated Show resolved Hide resolved
python/ray/serve/schema.py Outdated Show resolved Hide resolved
python/ray/serve/_private/logging_utils.py Outdated Show resolved Hide resolved
python/ray/serve/schema.py Outdated Show resolved Hide resolved
python/ray/serve/_private/application_state.py Outdated Show resolved Hide resolved
python/ray/serve/_private/application_state.py Outdated Show resolved Hide resolved
@@ -110,6 +111,7 @@ def _check_http_options(
def _start_controller(
http_options: Union[None, dict, HTTPOptions] = None,
grpc_options: Union[None, dict, gRPCOptions] = None,
logging_config: Union[None, dict, LoggingConfig] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to system_logging_config just like how we have update_system_logging_config in the client? It's a bit confusing to see logging_config in three different places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also change the config option in ServeDeploySchema? There's the same issue of the same option name being used in 3 places. Aware this is an API change, will leave it up to the team to decide.

Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
@sihanwang41
Copy link
Contributor Author

Hi @edoakes and @zcin , ptal, thx!

Copy link
Contributor

@edoakes edoakes left a comment

Choose a reason for hiding this comment

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

Just one clarification then lgtm

python/ray/serve/_private/api.py Outdated Show resolved Hide resolved
Comment on lines 963 to 968
# If application loggin config is set, apply to all existing deployment config
if app_logging_config:
for _, info in deployment_infos.items():
info.deployment_config.logging_config = LoggingConfig(
**app_logging_config
).dict()
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this override all deployments' logging config, even if there is one specified for the deployment? The desired behavior is being able to override deployment > application > system (this is standard practice, finest granularity should take precedence).

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm from the tests it looks like what I'm saying is already the case. I'm not following how this works because it looks like you're overriding all deployments' logging config here with the application one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apply the application logging config here.
And then we have the for loop to override the deployment config if set. https://github.com/ray-project/ray/blob/master/python/ray/serve/_private/application_state.py#L1020

So that deployment logging config will always be set lastly.

Copy link
Contributor

Choose a reason for hiding this comment

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

What if the user set logging_config in the code? It will always be overridden by the application level logging config.

Copy link
Contributor

Choose a reason for hiding this comment

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

That was my confusion as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

synced with Cindy offline, we apply the application config out of the function. So that we don't need to track whether setting in the deployment code or yaml file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. So this works as-is? Can you leave a comment describing this btw it's pretty hard to see from the code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to write a unit test to cover this case. Yeah, I will leave comments too!

python/ray/serve/tests/test_logging.py Outdated Show resolved Hide resolved
Signed-off-by: Sihan Wang <[email protected]>
Signed-off-by: Sihan Wang <[email protected]>
Copy link
Contributor

@zcin zcin left a comment

Choose a reason for hiding this comment

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

Some comments + 1 pending comment from above, otherwise LGTM

Comment on lines 963 to 968
# If application loggin config is set, apply to all existing deployment config
if app_logging_config:
for _, info in deployment_infos.items():
info.deployment_config.logging_config = LoggingConfig(
**app_logging_config
).dict()
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the user set logging_config in the code? It will always be overridden by the application level logging config.

python/ray/serve/_private/logging_utils.py Outdated Show resolved Hide resolved
Signed-off-by: Sihan Wang <[email protected]>
@@ -572,7 +573,18 @@ def _reconcile_target_deployments(self) -> None:

# Set target state for each deployment
for deployment_name, info in self._target_state.deployment_infos.items():
self.apply_deployment_info(deployment_name, info)
deploy_info = deepcopy(info)
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 the logic itself looks good, just flagging that we will execute a deepcopy once per deployment for every control loop iteration. I think it would be more efficient to store a copy of this info object since it doesn't change between control loop iterations.

@sihanwang41
Copy link
Contributor Author

@architkulkarni ready to merge, windows telemetry is flacky in master.

@architkulkarni architkulkarni merged commit 00a1dcb into ray-project:master Nov 9, 2023
25 of 30 checks passed
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Nov 29, 2023
Follow up with the pr to implement the dynamic logging.
---------

Signed-off-by: Sihan Wang <[email protected]>
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