Azure / azure-sdk-for-rust

This repository is for active development of the *unofficial* Azure SDK for Rust. This repository is *not* supported by the Azure SDK team.
MIT License
692 stars 237 forks source link

Request to make ImdsManagedIdentityCredential timeout configurable when used in DefaultAzureCredential #1519

Open NicoSaaiman opened 8 months ago

NicoSaaiman commented 8 months ago

The timeout in question is currently limited to 1 second and in addition to that, is also set to private. In my case I've had to resort to a custom handler to circumvent this limitation. (which is way too strict) The convenience of DefaultAzureCredential makes it the go-to for many and anyone hoping to make use of the Managed Identity portion of it will be hamstrung by this limitation. Please consider making this configurable.

            DefaultAzureCredentialEnum::ManagedIdentity(credential) => {
                // IMSD timeout is only limited to 1 second when used in DefaultAzureCredential
                credential
                    .get_token(resource)
                    .timeout(Duration::from_secs(1))
                    .await
                    .context(
                        ErrorKind::Credential,
                        "getting managed identity credential timed out",
                    )?
                    .context(
                        ErrorKind::Credential,
                        "error getting managed identity credential",
                    )
            }
cataggar commented 8 months ago

Thanks for reporting. I agree. The timeout is too short when it needs to be used. But it is too slow to be on by default in my opinion. I opened two other related issues. I hope to contribute something before the new year.