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

[ML] Fixes Anomaly Explorer Swimlane race condition, adds tests. #22814

Merged
merged 15 commits into from
Sep 11, 2018

Conversation

walterra
Copy link
Contributor

@walterra walterra commented Sep 7, 2018

Fixes #18344.

This PR addresses parts of #22642.

  • It gets rid of the use of var that = this;.
  • dragSelect's action strings are moved to a constants file.
  • Adds jest tests for the ExplorerSwimlane component.

Note for reviewers: The diff for explorer_swimlane.js is rather big - it's because I moved at lot of methods which were defined in componentDidMount() like this.fnName = ... to be methods on the class itself like fnName() { ... }, the methods themselves didn't change though.

This also fixes the following bugs:

  • The way we subscribe listeners to the events of the dragSelect library could result in the same event being triggered multiple times. This in turn could cause race conditions when on each event new data gets fetched but in between angular's scope gets updated and could end up in a non-intended way. The result of this were view-by swimlanes not updating correctly or anomaly charts showing non-related charts. This PR fixes it by filtering out consecutive swimlane click events.
  • When the angular based chart container wrapper directive gets destroyed/re-esetup when using the job pick, it missed unmounting the react component, it didn't trigger componentWillUnmount()and didn't unsubscribe from dragSelectListener.

@walterra walterra self-assigned this Sep 7, 2018
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -55,6 +56,15 @@ uiRoutes
import { uiModules } from 'ui/modules';
const module = uiModules.get('apps/ml');

function getDefaultViewBySwimlaneData() {
return {
'fieldName': '',
Copy link
Member

Choose a reason for hiding this comment

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

nit, keys shouldn't be quoted

cellData.laneLabels : $scope.getSelectedJobIds();
const influencers = getSelectionInfluencers(cellData);

const listenerData = { jobIds, influencers, start: timerange.earliestMs, end: timerange.latestMs, cellData };
Copy link
Member

Choose a reason for hiding this comment

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

nit, this could be broken over a few lines to make it more readable

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

LGTM

@elasticmachine
Copy link
Contributor

💔 Build Failed

@walterra
Copy link
Contributor Author

walterra commented Sep 7, 2018

retest

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@walterra walterra force-pushed the ml-explorer-swimlane-react-2 branch from 1963c4e to 5d2addb Compare September 8, 2018 09:21
@elasticmachine
Copy link
Contributor

💔 Build Failed

@walterra walterra force-pushed the ml-explorer-swimlane-react-2 branch from 5d2addb to 7ae6643 Compare September 9, 2018 08:41
@elasticmachine
Copy link
Contributor

💔 Build Failed

@walterra
Copy link
Contributor Author

retest

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

function loadDataForCharts(jobIds, influencers, earliestMs, latestMs) {
const requestTime = new Date().getTime();
Copy link
Member

@jgowdyelastic jgowdyelastic Sep 10, 2018

Choose a reason for hiding this comment

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

i think lastRequestTime could just be a counter that is incremented on each call

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Tested your latest changes and all selection events in the swimlane are behaving correctly for me (tested on Chrome and Edge).

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

}

const newRequestCount = requestCount + 1;
requestCount = newRequestCount;
Copy link
Member

@jgowdyelastic jgowdyelastic Sep 11, 2018

Choose a reason for hiding this comment

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

nit, these two lines could be
const newRequestCount = ++requestCount;

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@walterra walterra merged commit 7de9f69 into elastic:master Sep 11, 2018
@walterra walterra deleted the ml-explorer-swimlane-react-2 branch September 11, 2018 10:39
walterra added a commit to walterra/kibana that referenced this pull request Sep 11, 2018
…stic#22814)

This PR addresses parts of elastic#22642:
- It gets rid of the use of var that = this;.
- dragSelect's action strings are moved to a constants file.
- Adds jest tests for the ExplorerSwimlane component.

This also fixes the following bugs:
- The way we subscribe listeners to the events of the dragSelect library could result in the same event being triggered multiple times. This in turn could cause race conditions when on each event new data gets fetched but in between angular's scope gets updated and could end up in a non-intended way. The result of this were view-by swimlanes not updating correctly or anomaly charts showing non-related charts. This PR fixes it by filtering out consecutive swimlane click events.
- When the angular based chart container wrapper directive gets destroyed/re-esetup when using the job pick, it missed unmounting the react component, it didn't trigger componentWillUnmount()and didn't unsubscribe from dragSelectListener.
walterra added a commit that referenced this pull request Sep 11, 2018
) (#22923)

This PR addresses parts of #22642:
- It gets rid of the use of var that = this;.
- dragSelect's action strings are moved to a constants file.
- Adds jest tests for the ExplorerSwimlane component.

This also fixes the following bugs:
- The way we subscribe listeners to the events of the dragSelect library could result in the same event being triggered multiple times. This in turn could cause race conditions when on each event new data gets fetched but in between angular's scope gets updated and could end up in a non-intended way. The result of this were view-by swimlanes not updating correctly or anomaly charts showing non-related charts. This PR fixes it by filtering out consecutive swimlane click events.
- When the angular based chart container wrapper directive gets destroyed/re-esetup when using the job pick, it missed unmounting the react component, it didn't trigger componentWillUnmount()and didn't unsubscribe from dragSelectListener.
walterra added a commit that referenced this pull request Sep 13, 2018
- This fixes a regression introduced in #22814. The influencer list wouldn't update if no cell in the swimlanes was selected.
- Renames getTopInfluencers to loadTopInfluencers to be in line with the other functions loadDataForCharts and loadAnomaliesTableData
- Changes the order of arguments for loadDataForCharts so they are the same like in loadTopInfluencers.
walterra added a commit to walterra/kibana that referenced this pull request Sep 13, 2018
- This fixes a regression introduced in elastic#22814. The influencer list wouldn't update if no cell in the swimlanes was selected.
- Renames getTopInfluencers to loadTopInfluencers to be in line with the other functions loadDataForCharts and loadAnomaliesTableData
- Changes the order of arguments for loadDataForCharts so they are the same like in loadTopInfluencers.
walterra added a commit that referenced this pull request Sep 13, 2018
…2989)

- This fixes a regression introduced in #22814. The influencer list wouldn't update if no cell in the swimlanes was selected.
- Renames getTopInfluencers to loadTopInfluencers to be in line with the other functions loadDataForCharts and loadAnomaliesTableData
- Changes the order of arguments for loadDataForCharts so they are the same like in loadTopInfluencers.
walterra added a commit that referenced this pull request Sep 13, 2018
- Fixes a regression introduced in #22814. Because of the stricter checking for scope/props updates, resizing the browser window would miss updating the Anomaly Explorer Charts widths. This fixes it by adding a check to trigger anomalyDataChange in redrawOnResize().
- Additionally, if only one chart is up for display, this update makes sure a single chart always spans across the full available width.
walterra added a commit to walterra/kibana that referenced this pull request Sep 13, 2018
- Fixes a regression introduced in elastic#22814. Because of the stricter checking for scope/props updates, resizing the browser window would miss updating the Anomaly Explorer Charts widths. This fixes it by adding a check to trigger anomalyDataChange in redrawOnResize().
- Additionally, if only one chart is up for display, this update makes sure a single chart always spans across the full available width.
walterra added a commit that referenced this pull request Sep 13, 2018
- Fixes a regression introduced in #22814. Because of the stricter checking for scope/props updates, resizing the browser window would miss updating the Anomaly Explorer Charts widths. This fixes it by adding a check to trigger anomalyDataChange in redrawOnResize().
- Additionally, if only one chart is up for display, this update makes sure a single chart always spans across the full available width.
@lcawl lcawl added the bug Fixes for quality problems that affect the customer experience label Oct 29, 2018
@sophiec20 sophiec20 added the Feature:Anomaly Detection ML anomaly detection label Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Anomaly Detection ML anomaly detection Feature:ml-results legacy - do not use :ml v6.5.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML] Anomaly Explorer - empty charts after double-click in overall swimlane
6 participants