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

Add cloud symweb support #4848

Merged
merged 3 commits into from
Sep 3, 2024
Merged

Add cloud symweb support #4848

merged 3 commits into from
Sep 3, 2024

Conversation

mikem8361
Copy link
Member

Add back -mi (add symweb symbol server), -nocache and -interface options to setsymbolserver command.

Add back --internal-server support to dotnet-symbol.

Clean up the HttpSymbolStore.cs - fix HttpResponse not being properly disposed. Removed the separate authenticated client instance/var.

Fix dotnet-symbol for some heap dumps. Some didn't have coreclr.dll's debug directory contents. Catch error and continue downloading files.

@mikem8361 mikem8361 requested a review from hoyosjs August 12, 2024 23:05
@mikem8361 mikem8361 requested a review from a team as a code owner August 12, 2024 23:05
@mikem8361 mikem8361 self-assigned this Aug 12, 2024
Add back -mi (add symweb symbol server), -nocache and -interface options to setsymbolserver command.

Add back --internal-server support to dotnet-symbol.

Clean up the HttpSymbolStore.cs - fix HttpResponse not being properly disposed. Removed the separate authenticated client instance/var.

Fix dotnet-symbol for some heap dumps. Some didn't have coreclr.dll's debug directory contents. Catch error and continue downloading files.
eng/Versions.props Outdated Show resolved Hide resolved
src/Microsoft.SymbolStore/SymbolStores/HttpSymbolStore.cs Outdated Show resolved Hide resolved
src/Microsoft.SymbolStore/SymbolStores/HttpSymbolStore.cs Outdated Show resolved Hide resolved
src/Microsoft.SymbolStore/SymbolStores/HttpSymbolStore.cs Outdated Show resolved Hide resolved
}

private readonly List<string> InputFilePaths = new();
private readonly List<string> CacheDirectories = new();
private readonly List<ServerInfo> SymbolServers = new();
private TokenCredential TokenCredential = new DefaultAzureCredential(includeInteractiveCredentials: true);
Copy link
Member

Choose a reason for hiding this comment

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

why is symbol interactive but not dotnet/dump?

Copy link
Member Author

Choose a reason for hiding this comment

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

dotnet-dump has the option to be interactive with setsymbolserver --interactive. Since we do have customers that script dotnet-dump, I made it opt-in. With dotnet-symbol, I assume (maybe incorrectly) that it will always be interactive.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I make dotnet-dump interactive by default and the script users disable it?

Copy link
Member

Choose a reason for hiding this comment

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

hmm On linux I expect a good share to be headless and that's going to be the main analyze customer base for this. Thsi sounds good.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are ok with leaving this alone: dotnet-symbol is interactive by default and dotnet-dump isn't.

{
try
{
AccessToken accessToken = await TokenCredential.GetTokenAsync(new TokenRequestContext(["api://af9e1c69-e5e9-4331-8cc5-cdf93d57bafa/.default"]), token).ConfigureAwait(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I right in thinking this gets called on every symbol server request? If so, it can be unnecessarily expensive. Tokens are typically valid for several hours (the expiration timestamp is part of the AccessToken). It's wise to cache the token in memory and only call the underlying TokenCredential if the cached value is close to expiration (within ~5 minutes).
Some implementations (e.g. the Managed Identity token endpoint for Azure VMs and Azure App Service) -- but not all -- have their own token caches which makes subsequent calls cheap, but they still incur a network call (albeit to a localhost service).

Copy link
Member

Choose a reason for hiding this comment

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

This might have been my fault - I thought there was caching in Azure.Identity like MSAL with an application does (thought it was since it's backed by the library). The docs at https://learn.microsoft.com/en-us/dotnet/api/azure.identity.defaultazurecredential.gettokenasync?view=azure-dotnet specify:

Acquired tokens are cached by the credential instance. Token lifetime and refreshing is handled automatically. Where possible, reuse credential instances to optimize cache effectiveness.

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 is why Lee in CLRMD cached the token until it was 2 minutes before the expiration. Should I add similar logic?

Copy link
Member

Choose a reason for hiding this comment

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

The docs say it's cached - If that's not the case I am surprised (I know CLI creds are). I am not sure if browser creds are. DateTime has its own issues with time skew, but looking at the implementation of Azure.Identity this might be important given the cascading nature of creds and the fact some of them start a process.

Copy link
Member Author

Choose a reason for hiding this comment

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

So are we ok? Is there something you want me to do to the new token caching code?

Copy link
Member

Choose a reason for hiding this comment

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

And looks like MI token caching isn't supported. I am not too concerned with caches and IAM revocations since the tokens are so short lived for other types. This library isn't something I expect to be used much in the MI context though so it's ok.

@mikem8361
Copy link
Member Author

So everything is reviewed and approved?

@mikem8361 mikem8361 merged commit 73f3a28 into dotnet:main Sep 3, 2024
20 checks passed
@mikem8361 mikem8361 deleted the symweb branch September 3, 2024 19:56
@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants