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

Bug 1862934: Trigger the inactivity logout method when Masthead component is mounted #6189

Merged
merged 1 commit into from Aug 6, 2020

Conversation

jhadvig
Copy link
Member

@jhadvig jhadvig commented Aug 3, 2020

We need to trigger the _inactivityTimeout() when Masthead component is mounted to start the countdown to cover cases when user will just login and wont do any activity.

/assign @spadgett

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. label Aug 3, 2020
@openshift-ci-robot
Copy link
Contributor

@jhadvig: This pull request references Bugzilla bug 1862934, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1862934: Trigger the inactivity logout method when Masthead component is mounted

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Aug 3, 2020
@openshift-ci-robot openshift-ci-robot added component/core Related to console core functionality approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 3, 2020
@@ -93,6 +93,7 @@ class MastheadToolbarContents_ extends React.Component {
if (window.SERVER_FLAGS.inactivityTimeout >= 300) {
window.addEventListener('click', _.throttle(this._onInactivityTimeout, 500));
window.addEventListener('keydown', _.throttle(this._onInactivityTimeout, 500));
this._onInactivityTimeout();
Copy link
Member

Choose a reason for hiding this comment

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

Do you know if the OPENSHIFT flag and user prop is resolved as this point? We could be racing.

Not new, but this method would be better called _resetInactivityTimeout. _onInactivityTimeout sounds like you were inactive for too long.

@jhadvig
Copy link
Member Author

jhadvig commented Aug 3, 2020

Do you know if the OPENSHIFT flag and user prop is resolved as this point? We could be racing.

@spadgett dont think thats the issue here. It's more likely due to a fact that we are event needs to be triggered. ATM we are only adding a listener. If the user just logs in and wont do any interaction (wont trigger the event) the countdown wont start.

@spadgett
Copy link
Member

spadgett commented Aug 3, 2020

@spadgett dont think thats the issue here. It's more likely due to a fact that we are event needs to be triggered. ATM we are only adding a listener. If the user just logs in and wont do any interaction (wont trigger the event) the countdown wont start.

Right, I understand. But I think we're still racing since _onInactivityTimeout won't do anything if the user or the flag haven't resovled yet.

@spadgett
Copy link
Member

spadgett commented Aug 3, 2020

In other words, I'm not sure the fix will always work.

@jhadvig
Copy link
Member Author

jhadvig commented Aug 4, 2020

@spadgett yes, the race was also part of the issue. Updated the PR so only if all conditions are met the timeout is being set.
PTAL

) {
this._updateUser();
}
// Start the inactivity countdown when the flag and user are loaded and the timeout is not set
if (
window.SERVER_FLAGS.inactivityTimeout >= 300 &&
Copy link
Member

Choose a reason for hiding this comment

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

Let's pull this out into a separate var to avoid repeating the logic here and line 93.

const inactivityTimeoutEnabled = window.SERVER_FLAGS.inactivityTimeout >= 300;

window.SERVER_FLAGS.inactivityTimeout >= 300 &&
!this.userInactivityTimeout &&
flags[FLAGS.OPENSHIFT] &&
!_.isEmpty(user)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this check is still necessary since we check auth mode on startup.

if (
window.SERVER_FLAGS.inactivityTimeout >= 300 &&
!this.userInactivityTimeout &&
flags[FLAGS.OPENSHIFT] &&
Copy link
Member

Choose a reason for hiding this comment

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

Are we meaning to disable this when not OpenShift or are we simply checking if the flag is set? If the latter, you should use flagPending. Otherwise, we should move the OpenShift-specific logic below for logout. I don't think we need to restrict this to OpenShift, though.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we would need to block on the flag either. Presumably the flag will resolve well before the inactivity timeout kicks in.

@jhadvig
Copy link
Member Author

jhadvig commented Aug 4, 2020

@spadgett I've put the initial this._resetInactivityTimeout() call back into componentDidMount since we need to call it only once. Also I've realised that we dont need to pro-actively check for the flag of user.
PTAL

@jhadvig
Copy link
Member Author

jhadvig commented Aug 6, 2020

/test e2e-gcp-console

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 6, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhadvig, spadgett

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci-robot
Copy link
Contributor

@jhadvig: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-gcp-console a0344c5 link /test e2e-gcp-console

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit e9d7c71 into openshift:master Aug 6, 2020
@openshift-ci-robot
Copy link
Contributor

@jhadvig: All pull requests linked via external trackers have merged: openshift/console#6189. Bugzilla bug 1862934 has been moved to the MODIFIED state.

In response to this:

Bug 1862934: Trigger the inactivity logout method when Masthead component is mounted

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@spadgett spadgett added this to the v4.6 milestone Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/core Related to console core functionality lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants