Skip to content

Update capabilities and log worker metadata after specialization #9020

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

Merged
merged 4 commits into from
Jan 11, 2023

Conversation

kshyju
Copy link
Member

@kshyju kshyju commented Jan 5, 2023

This is a second set of changes on host side to address #8983. This changes follows the proto file changes made in Azure/azure-functions-language-worker-protobuf#90

In placeholder & specialization use case, the worker metadata and capabilities are available only after specialization (env reload response). In this PR, Updating the code path which handles env reload request to refresh the capabilities and log the worker metadata.

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

Additional information

@kshyju kshyju requested a review from a team as a code owner January 5, 2023 18:12
@kshyju kshyju force-pushed the shkr/env_reload_response_for_spcln branch from 0752ad0 to 0379800 Compare January 6, 2023 18:19
- Update App Service Authentication/Authorization on Linux Consumption from 1.4.17 to 1.5.1 [Release Note](https://github.com/Azure/app-service-announcements/issues/406)
- Upgraded proto files to v1.7.1-protofile release (#9023)
Copy link
Member Author

Choose a reason for hiding this comment

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

This one is not part of this PR. I forgot to include release_notes update in 9023.

@kshyju kshyju requested a review from liliankasem January 9, 2023 20:12
workerMetadata.UpdateWorkerMetadata(_workerConfig);
var workerMetadataString = workerMetadata.ToString();
_metricsLogger.LogEvent(MetricEventNames.WorkerMetadata, functionName: null, workerMetadataString);
_workerChannelLogger.LogDebug("Worker metadata: {workerMetadata}", workerMetadataString);
Copy link
Contributor

Choose a reason for hiding this comment

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

This may not be applicable for the scenario here but wanted to call out that for one of my previous PRs - refer, I got to know that adding log lines here has perf impact. So, we can double check if this log is really needed here and not affecting the perf.

Copy link
Member Author

Choose a reason for hiding this comment

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

This logging was existing code, which I moved to a private method now. So this PR should not make a perf impact as such.

But I get your point. We can definitely discuss removing this logging entry as we have this information getting logged to functions metrics as well. Thoughts @liliankasem ?

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 if a detector or other teams are using the information from the log somewhere so I can't say it's 100% safe to remove

@@ -395,7 +397,7 @@ internal void WorkerInitResponse(GrpcEvent initEvent)
UpdateCapabilities(_initMessage.Capabilities);

_isSharedMemoryDataTransferEnabled = IsSharedMemoryDataTransferEnabled();
_cancelCapabilityEnabled = !string.IsNullOrEmpty(_workerCapabilities.GetCapabilityState(RpcWorkerConstants.HandlesInvocationCancelMessage));
_cancelCapabilityEnabled ??= !string.IsNullOrEmpty(_workerCapabilities.GetCapabilityState(RpcWorkerConstants.HandlesInvocationCancelMessage));
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 value of this capability is set to a false-y string? false, 0, etc

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, this may not be part of this PR but can we update the name _cancelCapabilityEnabled to may be _invocationCancelCapabilityEnabled or something on similar lines. Only cancel capability is not communicating the meaning till I saw RpcWorkerConstants.HandlesInvocationCancelMessage

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, host code(in various places) checks the existence of the capability instead of the value being truthy. I agree, Ideally it should be a truthy check. but that might involve coordinating with workers to make sure they send the correct value.

Currently dotnet worker sends capability when the value is truthy. Ex: https://github.com/Azure/azure-functions-dotnet-worker/blob/14cc88859a1b7bbf68ee43409a1ad45a6e8362cb/src/DotNetWorker.Grpc/GrpcWorker.cs#L222-L229

@surgupta-msft surgupta-msft self-requested a review January 10, 2023 19:46
_workerChannelLogger.LogDebug("Worker metadata: {workerMetadata}", workerMetadata);
}
// In placeholder scenario, the capabilities and worker metadata will not be available
// until specialization is done (env reload request). So these can be removed from worker init response code path.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should check our understanding here with @soninaren as I remember change in flow on placeholder side for the work - selective loading of extensions.

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.

4 participants