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

[Mappings Editor] Disable _source field in serverless #181712

Conversation

ElenaStoeva
Copy link
Contributor

@ElenaStoeva ElenaStoeva commented Apr 25, 2024

Closes #181555

Summary

This PR disables the _source field in the Mappings editor's advanced options when in serverless or when the _source.mode property is set.

How to test:

  1. Start a serverless project.
  2. Go to Index Management and start creating an index template or a component template.
  3. In the Mappings step, go to the "Advanced options" tab.
  4. Verify that the _source field is not displayed and that creating a template doesn't add this property to the Es request.
  5. Verify that, in stateful Kibana, the _source field still exists and works as expected.
  6. In both stateful and serverless, verify that when you create an index template with the _source.mode property set (example Es request below), the whole _source field section is hidden.
PUT _index_template/my_template
{
  "index_patterns": ["foo*"],
  "template": {
    "mappings": {
      "_source": {
        "mode": "synthetic"
      },
      "properties": {
        "host_name": {
          "type": "keyword"
        },
        "created_at": {
          "type": "date",
          "format": "EEE MMM dd HH:mm:ss Z yyyy"
        }
      }
    }
  }
}

@ElenaStoeva ElenaStoeva added release_note:skip Skip the PR/issue when compiling release notes Feature:Mappings Editor Index mappings editor UI labels Apr 25, 2024
@ElenaStoeva ElenaStoeva self-assigned this Apr 25, 2024
@ElenaStoeva
Copy link
Contributor Author

/ci

1 similar comment
@ElenaStoeva
Copy link
Contributor Author

/ci

@ElenaStoeva ElenaStoeva force-pushed the im/serverless/disable-mappings-source-field branch from 76ec03e to e019e0a Compare April 26, 2024 11:55
@ElenaStoeva ElenaStoeva marked this pull request as ready for review April 26, 2024 12:01
@ElenaStoeva ElenaStoeva requested review from a team as code owners April 26, 2024 12:01
@@ -52,6 +52,11 @@ const schemaLatest = schema.object(
// We take this approach in order to have a central place (serverless.yml) for serverless config across Kibana
serverless: schema.boolean({ defaultValue: true }),
}),
enableMappingsSourceField: offeringBasedSchema({
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 was thinking about renaming the config to enableMappingsSourceFieldConfiguration but this might be too long. I'm open to any suggestions for the name of the config.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about enableMappingsSourceFieldConfig or enableMappingsSourceFieldSection? A little shorter, but not much 😅 . I'm also OK to leave it how you have it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions! I like enableMappingsSourceFieldSection since the component for the _source field configuration is called SourceFieldSection. Added this change with 813297e.

@ElenaStoeva ElenaStoeva force-pushed the im/serverless/disable-mappings-source-field branch from b178de6 to 04dacec Compare April 26, 2024 12:23
@ElenaStoeva ElenaStoeva requested a review from a team as a code owner April 26, 2024 12:23
Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

Core changes LGTM, did not test locally

@ElenaStoeva ElenaStoeva added the Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more label Apr 26, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

jeramysoucy
jeramysoucy previously approved these changes Apr 26, 2024
@jeramysoucy jeramysoucy dismissed their stale review April 26, 2024 14:54

Wanted to request a change

Copy link
Contributor

@jeramysoucy jeramysoucy left a comment

Choose a reason for hiding this comment

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

Kibana security changes LGTM, just one nit request.

@@ -276,6 +276,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
'xpack.index_management.enableIndexStats (any)',
'xpack.index_management.editableIndexSettings (any)',
'xpack.index_management.enableDataStreamsStorageColumn (any)',
'xpack.index_management.enableMappingsSourceField (any)',
Copy link
Contributor

@jeramysoucy jeramysoucy Apr 26, 2024

Choose a reason for hiding this comment

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

Nit: could we just move this down below the comment with the other conditional flags, or comment as 'any' due to offering based schema?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I moved it below the comment as well as the rest of the index management offering-based configs for consistency.

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! Tested on serverless ES and stateful and _source configuration was hidden/shown as expected.

One thing I noticed -

"Synthetic" mode is still supported via the API, but we haven't build the UI yet (follow up: #181609). If I create a template via the API with this configuration, the mappings editor doesn't handle it gracefully. Can you look into how difficult it would be to pass through the value?

Example request:

PUT _index_template/my_template
{
  "index_patterns": ["foo*"],
  "template": {
    "mappings": {
      "_source": {
        "mode": "synthetic"
      },
      "properties": {
        "host_name": {
          "type": "keyword"
        },
        "created_at": {
          "type": "date",
          "format": "EEE MMM dd HH:mm:ss Z yyyy"
        }
      }
    }
  }
}

Result in the UI:

Screenshot 2024-04-26 at 2 18 35 PM

@@ -52,6 +52,11 @@ const schemaLatest = schema.object(
// We take this approach in order to have a central place (serverless.yml) for serverless config across Kibana
serverless: schema.boolean({ defaultValue: true }),
}),
enableMappingsSourceField: offeringBasedSchema({
Copy link
Contributor

Choose a reason for hiding this comment

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

What about enableMappingsSourceFieldConfig or enableMappingsSourceFieldSection? A little shorter, but not much 😅 . I'm also OK to leave it how you have it.

@ElenaStoeva
Copy link
Contributor Author

Thanks for the review @alisonelizabeth!

"Synthetic" mode is still supported via the API, but we haven't build the UI yet (follow up: #181609). If I create a template via the API with this configuration, the mappings editor doesn't handle it gracefully. Can you look into how difficult it would be to pass through the value?

That's a good call, thanks for bringing it up! I added the mode setting for the _source field to the mappings configuration schema so the UI shouldn't display the warning now. Let me know if you see any other issues.

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

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

Thanks @ElenaStoeva!

I noticed one more thing, but it may be related to an existing issue: #106006. If I create a template via the API with the synthetic mode, then click on the "Advanced" tab, then go to save, the mode is dropped from the request. Can you take a look and see how feasible it would be to prevent the field from getting dropped?

Copy link
Contributor

@jeramysoucy jeramysoucy left a comment

Choose a reason for hiding this comment

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

Kibana security changes LGTM

@ElenaStoeva
Copy link
Contributor Author

I noticed one more thing, but it may be related to an existing issue: #106006. If I create a template via the API with the synthetic mode, then click on the "Advanced" tab, then go to save, the mode is dropped from the request. Can you take a look and see how feasible it would be to prevent the field from getting dropped?

Nice catch! I looked into this but couldn't find an easy fix - it seems the form overwrites the request with the current values in the form, and since there is no form data for the mode field, it gets dropped. It might be easiest if we just add a simple field for the mode property (e.g. a dropdown with the different options). Wdyt?

I can still investigate some more tomorrow to check again if there is any way to fix this without adding a field, I could have missed something.

@ElenaStoeva
Copy link
Contributor Author

Hi @alisonelizabeth, I found that the mode property cannot be set if enabled or non-empty includes/excludes properties are set. For example, the following Es request would fail:

PUT _index_template/my_template
{
  "index_patterns": ["foo*"],
  "template": {
    "mappings": {
      "_source": {
        "enabled": false,
        "mode": "synthetic"
      },
      "properties": {
        "host_name": {
          "type": "keyword"
        },
        "created_at": {
          "type": "date",
          "format": "EEE MMM dd HH:mm:ss Z yyyy"
        }
      }
    }
  }
}

Therefore, I think it wouldn't make sense to display any of the existing source fields in the UI if the mode field is set, so I decided, as a short-term solution, to hide the source fields if the mode is set. Now the mode field is no longer dropped as I added it to the serialization function. The fix is in d7359e4.

As a follow-up work, we can improve the UI to have a toggle between the two options (setting a mode or setting the existing fields).

@ElenaStoeva ElenaStoeva force-pushed the im/serverless/disable-mappings-source-field branch from 1ac4492 to 5d775db Compare April 30, 2024 10:37
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
indexManagement 656.2KB 656.6KB +426.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
indexManagement 42.3KB 42.4KB +79.0B

History

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

cc @ElenaStoeva

@alisonelizabeth alisonelizabeth requested review from yuliacech and removed request for yuliacech May 1, 2024 01:03
Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

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

Thanks @ElenaStoeva! Latest lgtm. Great work 🎉

@ElenaStoeva ElenaStoeva merged commit 8e25828 into elastic:main May 1, 2024
17 checks passed
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels May 1, 2024
TinLe added a commit to TinLe/kibana that referenced this pull request May 1, 2024
* master: (1654 commits)
  Bump ejs from 3.1.9 to 3.1.10
  Don't render exceptions flyout if data is loading (elastic#181588)
  Enable value list modal (elastic#181593)
  skip flaky suite (elastic#181777)
  skip failing test suite (elastic#182263)
  [Mappings Editor] Disable _source field in serverless (elastic#181712)
  [data.search] Fix unhandled promise rejections (elastic#181785)
  [Fleet] Fix logic for detecting first time Elastic Agent users (elastic#182214)
  [ML] Decouple data_visualizer from MapEmbeddable (elastic#181928)
  [ES|QL] Sorting accepts expressions (elastic#181916)
  [ML] Single Metric Viewer: ensures chart displays correctly when opening from a job annotation (elastic#182176)
  Adding optional Description field to Roles APIs (elastic#182039)
  Upgrade Markdown-it to 14.1.0 (elastic#182244)
  Bump xml-crypto from 5.0.0 to 6.0.0
  [DOCS] Fix docs and screenshots for rule creation changes (elastic#181925)
  Update dependency elastic-apm-node to ^4.5.3 (main) (elastic#182236)
  [Obs AI Assistant] register alert details context in observability plugin (elastic#181501)
  Add `@typescript-eslint/no-floating-promises` (elastic#181456)
  [Playground] Propagate Error message into FE (elastic#182201)
  [ES|QL] Rename the setting to a more generic one and move to the general section (elastic#182074)
  ...
yuliacech pushed a commit to yuliacech/kibana that referenced this pull request May 3, 2024
Closes elastic#181555

## Summary

This PR disables the `_source` field in the Mappings editor's advanced
options when in serverless.

**How to test:**
1. Start a serverless project.
2. Go to Index Management and start creating an index template or a
component template.
3. In the Mappings step, go to the "Advanced options" tab.
4. Verify that the `_source` field is not displayed and that creating a
template doesn't add this property to the Es request.
5. Verify that, in stateful Kibana, the `_source` field still exists and
works as expected.

<!--
### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@ElenaStoeva ElenaStoeva deleted the im/serverless/disable-mappings-source-field branch June 24, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Mappings Editor Index mappings editor UI 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 v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Mappings editor] [Serverless] Remove _source configuration on serverless
7 participants