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

Add warning for horizon timeout #30

Closed

Conversation

vwallfahrer
Copy link

Horizon timeout is impacted by keystone token timeout since when the
token gets outdated, then the user is automatically unable to use
horizon. This patch includes a check for the timeout of horizon and
keystone barclamps.


# keystone_timeout is in seconds and horizon_timeout is in minutes
if horizon_timeout * 60 > keystone_timeout
validation_error("Horizon timeout is bigger than keystone token expiration and these may cause problems.")

Choose a reason for hiding this comment

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

Style/IndentationWidth: Use 2 (not 4) spaces for indentation.

Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest rephrasing to: "The session timeout cannot be larger than the Keystone token expiration timeout."

@vwallfahrer vwallfahrer changed the title Add warning for horizon timeout [WIP] Add warning for horizon timeout Sep 17, 2015
@vwallfahrer vwallfahrer force-pushed the warning_keystone_timeout branch 2 times, most recently from 0066165 to 678e19f Compare September 17, 2015 12:38
@vwallfahrer vwallfahrer changed the title [WIP] Add warning for horizon timeout Add warning for horizon timeout Sep 17, 2015
@rsalevsky
Copy link
Member

Hrm... code looks good so far but it's the same code twice. Maybe but it in an validation helper method and just call the method.

@AbelNavarro
Copy link
Contributor

@rsalevsky you are right there is some code repeated (3 lines). Since the code is repeated in two different files and it's very specific for the validation, I'd say it would make it harder to read if you need to go to a third file for just this three lines. Would the code had been in the same file or had been more critical, I would totally go for a non-repetition approach.

@AbelNavarro
Copy link
Contributor

@vuntz 's comment seems to have disappeared after the pull request update. This is his original comment:

I'd suggest rephrasing to: "The session timeout cannot be larger than the Keystone token expiration timeout."

Btw, I agree with the rephrasing. Although I'd explicitly mention this is horizon's session timeout:
"The horizon session timeout cannot be larger than the Keystone token expiration timeout."

@AbelNavarro
Copy link
Contributor

Just thought of another corner case to try: what happens if we have keystone barclamp installed but not the horizon one? Probably there should be a check when retrieving the proposal to see it's not empty.

@AbelNavarro
Copy link
Contributor

I checked our default values for the expirations in cloud5:

  • horizon: 24 hours (1440 minutes)
  • keystone: 4 hours (14400 seconds)

So, the situation that triggers this problem is there by default. There won't be any warning in crowbar because it will only show upon a change. We will need to change the default values.

If we change the default values, should we also change any documentation for the end user?

@AbelNavarro
Copy link
Contributor

I still haven't fully backported this to cloud5 and probably cannot finish this soon. FTR, this is what the code would look like for cloud5:

    horizon_timeout = proposal["attributes"]["nova_dashboard"]["session_timeout"]
    keystone_proposal = ProposalObject.find_proposal("keystone", "default")
    unless keystone_proposal.nil?
      keystone_timeout = keystone_proposal["attributes"]["keystone"]["token_expiration"]

      # keystone_timeout is in seconds and horizon_timeout is in minutes
      if horizon_timeout * 60 > keystone_timeout
        validation_error("The horizon session timeout cannot be larger than the Keystone token expiration timeout.")
      end
    end

@vuntz
Copy link
Member

vuntz commented Sep 18, 2015

If we change the default values, should we also change any documentation for the end user?

I don't think we document that, so go ahead.

@AbelNavarro
Copy link
Contributor

Regarding the default timeouts, what about making both (horizon + keystone) to be 4 hours?

@vuntz
Copy link
Member

vuntz commented Sep 23, 2015

Regarding the default timeouts, what about making both (horizon + keystone) to be 4 hours?

We need to make the settings consistent, at least. I'd possibly go for 24 hours, but no strong opinion.

@@ -83,6 +83,15 @@ def validate_proposal_after_save proposal
validation_error("API version 3 or newer is required when enabling domain specific drivers.")
end

keystone_timeout = proposal["attributes"]["keystone"]["token_expiration"]
horizon_proposal = Proposal.where(barclamp: "nova_dashboard", name: "default").first
horizon_timeout = horizon_proposal["attributes"]["nova_dashboard"]["session_timeout"]
Copy link
Member

Choose a reason for hiding this comment

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

In this case, there's no guarantee that we have a horizon proposal, so we should check if horizon_proposal is nil.

@vuntz
Copy link
Member

vuntz commented Sep 23, 2015

Also needs a rebase

Horizon timeout is impacted by keystone token timeout since when the
token gets outdated, then the user is automatically unable to use
horizon. This patch includes a check for the timeout of horizon and
keystone barclamps.
# keystone_timeout is in seconds and horizon_timeout is in minutes
if horizon_timeout * 60 > keystone_timeout
validation_error("Setting the Horizon timeout (#{horizon_timeout * 60} minutes) longer than the Keystone token expiration timeout" \
"(#{keystone_timeout} minutes) is not supported. Please lower the Horizon token timeout.")

Choose a reason for hiding this comment

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

unexpected token tSTRING_BEG
unexpected token tRPAREN


timeout_warning = <<-EOF
Setting the Horizon timeout (#{horizon_timeout} minutes) longer than the Keystone token expiration timeout (#{keystone_timeout * 60} minutes) is not supported.
Please lower the Horizon token timeout.
Copy link
Member

Choose a reason for hiding this comment

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

Here I would change the error and say "Please increase the Keystone token expiration timeout." (since the user is editing the keystone proposal)

keystone_timeout = keystone_proposal["attributes"]["keystone"]["token_expiration"]

timeout_warning = <<-EOF
Setting the Horizon timeout (#{horizon_timeout} minutes) longer than the Keystone token expiration timeout (#{keystone_timeout * 60} minutes) is not supported.

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [159/150]

@tboerger
Copy link
Contributor

I would prefer the messages to be part of the i18n file as they are getting touched anyway.

@AbelNavarro
Copy link
Contributor

since @vwallfahrer is sick, I'm continuing the PR in this new one: #51

@tboerger
Copy link
Contributor

tboerger commented Oct 1, 2015

Continued in #51

@tboerger tboerger closed this Oct 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants