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

[server/status] implement generic status tracking #7459

Merged
merged 7 commits into from
Jun 15, 2016

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Jun 15, 2016

In #7333 we needed the ability to set the server status from outside of a plugin, but statuses were implemented in a way that coupled them to plugins. This led to reaching in and setting the status of the Kibana plugin. Rather than extending the undesirable coupling of status & plugin I've instead made the server status service support creating more generic status tracker objects, and extended it's API to include plugin-specific methods like createForPlugin(plugin) and getStateForPluginId(pluginId).

With the new API the settings service will be able to create it's own status object with kbnServer.status.create('settings') rather than reaching into the kibana plugin and setting its status.

See ycombinator#1 for an implementation of a more generic status, specifically ycombinator@1556b81

image

In elastic#7333 we needed the ability to set the server status from outside of a plugin, but statuses were implemented in a way that coupled them to plugins. This let to reaching in and setting the status of a plugin from the server. Rather than extending the undesirable coupling of status & plugin I've instead made the server status service support creating more generic status tracker objects, and extended it's API to include plugin-specific methods like `createForPluginId(pluginId)` and `getStateForPluginId(pluginId)`.

With the new API the settings service will be able to create it's own status object with `kbnServer.status.create('settings')` rather than reaching into the kibana plugin and setting its status.
@spalger spalger force-pushed the implement/pluginSpecificStatus branch from 94da008 to cbd7654 Compare June 15, 2016 01:34

module.exports = class ServerStatus {
constructor(server) {
this.server = server;
this._created = {};
}

create(plugin) {
return (this._created[plugin.id] = new Status(plugin, this.server));
create(id) {
Copy link
Contributor

@ycombinator ycombinator Jun 15, 2016

Choose a reason for hiding this comment

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

This PR creates two types of statuses: plugin status and service status. Since we have a method called createForPlugin for attaching a new Plugin status, should we rename the create method to createForService for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't really care for the "service" distinction personally, perhaps I should remove it from the status page logic. Primary reason being that services are only one thing that could use this new generic status, and since there aren't any "service" specific properties to this I don't think it makes sense to be createForService()

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood: there's no need for a separate createForService() method — because there's no need for a separate ServiceStatus class that's not going to have any specific properties (unlike for plugins). Agree with this bit.

I guess what's bugging me is that the class hierarchy doesn't match the distinction on the status page. There it looks like there are two distinct kinds of statuses, one for services and one for plugins. Maybe we just need to name the first block of generic statuses on the status page something other than service status, but I'm drawing a blank at the moment. Also this is veering into bikeshedding territory so I'm happy to just go with "service status" if we can't come up with something else soon :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My original instinct was to just list the ids for each status and let those draw their own distinction, if that's enough for you then it's enough for me!

image

Copy link
Contributor

@ycombinator ycombinator Jun 15, 2016

Choose a reason for hiding this comment

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

I like this! It more consistently mirrors the class hierarchy where everything is a Status, just that if a status has more specific properties like in the case of plugins, there's a subclass for it.

@spalger spalger force-pushed the implement/pluginSpecificStatus branch from ec4cd1d to 8cb1694 Compare June 15, 2016 03:05
ui.name = data.name;

ui.statuses = _.groupBy(data.status.statuses, s => s.plugin ? 'plugins' : 'generic');
Copy link
Contributor

Choose a reason for hiding this comment

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

The check for s.plugin here seems to break abstraction. What do you think of the Status class having an isPluginStatus method that abstracts away this check, to with similar methods like createForPlugin and getForPluginId and then using that method here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would be up for this, but this logic is all front-end, where it's just processing a list of JSON objects

Copy link
Contributor

@ycombinator ycombinator Jun 15, 2016

Choose a reason for hiding this comment

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

I believe this is moot now, based on the discussion in https://github.com/elastic/kibana/pull/7459/files#r67094458

</h4>

<table class="plugin_status_breakdown" ng-if="ui.statuses">
<table class="statuses" data-test-subj="statusBreakdown" ng-if="ui.statuses">
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker for this PR, more for my own curiosity: why did you create the separate data-test-subj attribute? Is it something only our tests look for or does it have another purpose?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ycombinator ycombinator assigned spalger and unassigned ycombinator Jun 15, 2016
@ycombinator
Copy link
Contributor

LGTM!

@spalger spalger merged commit 7af3e7e into elastic:master Jun 15, 2016
@epixa epixa added v5.0.0 and removed v5.0.0 labels Jun 28, 2016
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
…Status

[server/status] implement generic status tracking

Former-commit-id: 7af3e7e
@spalger spalger deleted the implement/pluginSpecificStatus branch October 18, 2019 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants