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

Global time range in URL overwritten in certain situations. #21326

Closed
walterra opened this issue Jul 27, 2018 · 6 comments · Fixed by #21440
Closed

Global time range in URL overwritten in certain situations. #21326

walterra opened this issue Jul 27, 2018 · 6 comments · Fixed by #21440
Assignees
Labels
blocker bug Fixes for quality problems that affect the customer experience PR sent Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v6.4.0

Comments

@walterra
Copy link
Contributor

walterra commented Jul 27, 2018

Found in version

  • master onwards since 38dcda0e6bc7719aab94be3d28a0e56c6acef623

Browser

  • macos/Chrome

Steps to reproduce

  • Move to Discover, set the date picker to something like "last 15 minutes"
  • Move to the ML jobs list page, click on one of the jobs list result icons to switch to anomaly explorer

Expected result

  • Anomaly Explorer should automatically pick the time range of the job

Actual result

  • The time range is the one selected in Discover ("last 15 minutes")

image

Additional information

  • It seems this was introduced by this PR: Fix refreshed dashboard losing time range #20858
  • If you copy the link from the results icon and load it separately in a new window, the timerange gets picked up correctly. So this seems to be an issue with routing and global state in the single page app when moving between pages without completely reloading.
@walterra walterra added bug Fixes for quality problems that affect the customer experience :ml labels Jul 27, 2018
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui

@stacey-gammon
Copy link
Contributor

Sorry for causing this with my PR. I thought that the fix would bring the logic back to where it was prior to June 26th, when angular was removed from the time picker.

Sounds like ML jobs and dashboards stored with time work similarly - when you open them, they should adjust the time, both in the UI and in the URL. That broke for dashboards when angular was removed from the time picker (the URL and the UI got out of sync). My change to fix that was to sync the URL with the UI state. The problem was that it wasn't being initialized on page load.

I'm technically off today but can help more on Monday, and spend some time investigating (or if I find time later today).

@stacey-gammon
Copy link
Contributor

stacey-gammon commented Jul 30, 2018

Assuming we start out with timefilter set to Time A. Opening a job URL set to Time B goes through this flow:

  1. State.$routeChangeStart
  2. this.emit('fetch_with_changes', diffResults.keys); because URL Time changed to Time B.
  3. kbnGlobalTimePicker is initialized
  4. updateGlobalStateWithTime sets globalState to that stored in timefilter (Time A).
  5. globalState.on('fetch_with_changes', function () { syncs timefilter to globalState, but that is now Time A, not Time B.

Why does this work for dashboards?

Assuming we start out with timefilter set to Time A and we open a dashboard with time stored as Time B. Dashboards soft refresh goes like this:

  1. this.emit('fetch_with_changes', diffResults.keys); with Time B (same as above).
    2. dashboardStateManager.syncTimefilterWithDashboard(_timefilter.timefilter, config.get('timepicker:quickRanges')); updates timefilter to what is stored in the dashboard
  2. kbnGlobalTimePicker is initialized

Step 2 stops this bug from appearing because dashboard manually syncs the timefilter to the saved time.

What about when we edit the URL directly, how come the bug doesn't appear then?

In that case kbnGlobalTimePicker is not initialized so we don't hit the bug.

I can actually reproduce this bug now excluding ML completely:

  1. Open up a dashboard and set time to Time A
  2. Copy the url, paste into an editor, change the global time to Time B.
  3. Go to dashboard listing page.
  4. Paste the URL into the browser

You'll get a soft refresh that causes the kbnGlobalTimePicker to be re-initialized and the url will end up re-syncing with Time A and losing Time B.

@stacey-gammon stacey-gammon changed the title [ML] Switch from jobs list to anomaly explorer/tsw doesn't update time range Global time range in URL overwritten in certain situations. Jul 30, 2018
@stacey-gammon stacey-gammon added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc :Sharing and removed :ml Feature:ml-results legacy - do not use labels Jul 30, 2018
@stacey-gammon
Copy link
Contributor

Not sure of a fix yet, but I think this is not related to ML so I edited the title and labels. It's really a platform/discover team thing, but the de-angularization of time picker was taken on by the Sharing team, as was the fix that caused this additional blocker, so I supposed it's up to us to find a short term solution for 6.4.

Long term, I think this is yet another example of how the tech debt in this area is causing us lost productivity.

@nreese
Copy link
Contributor

nreese commented Jul 31, 2018

@walterra Can you give this change a try - #21440. It should fix the problems you were seeing

@walterra
Copy link
Contributor Author

@nreese can confirm that this fixes the issue for me, great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker bug Fixes for quality problems that affect the customer experience PR sent Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v6.4.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants