Skip to content

Comments

[ML] Management: fix license unsubscribe#59365

Merged
alvarezmelissa87 merged 2 commits intoelastic:masterfrom
alvarezmelissa87:ml-fix-licensing-issue
Mar 5, 2020
Merged

[ML] Management: fix license unsubscribe#59365
alvarezmelissa87 merged 2 commits intoelastic:masterfrom
alvarezmelissa87:ml-fix-licensing-issue

Conversation

@alvarezmelissa87
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 commented Mar 4, 2020

Summary

Fixes error #59229 (comment)

Uses take to limit subscription to first value. Doesn't require call to unsubscribe.
Removes 'skip' from test previously thought to be flaky

@alvarezmelissa87 alvarezmelissa87 requested a review from a team as a code owner March 4, 2020 20:09
@alvarezmelissa87 alvarezmelissa87 self-assigned this Mar 4, 2020
@alvarezmelissa87 alvarezmelissa87 added :ml release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0 labels Mar 4, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Copy link
Member

Choose a reason for hiding this comment

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

Is it a valid expectation for the licensingSubscription observable to end up being undefined? If it's undefined because of some other error higher up, we log the error where it's happening. It feels like this is a side-effect of something else, but we don't know what.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From looking at observable docs - looks like unsubscribing within a subscribe callback in an observable is not the recommended way of doing it. I'd imagine that it is possible since the subscription wouldn't have returned yet when this is first hit - so it could be undefined.

I've confirmed that this works so it should unblock us. I'm working on a more rxjs-ey solution but didn't want to keep everyone waiting while I tested.

Copy link
Member

Choose a reason for hiding this comment

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

it's also worth noting that this is legacy code that will be rewritten soon for NP.
License checks where added here to enable ML's management plugin for the time being.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the confirmation that there will be future work done to improve this part of the code. I'm OK with the changes as they are to get folks unblocked.

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

@alvarezmelissa87 alvarezmelissa87 requested review from joelgriffith and wylieconlon and removed request for wylieconlon March 4, 2020 20:51
@alvarezmelissa87 alvarezmelissa87 force-pushed the ml-fix-licensing-issue branch from 91e4167 to 30696a2 Compare March 4, 2020 22:03
@alvarezmelissa87
Copy link
Contributor Author

Updated this as it needed an unrelated fix in master - I've updated to use take in the observable to remove the need to unsubscribe. Would you be up for taking another look when you get a chance? cc @tsullivan, @wylieconlon

const plugins = npSetup.plugins as PluginsSetupExtended;
const licencingSubscription = plugins.licensing.license$.subscribe(license => {
// only need to register once
const licensing = plugins.licensing.license$.pipe(take(1));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, LGTM

Copy link
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

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

Assuming tests pass, this LGTM

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

  • 💔 Build #30875 failed 91e41671f6f17d2eed9f666de6e78273ea281260

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@alvarezmelissa87 alvarezmelissa87 merged commit 44921e6 into elastic:master Mar 5, 2020
@alvarezmelissa87 alvarezmelissa87 deleted the ml-fix-licensing-issue branch March 5, 2020 00:04
alvarezmelissa87 added a commit to alvarezmelissa87/kibana that referenced this pull request Mar 5, 2020
* check for undefined before unsubscribe.remove skip from test

* use take for observable
jgowdyelastic added a commit that referenced this pull request Mar 5, 2020
* check for undefined before unsubscribe.remove skip from test

* use take for observable
jloleysens added a commit to jloleysens/kibana that referenced this pull request Mar 5, 2020
…re/files-and-filetree

* 'master' of github.com:elastic/kibana: (254 commits)
  Convert discover_page to ts, remove redundunt methods (elastic#59312)
  [Fix for Vis Editor] Revert setting time field to empty string when it's undefined (elastic#58873)
  Delete legacy search endpoint (elastic#59341)
  [Uptime] Improve duration chart (elastic#58404)
  [Snapshot & Restore] NP migration (elastic#59109)
  [ML] Add support for date_nanos time field in anomaly job wizard (elastic#59017)
  Revert "Makes alerting and actions optional properties for interface RequestH… (elastic#59264)"
  Change remote_clusters ID to remoteClusters (elastic#59246)
  Makes alerting and actions optional properties for interface RequestH… (elastic#59264)
  Clean up date histogram agg type. (elastic#58805)
  [ML] Management: fix license unsubscribe (elastic#59365)
  Remove documentation for server.cors settings (elastic#59096)
  Edit alert flyout (elastic#58964)
  [SIEM] Fix rule delete/duplicate actions (elastic#59306)
  move mouse to close obstructing tooltip (elastic#59214)
  Reset page after deleting (elastic#59310)
  Make sure phrases input filter triggers autosuggestons (elastic#59299)
  Add loading count source for http requests (elastic#59245)
  Revert "[ML] Transforms: Deprecate custom KibanaContext. (elastic#59133)"
  Expose metrics service to public API (elastic#59294)
  ...

# Conflicts:
#	src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:ml release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants