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

Use cancellation token and increase timeout for docker inspect fetchi… #502

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Aspire.Hosting/Dashboard/ViewModelCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ when _filterResource(customResource) && ProcessChange(_resourceMap, watchEventTy
{
// Container is ready to be inspected
// This task when returns will generate a notification in channel
_ = Task.Run(() => ComputeEnvironmentVariablesFromDocker(container));
_ = Task.Run(() => ComputeEnvironmentVariablesFromDocker(container, _cancellationToken));
_resourcesWithTaskLaunched.Add(name);
}
// For containers we always send list of env vars which we may have computed earlier from docker command
Expand Down Expand Up @@ -350,7 +350,7 @@ public ValueTask DisposeAsync()
return ValueTask.CompletedTask;
}

private async Task ComputeEnvironmentVariablesFromDocker(Container container)
private async Task ComputeEnvironmentVariablesFromDocker(Container container, CancellationToken cancellationToken)
{
IAsyncDisposable? processDisposable = null;
try
Expand All @@ -367,7 +367,7 @@ private async Task ComputeEnvironmentVariablesFromDocker(Container container)

(task, processDisposable) = ProcessUtil.Run(spec);

var exitCode = (await task.WaitAsync(TimeSpan.FromSeconds(5)).ConfigureAwait(false)).ExitCode;
var exitCode = (await task.WaitAsync(TimeSpan.FromSeconds(30), cancellationToken).ConfigureAwait(false)).ExitCode;
Copy link
Member

Choose a reason for hiding this comment

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

Docker really forcing us to true "eventual" consistency it looks like. That's unfortunate we'd need a timeout that long. But its not blocking so seems ok.

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 think my discussion with @karolz-ms it was indicated that docker can take long time. We wait for 10s to verify if docker is running in our startup. Since that is exception code path and this is not, I went with large amount. If we timeout here, we won't retry till cache is invalidated so just being overly generous. Non-blocking nature should help us avoid any impact of this.

if (exitCode == 0)
{
var jsonArray = JsonNode.Parse(outputStringBuilder.ToString())?.AsArray();
Expand Down