Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchdenny committed Mar 25, 2024
1 parent ca3897a commit d099b79
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ internal static IResourceBuilder<PostgresServerResource> PublishAsAzurePostgresF

var resource = new AzurePostgresResource(builder.Resource, configureConstruct);
var resourceBuilder = builder.ApplicationBuilder.CreateResourceBuilder(resource)
.WithParameter(AzureBicepResource.KnownParameters.PrincipalId)
.WithParameter(AzureBicepResource.KnownParameters.KeyVaultName)
.WithManifestPublishingCallback(resource.WriteToManifest)
.WithLoginAndPassword(builder.Resource);
Expand Down
10 changes: 6 additions & 4 deletions src/Aspire.Hosting/Dcp/KubernetesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using k8s.Exceptions;
using k8s.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Polly;
using Polly.Retry;

Expand Down Expand Up @@ -42,7 +43,7 @@ Task<Stream> GetLogStreamAsync<T>(
CancellationToken cancellationToken = default) where T : CustomResource;
}

internal sealed class KubernetesService(ILogger<KubernetesService> logger, DcpOptions dcpOptions, Locations locations) : IKubernetesService, IDisposable
internal sealed class KubernetesService(ILogger<KubernetesService> logger, IOptions<DcpOptions> dcpOptions, Locations locations) : IKubernetesService, IDisposable
{
private static readonly TimeSpan s_initialRetryDelay = TimeSpan.FromMilliseconds(100);
private static GroupVersion GroupVersion => Model.Dcp.GroupVersion;
Expand Down Expand Up @@ -309,8 +310,8 @@ private void EnsureKubernetes()
{
ShouldHandle = new PredicateBuilder().Handle<IOException>(e => e.Message.StartsWith("The process cannot access the file")),
BackoffType = DelayBackoffType.Constant,
MaxRetryAttempts = dcpOptions.KubernetesConfigReadRetryCount,
MaxDelay = TimeSpan.FromSeconds(dcpOptions.KubernetesConfigReadRetryIntervalSeconds),
MaxRetryAttempts = dcpOptions.Value.KubernetesConfigReadRetryCount,
MaxDelay = TimeSpan.FromSeconds(dcpOptions.Value.KubernetesConfigReadRetryIntervalSeconds),
OnRetry = (retry) =>
{
logger.LogDebug(
Expand All @@ -326,10 +327,11 @@ private void EnsureKubernetes()

pipeline.Execute(() =>
{
logger.LogDebug("Reading Kubernetes configuration from '{DcpKubeconfigPath}' on thread {ThreadId}.", locations.DcpKubeconfigPath, Environment.CurrentManagedThreadId);
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile(kubeconfigPath: locations.DcpKubeconfigPath, useRelativePaths: false);
logger.LogDebug("Successfully read Kubernetes configuration from '{DcpKubeconfigPath}'.", locations.DcpKubeconfigPath);
_kubernetes = new DcpKubernetesClient(config);
});

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Debug"
}
},
"AllowedHosts": "*"
Expand Down

0 comments on commit d099b79

Please sign in to comment.