Skip to content

Update PersistenceManager not to fail when used in a read-only file system #3913

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

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

dscpinheiro
Copy link
Contributor

Fixes #3801

Description

Updates the SDK's PersistenceManager not to fail when running on a read-only file system.

I also included the suggested new option to ignore the legacy persistence store when the SDK is going through the default profile resolution search (via the CredentialProfileStoreChain).

Motivation and Context

#3801 and DOTNET-8123

Testing

  • Dry-run: DRY_RUN-5960c79f-a0e7-4dad-97c9-61374e1d2324
  • I also created a console app using the PersistenceManager class directly and confirmed running it in a read-only file system does not throw a terminating error anymore:
using Amazon;
using Amazon.Runtime.Internal.Settings;

AWSConfigs.LoggingConfig.LogTo = LoggingOptions.Console;
AWSConfigs.LoggingConfig.LogMetricsFormat = LogMetricsFormatOption.JSON;
AWSConfigs.LoggingConfig.LogResponses = ResponseLoggingOption.Always;
AWSConfigs.LoggingConfig.LogMetrics = true;

var instance = PersistenceManager.Instance;
Console.WriteLine($"Got here! Instance type is {instance.GetType()}");

Before:

PS> docker run --read-only --rm my-dotnet-app
Unhandled exception. System.TypeInitializationException: The type initializer for 'Amazon.Runtime.Internal.Settings.PersistenceManager' threw an exception.
 ---> System.IO.IOException: Read-only file system : '/root/AppData'

After:

PS> docker run --read-only --rm my-dotnet-app
PersistenceManager 1|2025-07-10T23:52:15.244Z|ERROR|Unable to initialize 'PersistenceManager'. Falling back to 'InMemoryPersistenceManager'. --> System.IO.IOException: Read-only file system : '/root/AppData'
Got here! Instance type is Amazon.Runtime.Internal.Settings.InMemoryPersistenceManager

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

License

  • I confirm that this pull request can be released under the Apache 2 license

@sankettangade sankettangade requested a review from AlexDaines July 11, 2025 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System.IO.IOException at Amazon.Util.Internal.SettingsManager.GetSettings CreateDirectory
2 participants