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

Fix azure bugs, expand logging #2890

Merged
merged 4 commits into from
Nov 8, 2024

Conversation

Arkatufus
Copy link
Contributor

@Arkatufus Arkatufus commented Nov 8, 2024

Related to akkadotnet/akka.net#7379

Changes

  • Move LeaseActor from /user to /system
  • Improves logging verbosity for easier debugging
  • Fix bug that prevents Lease implementation from returning more than one result
  • Fix Azure blob container client instantiation problem

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Copy link
Contributor Author

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

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

Self review


public AzureApiImpl(ActorSystem system, AzureLeaseSettings settings)
{
_settings = settings;
_log = Logging.GetLogger(system, GetType());

_containerClient = new Lazy<BlobContainerClient>(() =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actual fix, removed Lazy<T> because it is caching container client value.

Comment on lines +68 to +84
private async Task<BlobContainerClient> ContainerClient()
{
var serviceClient = _settings.AzureCredential != null && _settings.ServiceEndpoint != null
? new BlobServiceClient(_settings.ServiceEndpoint, _settings.AzureCredential, _settings.BlobClientOptions)
: new BlobServiceClient(_settings.ConnectionString);

var client = serviceClient.GetBlobContainerClient(_settings.ContainerName);

// Make sure that `CreateIfNotExistsAsync()` only get called once for every AzureApi instance
if (!_initialized)
{
await client.CreateIfNotExistsAsync();
_initialized = true;
}

return client;
}
Copy link
Contributor Author

@Arkatufus Arkatufus Nov 8, 2024

Choose a reason for hiding this comment

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

Actual fix, instead of using Lazy<T>, make sure that a new container client is instantiated every time a container client is requested, but only try to initialize the azure container once for every instance of AzureApiImpl

Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

LGTM

@Aaronontheweb Aaronontheweb enabled auto-merge (squash) November 8, 2024 17:25
@Aaronontheweb Aaronontheweb merged commit 4404cf6 into akkadotnet:dev Nov 8, 2024
3 checks passed
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.

2 participants