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

[Watcher] More robust handling of license at setup #55831

Merged

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Jan 24, 2020

Summary

Fix after #54752 was merged. Watcher, at setup time, subscribes to a licensing.license$ stream and only registers after it has received the first message from that stream. The problem is the setup function is running synchronously and this was causing some flakiness in ordering. One issue I saw was (when navigating to Watcher):

Screenshot 2020-01-24 at 12 25 11

This would redirect to home page as if the app has been disabled (even though it was not).

Additionally there was some jankiness with when the app link would be shown.

Changes

  • In plugin.ts we now have an async setup method which will await the first license from licensing.license$. Only after it has a valid license will it process app registration. setup should remain synchronous [RFC][skip-ci] Prevent plugins from blocking Kibana startup #45796 (comment). We now do all registration synchronously and then respond to license$ updates.
  • In app.tsx we receive an initial license value and an observable so that we can react to license updates and handle license changes in a more graceful way.

How to test

  1. Navigate to watcher (w/ min. license)
  2. Run curl -XDELETE -v http://elastic:changeme@localhost:9200/_license && curl -XPOST -v http://elastic:changeme@localhost:9200/_license/start_basic\?acknowledge\=true
  3. Wait roughly 1 minute and the watcher UI should update with a spinner (it's trying to refresh but can't), then the license update should change the UI to callout explaining the issue.
  4. Refresh and watcher should not be in ES section

If you don't have the required min. license in place for watcher, the link should not be there in the ES management section.

Additional Notes

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

…e first

Enable app to react to license updates from backend
@jloleysens jloleysens added Feature:Watcher v8.0.0 Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes v7.7.0 labels Jan 24, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Tested locally, code LGTM! Just had a few small suggestions. Thanks for the extremely detailed PR description.

});
},
});
if (!initialLicenseStatus.valid) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of adding some comments to describe the intended UX? For example, a comment here along the lines of:

// When we first load Kibana, exclude Watcher from Kibana entirely
// if the license doesn't support it.

And then a corresponding comment on https://github.com/elastic/kibana/blob/master/x-pack/plugins/watcher/public/application/app.tsx#L57 would be something like:

// If the license changes while the user is in Watcher, we need to explain
// what's happened.

x-pack/plugins/watcher/public/plugin.ts Show resolved Hide resolved
MANAGEMENT_BREADCRUMB: any;
}

export const App = (deps: AppDeps) => {
const { valid, message } = deps.getLicenseStatus();
const [{ valid, message }, setLicenseStatus] = useState(deps.initialLicenseStatus);
Copy link
Contributor

@cjcenizal cjcenizal Jan 24, 2020

Choose a reason for hiding this comment

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

It took me a minute to figure out what role initialLicenseStatus plays here and it seems like it doesn't have one, since plugin.ts won't render this component if initialLicenseStatus.valid is false. If that's the case, maybe it will be clearer to remove initialLicenseStatus from the props and instead use a hardcoded default:

const [{ valid, message }, setLicenseStatus] = useState({ valid: true });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point! Will update!

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@jloleysens jloleysens merged commit 35edfb0 into elastic:master Jan 27, 2020
@jloleysens jloleysens deleted the fix/watcher/more-robust-app-startup branch January 27, 2020 12:35
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jan 27, 2020
* Only register watcher app if we have received an indication of license first
Enable app to react to license updates from backend

* Return setup to a synchronous function.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
jloleysens added a commit that referenced this pull request Jan 30, 2020
* Only register watcher app if we have received an indication of license first
Enable app to react to license updates from backend

* Return setup to a synchronous function.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Watcher release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants