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

[Remote clusters] Migrate server code out of legacy #56781

Merged
merged 13 commits into from
Feb 10, 2020

Conversation

alisonelizabeth
Copy link
Contributor

@alisonelizabeth alisonelizabeth commented Feb 4, 2020

This PR completes the NP migration for the remote_clusters server-side code. I will address the client code in a separate PR.

Changes include:

  • Adopted NP router
  • Adopted NP license plugin
    • I'm happy to change the implementation here once we decide on a common pattern.
  • Updated route tests using the NP core mocks
  • Moved server code out of legacy directory

Note: It may be helpful to review the code changes by commit.

How to test

You will need to set up two clusters in order to test remote clusters. For example:

yarn es snapshot
yarn es snapshot -E cluster.name="my_cluster" -E http.port=9201 -E path.data=/tmp/es (in another tab)
  • Test all routes and confirm behaving as expected (create, edit, delete, get remote clusters)
  • Test license check (remote clusters is available with Basic license)

@alisonelizabeth alisonelizabeth added 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 Feature:NP Migration v7.7.0 labels Feb 4, 2020
@elasticmachine
Copy link
Contributor

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

@alisonelizabeth alisonelizabeth changed the title [WIP] [Remote clusters] Migrate remote clusters to NP [WIP] [Remote clusters] Migrate server code to NP Feb 5, 2020
@alisonelizabeth alisonelizabeth changed the title [WIP] [Remote clusters] Migrate server code to NP [WIP] [Remote clusters] Migrate server code out of legacy Feb 5, 2020
@elasticmachine
Copy link
Contributor

💔 Build Failed


Test Failures

Kibana Pipeline / kibana-xpack-agent / X-Pack API Integration Tests.x-pack/test/api_integration/apis/management/remote_clusters/remote_clusters·js.apis management remote clusters Remote Clusters Add should not allow us to re-add an existing remote cluster

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches

[00:00:00]       │
[00:00:00]         └-: apis
[00:00:00]           └-> "before all" hook
[00:04:17]           └-: management
[00:04:17]             └-> "before all" hook
[00:04:31]             └-: remote clusters
[00:04:31]               └-> "before all" hook
[00:04:31]               └-: Remote Clusters
[00:04:31]                 └-> "before all" hook
[00:04:31]                 └-: Add
[00:04:31]                   └-> "before all" hook
[00:04:31]                   └-> should allow us to add a remote cluster
[00:04:31]                     └-> "before each" hook: global before each
[00:04:31]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:04:31]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:04:31]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:04:31]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:04:31]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:04:31]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:04:31]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:04:31]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:04:31]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.skip_unavailable] from [false] to [true]
[00:04:31]                     └- ✓ pass  (65ms) "apis management remote clusters Remote Clusters Add should allow us to add a remote cluster"
[00:04:31]                   └-> should not allow us to re-add an existing remote cluster
[00:04:31]                     └-> "before each" hook: global before each
[00:04:31]                     └- ✖ fail: "apis management remote clusters Remote Clusters Add should not allow us to re-add an existing remote cluster"
[00:04:31]                     │

Stack Trace

Error: expected 409 "Conflict", got 400 "Bad Request"
    at Test._assertStatus (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:268:12)
    at Test._assertFunction (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:283:11)
    at Test.assert (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:173:18)
    at assert (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:131:12)
    at /dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:128:5
    at Test.Request.callback (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/index.js:718:3)
    at parser (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/index.js:906:18)
    at IncomingMessage.res.on (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/parsers/json.js:19:7)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Kibana Pipeline / kibana-xpack-agent / X-Pack API Integration Tests.x-pack/test/api_integration/apis/management/remote_clusters/remote_clusters·js.apis management remote clusters Remote Clusters Add should not allow us to re-add an existing remote cluster

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches

[00:00:00]       │
[00:00:00]         └-: apis
[00:00:00]           └-> "before all" hook
[00:04:55]           └-: management
[00:04:55]             └-> "before all" hook
[00:05:09]             └-: remote clusters
[00:05:09]               └-> "before all" hook
[00:05:09]               └-: Remote Clusters
[00:05:09]                 └-> "before all" hook
[00:05:09]                 └-: Add
[00:05:09]                   └-> "before all" hook
[00:05:09]                   └-> should allow us to add a remote cluster
[00:05:09]                     └-> "before each" hook: global before each
[00:05:09]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:05:09]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:05:09]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:05:09]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:05:09]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:05:09]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:05:09]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:05:09]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.seeds] from [[]] to [["localhost:6173"]]
[00:05:09]                     │ info [o.e.c.s.ClusterSettings] [kibana-ci-immutable-centos-tests-xl-1581024350419232108] updating [cluster.remote.test_cluster.skip_unavailable] from [false] to [true]
[00:05:09]                     └- ✓ pass  (71ms) "apis management remote clusters Remote Clusters Add should allow us to add a remote cluster"
[00:05:09]                   └-> should not allow us to re-add an existing remote cluster
[00:05:09]                     └-> "before each" hook: global before each
[00:05:09]                     └- ✖ fail: "apis management remote clusters Remote Clusters Add should not allow us to re-add an existing remote cluster"
[00:05:09]                     │

Stack Trace

Error: expected 409 "Conflict", got 400 "Bad Request"
    at Test._assertStatus (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:268:12)
    at Test._assertFunction (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:283:11)
    at Test.assert (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:173:18)
    at assert (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:131:12)
    at /dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:128:5
    at Test.Request.callback (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/index.js:718:3)
    at parser (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/index.js:906:18)
    at IncomingMessage.res.on (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/parsers/json.js:19:7)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

History

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

@elastic elastic deleted a comment from kibanamachine Feb 6, 2020
@alisonelizabeth alisonelizabeth changed the title [WIP] [Remote clusters] Migrate server code out of legacy [Remote clusters] Migrate server code out of legacy Feb 7, 2020
@elasticmachine
Copy link
Contributor

💔 Build Failed

History

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

@alisonelizabeth alisonelizabeth marked this pull request as ready for review February 7, 2020 14:45
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

History

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

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.

Great work @alisonelizabeth ! I left a few comments. One about typing information that I think should be addressed and one about migrating config to New Platform. I think it would be good to include the migration here if we consider this the final migration step from our side.

I created, updated and deleted a remote cluster(s) and the functionality worked 100% 🎉

@@ -7,8 +7,6 @@
import { Legacy } from 'kibana';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if the goal of this contribution is to complete the NP migration we should strip this file down to the bare minimum required to keep functional parity with legacy. For instance:

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 planning on addressing these items in a separate PR as part of the public migration.

Also, isEnabled is being used by CCR so I think this needs to stay as is for now.

import { RouteDependencies } from '../../types';

export const register = (deps: RouteDependencies): void => {
const addHandler: RequestHandler<any, any, any> = async (ctx, request, response) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to try and avoid use of any here when we know what the query, params and body will be.

Using unknown explicitly when we know we don't expect a value in one of those slots makes it clear what we expect for a route. Then passing in type information from:

body: schema.object({
          name: schema.string(),
          seeds: schema.arrayOf(schema.string()),
          skipUnavailable: schema.boolean(),
        }),

would be really nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, fixed!

const cluster = get(updateClusterResponse, `persistent.cluster.remote.${name}`);

if (acknowledged && !cluster) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

A short comment here explaining why we are not returning a KibanaResponse for the happy path would be helpful 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment. The response is being returned on L104.

@alisonelizabeth
Copy link
Contributor Author

@jloleysens I believe I addressed all of your comments. Mind taking another look? I plan on creating a separate PR to complete the migration of the public code and anything else outstanding in x-pack/legacy/plugins/remote_clusters/index.ts

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.

Happy with the changes - did not test manually again.

@alisonelizabeth
Copy link
Contributor Author

@elasticmachine merge upstream

@alisonelizabeth
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

@alisonelizabeth alisonelizabeth merged commit 82972ef into elastic:master Feb 10, 2020
@alisonelizabeth alisonelizabeth deleted the np/remote_clusters branch February 10, 2020 20:25
gmmorris added a commit to gmmorris/kibana that referenced this pull request Feb 11, 2020
* master: (34 commits)
  [Index management] Server-side NP ready (elastic#56829)
  Webhook action - make user and password secrets optional (elastic#56823)
  [DOCS] Removes reference to IRC (elastic#57245)
  [Monitoring] NP migration: Local angular module (elastic#51823)
  [SIEM] Adds ECS link to help menu (elastic#57104)
  Ensure http interceptors are shares across lifecycle methods (elastic#57150)
  [Remote clusters] Migrate server code out of legacy (elastic#56781)
  fixes render bug in alert list (elastic#57152)
  siem 7.6 updates (elastic#57169)
  Make the update alert API key API work when AAD is out of sync (elastic#56640)
  fix(NA): MaxListenersExceededWarning on getLoggerStream (elastic#57133)
  [Metrics UI] Setup commonly used time ranges in timepicker (elastic#56701)
  [Maps] set filter.meta.key to geoFieldName so query passes filterMatchesIndex when ignoreFilterIfFieldNotInIndex is true (elastic#56692)
  Create plugin mock for event log plugin (elastic#57048)
  fix ts error on master (elastic#57236)
  Don't create API key for disabled alerts when calling create API (elastic#57041)
  Fix enable and disable API to still work when AAD is out of sync (elastic#56634)
  [DOCS] Canvas embed objects (elastic#57156)
  Delete autocomplete namespace (elastic#57187)
  Security - Inject logout url (elastic#57201)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:CCR and Remote Clusters Feature:NP Migration 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.

5 participants