You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow retries in DefaultKeyResolver.CanCreateAuthenticatedEncryptor (#54711)
* Allow retries in DefaultKeyResolver.CanCreateAuthenticatedEncryptor
This code is trying to ensure that the selected key can be decrypted (i.e. is usable). It may fail if, for example, Azure KeyVault is unreachable due to connectivity issues. If it fails, there's a log message and then an immediately-activated key will be generated. An immediately-activated key can cause problems for sessions making requests to multiple app instances and those problems won't obviously be connected to the (almost silent) failure in CanCreateAuthenticatedEncryptor. Rather than effectively swallowing such errors, we should allow some retries.
Part of #36157
* Roll our own Lazy that allows resets
Retries against the actual `Key` type weren't working because the exception was getting cached in the key's lazy descriptor. Implement our own simple lazy and expose a method for clearing the cached value and exception.
[LoggerMessage(12,LogLevel.Warning,"Key {KeyId:B} is ineligible to be the default key because its {MethodName} method failed.",EventName="KeyIsIneligibleToBeTheDefaultKeyBecauseItsMethodFailed")]
76
+
[LoggerMessage(12,LogLevel.Warning,"Key {KeyId:B} is ineligible to be the default key because its {MethodName} method failed after the maximum number of retries.",EventName="KeyIsIneligibleToBeTheDefaultKeyBecauseItsMethodFailed")]
[LoggerMessage(13,LogLevel.Debug,"Considering key {KeyId:B} with expiration date {ExpirationDate:u} as default key.",EventName="ConsideringKeyWithExpirationDateAsDefaultKey")]
0 commit comments