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

feat: added a global timeout to the login command #1027

Merged
merged 2 commits into from
Sep 6, 2021

Conversation

alexal
Copy link
Contributor

@alexal alexal commented Sep 3, 2021

Closes #989

@@ -53,6 +52,7 @@ func (a *AuthorizationCodeGrant) Execute(ctx context.Context, ssoCfg *SSOConfig,
if err := a.loginMAS(ctx, masSSOCfg); err != nil {
return err
}
a.Logger.Info(a.Localizer.MustLocalize("login.log.info.loggedIn"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wtrocki , @craicoverflow

I've moved this here because we may end up in a situation like this

Logging in...

Logged in successfully
Logging in to identity.api.openshift.com...
Error: login operation took too long. Please try again. Run the command in verbose mode using the -v flag to see more information

After I did that, everything looks much better

Logging in...

Logging in to identity.api.openshift.com...
Error: login operation took too long. Please try again. Run the command in verbose mode using the -v flag to see more information

Copy link
Contributor

Choose a reason for hiding this comment

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

a.Logger.Info(a.Localizer.MustLocalize("login.log.info.loggingInMAS", localize.NewEntry("Host", masSSOHost)))

Could you make this into a debug message instead? The user does not need to see two login statuses whyen it should happen automatically. The new ordering might be a bit confusing but that's just an effect of repeated login messages

@alexal
Copy link
Contributor Author

alexal commented Sep 3, 2021

Also, it seems like global timeout is enough and createClientContext don't need to be changed.

ctx, cancel := context.WithTimeout(context.Background(), build.DefaultLoginTimeout)
defer cancel()

if err = loginExec.Execute(ctx, ssoCfg, masSsoCfg); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if err = loginExec.Execute(ctx, ssoCfg, masSsoCfg); err != nil {
if err = loginExec.Execute(ctx, ssoCfg, masSsoCfg); err != nil && errors.Is(err, context.DeadlineExceeded) {

This could work, to save a nested if statement.

Copy link
Contributor

@craicoverflow craicoverflow left a comment

Choose a reason for hiding this comment

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

Awesome work!

@@ -53,6 +52,7 @@ func (a *AuthorizationCodeGrant) Execute(ctx context.Context, ssoCfg *SSOConfig,
if err := a.loginMAS(ctx, masSSOCfg); err != nil {
return err
}
a.Logger.Info(a.Localizer.MustLocalize("login.log.info.loggedIn"))
a.Logger.Info(a.Localizer.MustLocalize("login.log.info.loggedInMAS", localize.NewEntry("Host", masSSOHost)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
a.Logger.Info(a.Localizer.MustLocalize("login.log.info.loggedInMAS", localize.NewEntry("Host", masSSOHost)))
a.Logger.Debug(a.Localizer.MustLocalize("login.log.info.loggedInMAS", localize.NewEntry("Host", masSSOHost)))

While you are here, would you mind making this a debug message? I think the new ordering might be a little confusing, and the user does not really need to see two log in messages, now that I think about it :)

@craicoverflow craicoverflow merged commit 7748630 into redhat-developer:main Sep 6, 2021
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.

Add a timeout when logging in via the web browser
2 participants