Skip to content

Comments

[uiSettings] support overriding uiSettings from the config file#21628

Merged
spalger merged 18 commits intoelastic:masterfrom
spalger:implement/ui-setting-overrides
Aug 15, 2018
Merged

[uiSettings] support overriding uiSettings from the config file#21628
spalger merged 18 commits intoelastic:masterfrom
spalger:implement/ui-setting-overrides

Conversation

@spalger
Copy link
Contributor

@spalger spalger commented Aug 3, 2018

This PR implements the uiSettings.overrides setting which [when stored in kibana.yml or passed as config args when starting Kibana] allows forcing some uiSettings to always have a specific value. This setting accepts a map of uiSetting keys to values that will always be used to override whatever is stored in the config saved object.

image

When users view the settings in the advanced settings UI they are disabled and describe why they can't be changed.

image

Attempting to change these values from the uiSettings client/service/api is also prevented, causing a 400 error to be thrown and/or sent as the response.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@spalger spalger force-pushed the implement/ui-setting-overrides branch from 4446556 to 7328d6a Compare August 3, 2018 04:00
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

@LeeDr
Copy link

LeeDr commented Aug 3, 2018

@spalger I must be missing something. We already have 2 ways for tests to set whatever things they want in the .kibana config doc which I think is where all the advanced settings are stored.

  1. Many tests load a .kibana index which already has some settings in the config doc including things like default index pattern.
  2. await kibanaServer.uiSettings.disableToastAutohide();
  3. await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'UTC', 'defaultIndex': 'logstash-*' });

These seems like a pretty large change (25 files) without a great explanation for what problem it solves over and above the other ways we already have to set things.

@LeeDr LeeDr self-requested a review August 3, 2018 13:23
@LeeDr
Copy link

LeeDr commented Aug 3, 2018

Aren't these uiSettings.overrides stored in the config doc? If they are, then each test that replaces the .kibana index would wipe them out anyway. If they're not, please explain.

@spalger
Copy link
Contributor Author

spalger commented Aug 3, 2018

I must be missing something. We already have 2 ways for tests to set whatever things they want in the .kibana config doc which I think is where all the advanced settings are stored.

Yeah all of those options are for mutating the uiSettings stored in elasticsearch, but this change doesn't not try to solve that problem. Instead it makes a uiSetting immutable, and forces the API to use a specific value for that setting. The value is not persisted to Elasticsearch, it is only found in the config file, and if you try to change that value from the API you will get an error because the value is overridden.

This way users of Kibana can choose to enforce certain uiSettings from the config file without having to interact with Kibana to change the setting.

@spalger
Copy link
Contributor Author

spalger commented Aug 3, 2018

Aren't these uiSettings.overrides stored in the config doc? If they are, then each test that replaces the .kibana index would wipe them out anyway. If they're not, please explain.

The overrides are not stored in the config document, they are stored in the kibana.yml file and merged with the values from the config document when it is read within the uiSettings service/API.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

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.

LGTM! My only suggestions were about consistent terminology, either overridden or isControlledByServer.

And I do have an idea about this, though feel free to reject it if you're sick of the whole thing. What do you think of using the term isBakedIn instead? It conveys the idea to me that Kibana's been unalterably configured with certain settings. And we can use it to describe the feature in the release notes: "Administrators can now bake settings into Kibana for their users."

if (setting.isControlledByServer) {
return (
<EuiText size="xs">
This setting is overriden by the Kibana server and can not be changed.
Copy link
Contributor

Choose a reason for hiding this comment

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

How about "An administrator has baked this setting into Kibana's configuration"? I don't think we need to explain that it can't be changed since the UI makes that clear.

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'm really not a huge fan of the "baked" terminology. It implies to me that the values are set by some "baking" process, like if they were baked into the build or something. I think if we wanted to get away from the "controlled" terminology I would prefer something like "forced", but then I feel like we come back around to "overridden"... I think I'm most comfortable with the idea of the UI/API representing these config values as "controlled by the server", and the server seeing them as overrides that it applies to the config values.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, works for me.

Copy link

Choose a reason for hiding this comment

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

Someone reading it might think you're getting "baked" while coding ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

🍪

set: () => {},
remove: () => {},
isCustom: (setting) => setting.isCustom,
isControlledByServer: (key) => key.startsWith('test:overridden'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe references to overridden should be replaced by isControlledByServer here?

checked={!!unsavedValue}
onChange={this.onFieldChange}
disabled={loading}
disabled={loading || setting.isControlledByServer}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe destructure isControlledByServer along with the other setting properties on line 322?

const config = await Config.withDefaultSchema({
uiSettings: { enabled }
uiSettings: {
overrides: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need the overrides "namespace"? If we still need a namespace, maybe "controlledByServer" would be more consistent?

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'd like to leave the option for custom defaults: down the road, and I feel like controlledByServer makes more sense from the UI perspective, but less sense in the server config itself.


assertUpdateAllowed(key) {
if (this.isControlledByServer(key)) {
throw new Error(`Unable to update "${key}" because it is overridden by the Kibana server`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's more consistent to say "because it is controlled by the Kibana server"?

@spalger spalger requested review from bmcconaghy and jen-huang August 7, 2018 20:36
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@spalger
Copy link
Contributor Author

spalger commented Aug 8, 2018

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@bmcconaghy bmcconaghy left a comment

Choose a reason for hiding this comment

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

Code looks good to me, but the naming here still seems off. The variable is "inControlledByServer" but the word overridden is used all over the place. The relationship between the two concepts is murky. Maybe it could be "isLockedByServer" and we could just use locked everywhere. We need to settle on a single term to represent what is happening here.

@bmcconaghy
Copy link
Contributor

I'm OK with overrides as the consistent term. Just want there to be a single term for what this is.

@spalger spalger force-pushed the implement/ui-setting-overrides branch from ba7e2fa to ae7f738 Compare August 14, 2018 20:40
@spalger spalger force-pushed the implement/ui-setting-overrides branch from ae7f738 to ef3c14f Compare August 14, 2018 20:43
@elasticmachine

This comment has been minimized.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@spalger spalger merged commit e49d5f3 into elastic:master Aug 15, 2018
spalger pushed a commit to spalger/kibana that referenced this pull request Aug 15, 2018
…tic#21628)

This PR implements the `uiSettings.overrides` setting which [when stored in kibana.yml or passed as config args when starting Kibana] allows forcing some uiSettings to always have a specific value. This setting accepts a map of uiSetting keys to values that will always be used to override whatever is stored in the config saved object.

![image](https://user-images.githubusercontent.com/1329312/43619094-feded1ae-9680-11e8-9ec3-c12d4d949c46.png)

When users view the settings in the advanced settings UI they are disabled and describe why they can't be changed.

![image](https://user-images.githubusercontent.com/1329312/43618938-2cdee0f4-9680-11e8-9ed6-f384d4ee78f6.png)

Attempting to change these values from the uiSettings client/service/api is also prevented, causing a 400 error to be thrown and/or sent as the response.
spalger pushed a commit that referenced this pull request Aug 15, 2018
…#21628) (#21983)

Backports the following commits to 6.x:
 - [uiSettings] support overriding uiSettings from the config file  (#21628)
@spalger
Copy link
Contributor Author

spalger commented Aug 15, 2018

6.5/6.x: c175c04

@spalger spalger deleted the implement/ui-setting-overrides branch August 15, 2018 23:22
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.

5 participants