Skip to content

Add MSI eMSI support #5771

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

Merged
merged 9 commits into from
Mar 21, 2018
Merged

Add MSI eMSI support #5771

merged 9 commits into from
Mar 21, 2018

Conversation

markcowl
Copy link
Member

@markcowl markcowl commented Mar 20, 2018

Description

Checklist

Copy link
Contributor

@praries880 praries880 left a comment

Choose a reason for hiding this comment

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

A few minor comments...

@@ -93,22 +108,97 @@ public void AuthorizeRequest(Action<string, string> authTokenSetter)

void GetOrRenewAuthentication()
{
if (_expiration - DateTime.UtcNow < TimeSpan.FromMinutes(5))
if (_expiration - DateTime.UtcNow < TimeSpan.FromMinutes(4))
Copy link
Contributor

Choose a reason for hiding this comment

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

@markcowl A comment here about the significance of the 4 minute to expiration time check would be great...

also what drove the reduction of the one minute here 5 to 4?


public bool IsExpired()
{
return DateTime.UtcNow - CreationDate > (TimeSpan.FromSeconds(ExpiresIn) - TimeSpan.FromMinutes(5));
Copy link
Contributor

@praries880 praries880 Mar 20, 2018

Choose a reason for hiding this comment

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

Is the 5 minutes supposed to be a buffer time? So that we never end up with an expired token in our cache? Also is this related to the check for 4 mins in the code above?

If so, should we look at introducing a constant that is set to 5 and use ("said constant" -1) in the code above?

@@ -26,7 +26,9 @@ namespace Microsoft.Azure.Commands.Common.Authentication.Factories
{
public class AuthenticationFactory : IAuthenticationFactory
{
public const string CommonAdTenant = "Common", DefaultMSILoginUri = "http://localhost:50342/oauth2/token";
public const string CommonAdTenant = "Common",
DefaultMSILoginUri = "http://169.254.169.254/metadata/identity/oauth2/token",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we using this specific IP and is it never going to change or should we use a DNS name?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it is the defined ip of the metadata service on every VM host.

public const string CommonAdTenant = "Common", DefaultMSILoginUri = "http://localhost:50342/oauth2/token";
public const string CommonAdTenant = "Common",
DefaultMSILoginUri = "http://169.254.169.254/metadata/identity/oauth2/token",
DefaultBackupMSILoginUri = "http://localhost:50342/oauth2/token";
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this for testing purposes? How would we get back a valid token from the local host?

Copy link
Member Author

@markcowl markcowl Mar 21, 2018

Choose a reason for hiding this comment

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

No, these are the real endpoints. In the old implementation, there is a loopback endpoint that serves tokens, in the new one, the metadata token service (which has a reserved identical ip on each vm host) is used.

public TimeSpan GetRetryInterval()
{
var result = _currentInterval;
_currentInterval = TimeSpan.FromTicks(_currentInterval.Ticks * _multiplier);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can there be a case where we have multiple threads/processes retrying for the same endpoint at the same time? If so, we should look at adding a small amount of jitter to each retry... jitter helps relieve the case where multiple threads can end up retrying in sync.

@markcowl
Copy link
Member Author

@markcowl markcowl changed the base branch from preview to release-2018-03-23 March 21, 2018 09:42
@cormacpayne
Copy link
Member

@markcowl
Copy link
Member Author

Copy link
Contributor

@praries880 praries880 left a comment

Choose a reason for hiding this comment

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

LGTM!!!
Thanks for taking care of the comments :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants