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

[Enterprise Search] Request handler refactors/enhancements + update existing routes to use shared handler #76106

Merged
merged 8 commits into from
Aug 28, 2020

Conversation

cee-chen
Copy link
Member

Summary

This PR follows up on the awesome work done in #75487 🎉

  • Updates /api/app_search/engines and /api/workplace_search/overview to use the shared request handler
  • Adds the following refactors/enhancements:
    • 4804aee[Refactor] Changes the function enterpriseSearchRequestHandler to a class EnterpriseSearchRequestHandler
      • The helper class is now instantiated on plugin.ts load with config and log dependencies
      • The end goal is that each route doesn't have to constantly pass the same static dependencies repeatedly. They now only pass params that change per-route
      • It also had a neat side effect of cleaning up type definitions slightly
    • 74a4149[Enhancement] The lib has been updated to allow passing custom params that override request.query
      • This is for the /api/app_Search/engines endpoint, which renames some params between Kibana client-side and Enterprise Search API, as well as stores a param (page size) as a constant instead of passing it between public/ & server/.
    • 74a4149[Enhancement] The lib has been updated to pass route method and body payload.
      • This is in anticipation for upcoming POST routes.
    • 74a4149[Enhancement] The lib has been updated to pass back the status returned by the Enterprise Search API endpoint
      • This is in anticipation for endpoints that can 404, such as a single engine endpoint.
    • 4d1f6f9[Enhancement] The lib has been (re?)updated to detect /login redirects
      • We were seeing a decent amount of these issues in Cloud and IMO this change will be helpful for quickly diagnosing auth issues if we send back a console error instead of relying solely on a server/log error (although that is still there of course).
  • Test refactors:
    • ffb659f - Adds a mockRequestHandler mock that represents an enterpriseSearchRequestHandler, and can be passed via mockDependencies
    • 134d13c - Adds a test-only hasValidData helper which pulls out the slightly ugly jestMock.mock.calls[0][0] syntax for us (which I'd previously whinged about)

QA

Note that localhost:5601/api/enterprise_search/config_data and localhost:5601/api/enterprise_search/telemetry remain unchanged (telemetry because it doesn't need to hit Enterprise Search's API, and config_data because it has a decent amount of custom behavior such as a signal controller).

Checklist

…fig/log

- So that routes don't have to continuously pass it in - just params that actually change (paths, queries)

+ misc refactors/lint fixes from code review
- This required updating the shared handler to accept custom params set by the route, since the engines route transmutes some param names
- createRequest mock also had to be updated to correctly reflect a curried function in order to get tests passing
- Check for /login URL (indicates auth issue)
- Refactor final catch return to allow being passed messages from previous throw
- Change hasValidData fallback to only log (potentially sensitive?) JSON data to server, not to client
- Minor test cleanup - move error tests to single describe block, minor URL/newline cleanup
- This will support future POST requests as well as support (e.g.) 404 responses

Minor test refactors:
- Set up new request defaults (method, empty body) + expected output & convert KibanaAuthHeader to string since they're set so close to one another
- group request pass tests into a describe block, remove response body portion of their tests (since we don't really care about that for those tests)
- group response tests into describe block
- clarify how passed handler params arg overrides request.params
@cee-chen cee-chen added Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes v7.10.0 labels Aug 27, 2020
Comment on lines 87 to 92
const errorMessage = `Error connecting to Enterprise Search: ${e?.message || e.toString()}`;

this.log.error(errorMessage);
if (e instanceof Error) this.log.debug(e.stack as string);

return response.customError({ statusCode: 502, body: errorMessage });
Copy link
Member Author

@cee-chen cee-chen Aug 27, 2020

Choose a reason for hiding this comment

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

😁 I was accidentally able to test the new functionality where we send custom error messages back to the console (instead of the previous generic "Error connecting" message) when implementing the body payload:

Screen Shot 2020-08-26 at 4 53 40 PM

VERY useful for debugging, and I'm happy w/ this change - the only thing to keep an eye on is if we start catching errors that leak sensitive info in the message somehow.

Comment on lines 66 to 68
const body = Object.keys(request.body as object).length
? JSON.stringify(request.body)
: undefined;
Copy link
Member Author

@cee-chen cee-chen Aug 27, 2020

Choose a reason for hiding this comment

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

Follow up to the above comment:

Kibana's request.body sends an empty obj, while node-fetch's expects an undefined if there's no body, hence this required ternary check.

We might also want to consider checking for method === 'GET'/HEAD and not allowing a body for GET requests (see below repeated screenshot), but that's maybe overkill? What do you think?

Screen Shot 2020-08-26 at 4 53 40 PM

Copy link
Member

@JasonStoltz JasonStoltz left a comment

Choose a reason for hiding this comment

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

Approved, but I left a suggestion to consider.

) => {
try {
// Set up API URL
params = params ?? (request.query ? `?${querystring.stringify(request.query)}` : '');
Copy link
Member

Choose a reason for hiding this comment

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

Could params be an object rather than a string? This would let us "merge" params, if some need to be dynamic and some static.

const allParams = {
  ...(params && { params }), // base params
  ...(request.query && { request.query }) // override / mix in dynamic params
}
params = (Object.keys(allParams).length > 0 ? `?${querystring.stringify(allParams)}` : '');

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah! Great call, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

f6a709d - this is so much better, thanks for the amazing suggestion!!

I also realized while testing it that request.query is also an empty obj so in reality our request.query ? check was never failing 🤦‍♀️

return response.customError({ statusCode: 502, body: 'cannot-connect' });
}
})}`,
hasValidData: (body?: IEnginesResponse) =>
Copy link
Member

Choose a reason for hiding this comment

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

Totally unrelated to this PR. Do we need to add this for every API request 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah, probably not. I think I originally added it to catch issues like the /login redirect (or anything else cropping up that I couldn't predict due to auth issues). I'd say it's probably only super important for pages where the front-end will crash with a typeerror of some kind if it receives unexpected data. 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

To be honest I'd be fine if most API routes going forward didn't have this, and we added them on an as-needed basis (if we started getting error reports for bad API endpoints, for example).

@kibanamachine
Copy link
Contributor

💛 Build succeeded, but was flaky


Test Failures

Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/infra/home_page·ts.InfraOps app Home page with metrics present records telemetry for docker

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has failed 1 times on tracked branches: https://github.com/elastic/kibana/issues/75724

[00:00:00]       │
[00:23:23]         └-: InfraOps app
[00:23:23]           └-> "before all" hook
[00:23:23]           └-: Home page
[00:23:23]             └-> "before all" hook
[00:23:23]             └-> "before all" hook
[00:23:23]               │ info [empty_kibana] Loading "mappings.json"
[00:23:23]               │ info [o.e.c.m.MetadataDeleteIndexService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] [.kibana_2/uE2Bw65iTVOHfLxJcNJgcQ] deleting index
[00:23:23]               │ info [o.e.c.m.MetadataDeleteIndexService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] [.kibana_1/b1rS7ETvR5-B6CgYe3W92Q] deleting index
[00:23:23]               │ info [empty_kibana] Deleted existing index [".kibana_2",".kibana_1"]
[00:23:23]               │ info [o.e.c.m.MetadataCreateIndexService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] [.kibana] creating index, cause [api], templates [], shards [1]/[1]
[00:23:23]               │ info [empty_kibana] Created index ".kibana"
[00:23:23]               │ debg [empty_kibana] ".kibana" settings {"index":{"number_of_replicas":"1","number_of_shards":"1"}}
[00:23:23]               │ info [o.e.c.m.MetadataMappingService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] [.kibana/kGQ0yZX8SrKqKRDEUhCgZg] update_mapping [_doc]
[00:23:23]               │ debg Migrating saved objects
[00:23:23]               │ proc [kibana]   log   [00:05:34.719] [error][data][elasticsearch] [version_conflict_engine_exception]: [task:session_cleanup]: version conflict, document already exists (current version [4])
[00:23:23]               │ proc [kibana]   log   [00:05:34.720] [info][savedobjects-service] Creating index .kibana_2.
[00:23:23]               │ info [o.e.c.m.MetadataCreateIndexService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] [.kibana_2] creating index, cause [api], templates [], shards [1]/[1]
[00:23:23]               │ info [o.e.c.r.a.AllocationService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] updating number_of_replicas to [0] for indices [.kibana_2]
[00:23:23]               │ proc [kibana]   log   [00:05:34.790] [info][savedobjects-service] Reindexing .kibana to .kibana_1
[00:23:23]               │ info [o.e.c.m.MetadataCreateIndexService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] [.kibana_1] creating index, cause [api], templates [], shards [1]/[1]
[00:23:23]               │ info [o.e.c.r.a.AllocationService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] updating number_of_replicas to [0] for indices [.kibana_1]
[00:23:23]               │ info [o.e.t.LoggingTaskListener] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] 30451 finished with response BulkByScrollResponse[took=1ms,timed_out=false,sliceId=null,updated=0,created=0,deleted=0,batches=0,versionConflicts=0,noops=0,retries=0,throttledUntil=0s,bulk_failures=[],search_failures=[]]
[00:23:23]               │ info [o.e.c.m.MetadataDeleteIndexService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] [.kibana/kGQ0yZX8SrKqKRDEUhCgZg] deleting index
[00:23:23]               │ proc [kibana]   log   [00:05:35.127] [info][savedobjects-service] Migrating .kibana_1 saved objects to .kibana_2
[00:23:23]               │ proc [kibana]   log   [00:05:35.131] [info][savedobjects-service] Pointing alias .kibana to .kibana_2.
[00:23:23]               │ proc [kibana]   log   [00:05:35.155] [info][savedobjects-service] Finished in 436ms.
[00:23:23]               │ debg applying update to kibana config: {"accessibility:disableAnimations":true,"dateFormat:tz":"UTC"}
[00:23:23]               │ proc [kibana]   log   [00:05:35.196] [error][data][elasticsearch] [version_conflict_engine_exception]: [task:session_cleanup]: version conflict, document already exists (current version [4])
[00:23:23]               │ info [o.e.c.m.MetadataMappingService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] [.kibana_2/qA7nmRCsR9qwJb9nY1JBeA] update_mapping [_doc]
[00:23:24]               │ proc [kibana]   log   [00:05:35.245] [error][data][elasticsearch] [version_conflict_engine_exception]: [space:default]: version conflict, document already exists (current version [1])
[00:23:24]               │ info [o.e.c.m.MetadataMappingService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] [.kibana_2/qA7nmRCsR9qwJb9nY1JBeA] update_mapping [_doc]
[00:23:34]             └-: with metrics present
[00:23:34]               └-> "before all" hook
[00:23:34]               └-> "before all" hook
[00:23:34]                 │ info [infra/metrics_and_logs] Loading "mappings.json"
[00:23:34]                 │ info [infra/metrics_and_logs] Loading "data.json.gz"
[00:23:34]                 │ info [o.e.c.m.MetadataCreateIndexService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] [metricbeat-7.0.0-alpha1-2018.10.17] creating index, cause [api], templates [], shards [1]/[0]
[00:23:34]                 │ info [o.e.c.r.a.AllocationService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] current.health="GREEN" message="Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[metricbeat-7.0.0-alpha1-2018.10.17][0]]])." previous.health="YELLOW" reason="shards started [[metricbeat-7.0.0-alpha1-2018.10.17][0]]"
[00:23:34]                 │ info [infra/metrics_and_logs] Created index "metricbeat-7.0.0-alpha1-2018.10.17"
[00:23:34]                 │ debg [infra/metrics_and_logs] "metricbeat-7.0.0-alpha1-2018.10.17" settings {"index":{"codec":"best_compression","mapping":{"total_fields":{"limit":"10000"}},"number_of_replicas":"0","number_of_shards":"1","query":{"default_field":["beat.name","beat.hostname","beat.timezone","beat.version","tags","error.message","error.type","meta.cloud.provider","meta.cloud.instance_id","meta.cloud.instance_name","meta.cloud.machine_type","meta.cloud.availability_zone","meta.cloud.project_id","meta.cloud.region","docker.container.id","docker.container.image","docker.container.name","host.name","host.id","host.architecture","host.os.platform","host.os.version","host.os.family","host.mac","kubernetes.pod.name","kubernetes.pod.uid","kubernetes.namespace","kubernetes.node.name","kubernetes.container.name","kubernetes.container.image","metricset.module","metricset.name","metricset.host","metricset.namespace","type","service.name","aerospike.namespace.name","aerospike.namespace.node.host","aerospike.namespace.node.name","apache.status.hostname","ceph.cluster_health.overall_status","ceph.cluster_health.timechecks.round.status","ceph.monitor_health.health","ceph.monitor_health.name","ceph.osd_df.name","ceph.osd_df.device_class","ceph.osd_tree.name","ceph.osd_tree.type","ceph.osd_tree.children","ceph.osd_tree.status","ceph.osd_tree.device_class","ceph.osd_tree.father","ceph.pool_disk.name","couchbase.bucket.name","couchbase.bucket.type","couchbase.node.hostname","docker.container.command","docker.container.status","docker.container.ip_addresses","docker.healthcheck.status","docker.healthcheck.event.output","docker.image.id.current","docker.image.id.parent","docker.info.id","docker.network.interface","elasticsearch.cluster.name","elasticsearch.cluster.id","elasticsearch.cluster.state.id","elasticsearch.index.name","elasticsearch.node.name","elasticsearch.node.version","elasticsearch.node.jvm.version","elasticsearch.cluster.pending_task.source","elasticsearch.shard.state","etcd.leader.leader","etcd.self.id","etcd.self.leaderinfo.leader","etcd.self.leaderinfo.starttime","etcd.self.leaderinfo.uptime","etcd.self.name","etcd.self.starttime","etcd.self.state","golang.expvar.cmdline","golang.heap.cmdline","graphite.server.example","haproxy.stat.status","haproxy.stat.service_name","haproxy.stat.check.status","haproxy.stat.check.health.last","haproxy.stat.proxy.name","http.request.method","http.request.body","http.response.code","http.response.phrase","http.response.body","kafka.consumergroup.broker.address","kafka.consumergroup.id","kafka.consumergroup.topic","kafka.consumergroup.meta","kafka.consumergroup.client.id","kafka.consumergroup.client.host","kafka.consumergroup.client.member_id","kafka.partition.topic.name","kafka.partition.broker.address","kibana.stats.cluster_uuid","kibana.stats.name","kibana.stats.uuid","kibana.stats.version.number","kibana.stats.status.overall.state","kibana.status.name","kibana.status.uuid","kibana.status.version.number","kibana.status.status.overall.state","kubernetes.apiserver.request.client","kubernetes.apiserver.request.resource","kubernetes.apiserver.request.subresource","kubernetes.apiserver.request.scope","kubernetes.apiserver.request.verb","kubernetes.event.message","kubernetes.event.reason","kubernetes.event.type","kubernetes.event.metadata.name","kubernetes.event.metadata.namespace","kubernetes.event.metadata.resource_version","kubernetes.event.metadata.uid","kubernetes.event.metadata.self_link","kubernetes.event.involved_object.api_version","kubernetes.event.involved_object.kind","kubernetes.event.involved_object.name","kubernetes.event.involved_object.resource_version","kubernetes.event.involved_object.uid","kubernetes.container.id","kubernetes.container.status.phase","kubernetes.container.status.reason","kubernetes.deployment.name","kubernetes.node.status.ready","kubernetes.pod.status.phase","kubernetes.pod.status.ready","kubernetes.pod.status.scheduled","kubernetes.replicaset.name","kubernetes.statefulset.name","kubernetes.system.container","kubernetes.volume.name","kvm.dommemstat.stat.name","kvm.dommemstat.name","logstash.node.host","logstash.node.version","logstash.node.jvm.version","mongodb.collstats.db","mongodb.collstats.collection","mongodb.collstats.name","mongodb.dbstats.db","mongodb.status.version","mongodb.status.storage_engine.name","mysql.galera_status.cluster.status","mysql.galera_status.connected","mysql.galera_status.evs.evict","mysql.galera_status.evs.state","mysql.galera_status.local.state","mysql.galera_status.ready","nginx.stubstatus.hostname","php_fpm.pool.name","php_fpm.pool.process_manager","postgresql.activity.database.name","postgresql.activity.user.name","postgresql.activity.application_name","postgresql.activity.client.address","postgresql.activity.client.hostname","postgresql.activity.state","postgresql.activity.query","postgresql.database.name","postgresql.statement.query.text","rabbitmq.connection.name","rabbitmq.connection.vhost","rabbitmq.connection.user","rabbitmq.connection.node","rabbitmq.connection.type","rabbitmq.connection.host","rabbitmq.connection.peer.host","rabbitmq.exchange.name","rabbitmq.exchange.vhost","rabbitmq.exchange.user","rabbitmq.node.name","rabbitmq.node.type","rabbitmq.queue.name","rabbitmq.queue.vhost","rabbitmq.queue.node","rabbitmq.queue.state","redis.info.memory.max.policy","redis.info.memory.allocator","redis.info.persistence.rdb.bgsave.last_status","redis.info.persistence.aof.bgrewrite.last_status","redis.info.persistence.aof.write.last_status","redis.info.replication.role","redis.info.server.version","redis.info.server.git_sha1","redis.info.server.git_dirty","redis.info.server.build_id","redis.info.server.mode","redis.info.server.os","redis.info.server.arch_bits","redis.info.server.multiplexing_api","redis.info.server.gcc_version","redis.info.server.run_id","redis.info.server.config_file","redis.keyspace.id","system.diskio.name","system.diskio.serial_number","system.filesystem.device_name","system.filesystem.type","system.filesystem.mount_point","system.network.name","system.process.name","system.process.state","system.process.cmdline","system.process.username","system.process.cwd","system.process.cgroup.id","system.process.cgroup.path","system.process.cgroup.cpu.id","system.process.cgroup.cpu.path","system.process.cgroup.cpuacct.id","system.process.cgroup.cpuacct.path","system.process.cgroup.memory.id","system.process.cgroup.memory.path","system.process.cgroup.blkio.id","system.process.cgroup.blkio.path","system.raid.name","system.raid.activity_state","system.socket.direction","system.socket.family","system.socket.remote.host","system.socket.remote.etld_plus_one","system.socket.remote.host_error","system.socket.process.command","system.socket.process.cmdline","system.socket.process.exe","system.socket.user.name","uwsgi.status.worker.status","uwsgi.status.worker.rss","vsphere.datastore.name","vsphere.datastore.fstype","vsphere.host.name","vsphere.host.network_names","vsphere.virtualmachine.host","vsphere.virtualmachine.name","vsphere.virtualmachine.network_names","windows.service.id","windows.service.name","windows.service.display_name","windows.service.start_type","windows.service.state","windows.service.exit_code","zookeeper.mntr.hostname","zookeeper.mntr.server_state","zookeeper.mntr.version","fields.*"]},"refresh_interval":"5s"}}
[00:23:34]                 │ info [o.e.c.m.MetadataCreateIndexService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] [filebeat-7.0.0-alpha1-2018.10.17] creating index, cause [api], templates [], shards [1]/[0]
[00:23:34]                 │ info [o.e.c.r.a.AllocationService] [kibana-ci-immutable-debian-tests-xxl-1598569827377865364] current.health="GREEN" message="Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[filebeat-7.0.0-alpha1-2018.10.17][0]]])." previous.health="YELLOW" reason="shards started [[filebeat-7.0.0-alpha1-2018.10.17][0]]"
[00:23:34]                 │ info [infra/metrics_and_logs] Created index "filebeat-7.0.0-alpha1-2018.10.17"
[00:23:34]                 │ debg [infra/metrics_and_logs] "filebeat-7.0.0-alpha1-2018.10.17" settings {"index":{"codec":"best_compression","mapping":{"total_fields":{"limit":"10000"}},"number_of_replicas":"0","number_of_shards":"1","query":{"default_field":["beat.name","beat.hostname","beat.timezone","beat.version","tags","error.message","error.type","meta.cloud.provider","meta.cloud.instance_id","meta.cloud.instance_name","meta.cloud.machine_type","meta.cloud.availability_zone","meta.cloud.project_id","meta.cloud.region","docker.container.id","docker.container.image","docker.container.name","host.name","host.id","host.architecture","host.os.platform","host.os.version","host.os.family","host.mac","kubernetes.pod.name","kubernetes.pod.uid","kubernetes.namespace","kubernetes.node.name","kubernetes.container.name","kubernetes.container.image","source","message","stream","prospector.type","input.type","read_timestamp","fileset.module","fileset.name","syslog.severity_label","syslog.facility_label","process.program","service.name","log.level","apache2.access.remote_ip","apache2.access.user_name","apache2.access.method","apache2.access.url","apache2.access.http_version","apache2.access.referrer","apache2.access.agent","apache2.access.user_agent.device","apache2.access.user_agent.patch","apache2.access.user_agent.name","apache2.access.user_agent.os","apache2.access.user_agent.os_name","apache2.access.geoip.continent_name","apache2.access.geoip.country_iso_code","apache2.access.geoip.region_name","apache2.access.geoip.city_name","apache2.error.level","apache2.error.client","apache2.error.message","apache2.error.module","auditd.log.record_type","auditd.log.old_auid","auditd.log.new_auid","auditd.log.old_ses","auditd.log.new_ses","auditd.log.acct","auditd.log.pid","auditd.log.ppid","auditd.log.items","auditd.log.item","auditd.log.a0","auditd.log.res","auditd.log.geoip.continent_name","auditd.log.geoip.city_name","auditd.log.geoip.region_name","auditd.log.geoip.country_iso_code","elasticsearch.audit.node_name","elasticsearch.audit.layer","elasticsearch.audit.event_type","elasticsearch.audit.origin_type","elasticsearch.audit.principal","elasticsearch.audit.action","elasticsearch.audit.uri","elasticsearch.audit.request","elasticsearch.audit.request_body","elasticsearch.gc.tags","elasticsearch.server.component","elasticsearch.slowlog.loglevel","elasticsearch.slowlog.logger","elasticsearch.slowlog.node_name","elasticsearch.slowlog.index_name","elasticsearch.slowlog.shard_id","elasticsearch.slowlog.took","elasticsearch.slowlog.types","elasticsearch.slowlog.stats","elasticsearch.slowlog.search_type","elasticsearch.slowlog.source_query","elasticsearch.slowlog.extra_source","elasticsearch.slowlog.took_millis","elasticsearch.slowlog.total_hits","elasticsearch.slowlog.total_shards","icinga.debug.facility","icinga.debug.severity","icinga.debug.message","icinga.main.facility","icinga.main.severity","icinga.main.message","icinga.startup.facility","icinga.startup.severity","icinga.startup.message","iis.access.server_ip","iis.access.method","iis.access.url","iis.access.query_string","iis.access.user_name","iis.access.remote_ip","iis.access.referrer","iis.access.site_name","iis.access.server_name","iis.access.http_version","iis.access.cookie","iis.access.hostname","iis.access.agent","iis.access.user_agent.device","iis.access.user_agent.patch","iis.access.user_agent.name","iis.access.user_agent.os","iis.access.user_agent.os_name","iis.access.geoip.continent_name","iis.access.geoip.country_iso_code","iis.access.geoip.region_name","iis.access.geoip.city_name","iis.error.remote_ip","iis.error.server_ip","iis.error.http_version","iis.error.method","iis.error.url","iis.error.reason_phrase","iis.error.queue_name","iis.error.geoip.continent_name","iis.error.geoip.country_iso_code","iis.error.geoip.region_name","iis.error.geoip.city_name","kafka.log.timestamp","kafka.log.level","kafka.log.message","kafka.log.component","kafka.log.class","kafka.log.trace.class","kafka.log.trace.message","kafka.log.trace.full","kibana.log.tags","kibana.log.state","logstash.log.message","logstash.log.level","logstash.log.module","logstash.log.thread","logstash.slowlog.message","logstash.slowlog.level","logstash.slowlog.module","logstash.slowlog.thread","logstash.slowlog.event","logstash.slowlog.plugin_name","logstash.slowlog.plugin_type","logstash.slowlog.plugin_params","mongodb.log.severity","mongodb.log.component","mongodb.log.context","mongodb.log.message","mysql.error.timestamp","mysql.error.level","mysql.error.message","mysql.slowlog.user","mysql.slowlog.host","mysql.slowlog.ip","mysql.slowlog.query","nginx.access.remote_ip","nginx.access.user_name","nginx.access.method","nginx.access.url","nginx.access.http_version","nginx.access.referrer","nginx.access.agent","nginx.access.user_agent.device","nginx.access.user_agent.patch","nginx.access.user_agent.name","nginx.access.user_agent.os","nginx.access.user_agent.os_name","nginx.access.geoip.continent_name","nginx.access.geoip.country_iso_code","nginx.access.geoip.region_name","nginx.access.geoip.city_name","nginx.error.level","nginx.error.message","osquery.result.name","osquery.result.action","osquery.result.host_identifier","osquery.result.calendar_time","postgresql.log.timestamp","postgresql.log.timezone","postgresql.log.user","postgresql.log.database","postgresql.log.level","postgresql.log.query","postgresql.log.message","redis.log.role","redis.log.level","redis.log.message","redis.slowlog.cmd","redis.slowlog.key","redis.slowlog.args","system.auth.timestamp","system.auth.hostname","system.auth.program","system.auth.message","system.auth.user","system.auth.ssh.event","system.auth.ssh.method","system.auth.ssh.signature","system.auth.ssh.geoip.continent_name","system.auth.ssh.geoip.city_name","system.auth.ssh.geoip.region_name","system.auth.ssh.geoip.country_iso_code","system.auth.sudo.error","system.auth.sudo.tty","system.auth.sudo.pwd","system.auth.sudo.user","system.auth.sudo.command","system.auth.useradd.name","system.auth.useradd.home","system.auth.useradd.shell","system.auth.groupadd.name","system.syslog.timestamp","system.syslog.hostname","system.syslog.program","system.syslog.pid","system.syslog.message","traefik.access.remote_ip","traefik.access.user_name","traefik.access.method","traefik.access.url","traefik.access.http_version","traefik.access.referrer","traefik.access.agent","traefik.access.user_agent.device","traefik.access.user_agent.patch","traefik.access.user_agent.name","traefik.access.user_agent.os","traefik.access.user_agent.os_name","traefik.access.geoip.continent_name","traefik.access.geoip.country_iso_code","traefik.access.geoip.region_name","traefik.access.geoip.city_name","traefik.access.frontend_name","traefik.access.backend_url","fields.*"]},"refresh_interval":"5s"}}
[00:23:38]                 │ info [infra/metrics_and_logs] Indexed 11063 docs into "metricbeat-7.0.0-alpha1-2018.10.17"
[00:23:38]                 │ info [infra/metrics_and_logs] Indexed 1632 docs into "filebeat-7.0.0-alpha1-2018.10.17"
[00:23:38]                 │ debg navigating to infraOps url: http://localhost:6131/app/metrics
[00:23:38]                 │ debg navigate to: http://localhost:6131/app/metrics
[00:23:38]                 │ debg browser[INFO] http://localhost:6131/app/metrics?_t=1598573149864 341 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
[00:23:38]                 │
[00:23:38]                 │ debg browser[INFO] http://localhost:6131/bootstrap.js 42:19 "^ A single error about an inline script not firing due to content security policy is expected!"
[00:23:38]                 │ debg ... sleep(700) start
[00:23:39]                 │ debg ... sleep(700) end
[00:23:39]                 │ debg returned from get, calling refresh
[00:23:40]                 │ debg browser[INFO] http://localhost:6131/35882/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js 452:106112 "INFO: 2020-08-28T00:05:50Z
[00:23:40]                 │        Adding connection to http://localhost:6131/elasticsearch
[00:23:40]                 │
[00:23:40]                 │      "
[00:23:40]                 │ debg browser[INFO] http://localhost:6131/app/metrics?_t=1598573149864 341 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
[00:23:40]                 │
[00:23:40]                 │ debg browser[INFO] http://localhost:6131/bootstrap.js 42:19 "^ A single error about an inline script not firing due to content security policy is expected!"
[00:23:40]                 │ debg currentUrl = http://localhost:6131/app/metrics
[00:23:40]                 │          appUrl = http://localhost:6131/app/metrics
[00:23:40]                 │ debg TestSubjects.find(kibanaChrome)
[00:23:40]                 │ debg Find.findByCssSelector('[data-test-subj="kibanaChrome"]') with timeout=60000
[00:23:42]                 │ debg browser[INFO] http://localhost:6131/35882/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js 452:106112 "INFO: 2020-08-28T00:05:52Z
[00:23:42]                 │        Adding connection to http://localhost:6131/elasticsearch
[00:23:42]                 │
[00:23:42]                 │      "
[00:23:42]                 │ debg ... sleep(501) start
[00:23:42]                 │ debg ... sleep(501) end
[00:23:42]                 │ debg in navigateTo url = http://localhost:6131/app/metrics/inventory?waffleFilter=(expression%3A''%2Ckind%3Akuery)&waffleOptions=(accountId%3A''%2CautoBounds%3A!t%2CboundsOverride%3A(max%3A1%2Cmin%3A0)%2CcustomMetrics%3A!()%2CcustomOptions%3A!()%2CgroupBy%3A!()%2Clegend%3A(palette%3Acool%2CreverseColors%3A!f%2Csteps%3A10)%2Cmetric%3A(type%3Acpu)%2CnodeType%3Ahost%2Cregion%3A''%2Csort%3A(by%3Aname%2Cdirection%3Adesc)%2Cview%3Amap)&waffleTime=(currentTime%3A1598573153520%2CisAutoReloading%3A!f)
[00:23:42]                 │ debg --- retry.try error: URL changed, waiting for it to settle
[00:23:43]                 │ debg ... sleep(501) start
[00:23:43]                 │ debg ... sleep(501) end
[00:23:43]                 │ debg in navigateTo url = http://localhost:6131/app/metrics/inventory?waffleFilter=(expression%3A''%2Ckind%3Akuery)&waffleOptions=(accountId%3A''%2CautoBounds%3A!t%2CboundsOverride%3A(max%3A1%2Cmin%3A0)%2CcustomMetrics%3A!()%2CcustomOptions%3A!()%2CgroupBy%3A!()%2Clegend%3A(palette%3Acool%2CreverseColors%3A!f%2Csteps%3A10)%2Cmetric%3A(type%3Acpu)%2CnodeType%3Ahost%2Cregion%3A''%2Csort%3A(by%3Aname%2Cdirection%3Adesc)%2Cview%3Amap)&waffleTime=(currentTime%3A1598573153520%2CisAutoReloading%3A!f)
[00:23:43]                 │ debg TestSubjects.exists(statusPageContainer)
[00:23:43]                 │ debg Find.existsByDisplayedByCssSelector('[data-test-subj="statusPageContainer"]') with timeout=2500
[00:23:46]                 │ debg --- retry.tryForTime error: [data-test-subj="statusPageContainer"] is not displayed
[00:23:46]                 │ debg TestSubjects.missingOrFail(loadingMessage)
[00:23:46]                 │ debg Find.waitForDeletedByCssSelector('[data-test-subj="loadingMessage"]') with timeout=20000
[00:23:47]               └-> renders the waffle map for dates with data
[00:23:47]                 └-> "before each" hook: global before each
[00:23:47]                 │ debg Find.findByCssSelector('[data-test-subj="waffleDatePicker"] .euiDatePicker.euiFieldText') with timeout=10000
[00:23:50]                 │ debg TestSubjects.find(waffleMap)
[00:23:50]                 │ debg Find.findByCssSelector('[data-test-subj="waffleMap"]') with timeout=10000
[00:23:50]                 │ debg TestSubjects.find(waffleMap)
[00:23:50]                 │ debg Find.findByCssSelector('[data-test-subj="waffleMap"]') with timeout=10000
[00:23:50]                 └- ✓ pass  (3.4s) "InfraOps app Home page with metrics present renders the waffle map for dates with data"
[00:23:50]               └-> renders an empty data prompt for dates with no data
[00:23:50]                 └-> "before each" hook: global before each
[00:23:50]                 │ debg Find.findByCssSelector('[data-test-subj="waffleDatePicker"] .euiDatePicker.euiFieldText') with timeout=10000
[00:23:53]                 │ debg TestSubjects.find(noMetricsDataPrompt)
[00:23:53]                 │ debg Find.findByCssSelector('[data-test-subj="noMetricsDataPrompt"]') with timeout=10000
[00:23:53]                 └- ✓ pass  (3.1s) "InfraOps app Home page with metrics present renders an empty data prompt for dates with no data"
[00:23:53]               └-> records telemetry for hosts
[00:23:53]                 └-> "before each" hook: global before each
[00:23:53]                 │ debg Find.findByCssSelector('[data-test-subj="waffleDatePicker"] .euiDatePicker.euiFieldText') with timeout=10000
[00:23:56]                 │ debg TestSubjects.find(waffleMap)
[00:23:56]                 │ debg Find.findByCssSelector('[data-test-subj="waffleMap"]') with timeout=10000
[00:23:57]                 │ debg TestSubjects.find(waffleMap)
[00:23:57]                 │ debg Find.findByCssSelector('[data-test-subj="waffleMap"]') with timeout=10000
[00:23:57]                 └- ✓ pass  (3.8s) "InfraOps app Home page with metrics present records telemetry for hosts"
[00:23:57]               └-> records telemetry for docker
[00:23:57]                 └-> "before each" hook: global before each
[00:23:57]                 │ debg Find.findByCssSelector('[data-test-subj="waffleDatePicker"] .euiDatePicker.euiFieldText') with timeout=10000
[00:24:00]                 │ debg TestSubjects.find(waffleMap)
[00:24:00]                 │ debg Find.findByCssSelector('[data-test-subj="waffleMap"]') with timeout=10000
[00:24:00]                 │ debg TestSubjects.find(waffleMap)
[00:24:00]                 │ debg Find.findByCssSelector('[data-test-subj="waffleMap"]') with timeout=10000
[00:24:00]                 │ debg TestSubjects.click(openInventorySwitcher)
[00:24:00]                 │ debg Find.clickByCssSelector('[data-test-subj="openInventorySwitcher"]') with timeout=10000
[00:24:00]                 │ debg Find.findByCssSelector('[data-test-subj="openInventorySwitcher"]') with timeout=10000
[00:24:00]                 │ debg TestSubjects.find(goToHost)
[00:24:00]                 │ debg Find.findByCssSelector('[data-test-subj="goToHost"]') with timeout=10000
[00:24:00]                 │ debg TestSubjects.click(goToDocker)
[00:24:00]                 │ debg Find.clickByCssSelector('[data-test-subj="goToDocker"]') with timeout=10000
[00:24:00]                 │ debg Find.findByCssSelector('[data-test-subj="goToDocker"]') with timeout=10000
[00:24:01]                 │ info Taking screenshot "/dev/shm/workspace/parallel/3/kibana/x-pack/test/functional/screenshots/failure/InfraOps app Home page with metrics present records telemetry for docker.png"
[00:24:01]                 │ info Current URL is: http://localhost:6131/app/metrics/inventory?waffleFilter=(expression%3A''%2Ckind%3Akuery)&waffleOptions=(accountId%3A''%2CautoBounds%3A!t%2CboundsOverride%3A(max%3A1%2Cmin%3A0)%2CcustomMetrics%3A!()%2CcustomOptions%3A!()%2CgroupBy%3A!()%2Clegend%3A(palette%3Acool%2CreverseColors%3A!f%2Csteps%3A10)%2Cmetric%3A(type%3Acpu)%2CnodeType%3Acontainer%2Cregion%3A''%2Csort%3A(by%3Aname%2Cdirection%3Adesc)%2Cview%3Amap)&waffleTime=(currentTime%3A1539806283000%2CisAutoReloading%3A!f)
[00:24:01]                 │ info Saving page source to: /dev/shm/workspace/parallel/3/kibana/x-pack/test/functional/failure_debug/html/InfraOps app Home page with metrics present records telemetry for docker.html
[00:24:01]                 └- ✖ fail: InfraOps app Home page with metrics present records telemetry for docker
[00:24:01]                 │      Error: expected 0 to be above 0
[00:24:01]                 │       at Assertion.assert (/dev/shm/workspace/parallel/3/kibana/packages/kbn-expect/expect.js:100:11)
[00:24:01]                 │       at Assertion.greaterThan.Assertion.above (/dev/shm/workspace/parallel/3/kibana/packages/kbn-expect/expect.js:317:8)
[00:24:01]                 │       at Function.greaterThan (/dev/shm/workspace/parallel/3/kibana/packages/kbn-expect/expect.js:531:15)
[00:24:01]                 │       at Context.it (test/functional/apps/infra/home_page.ts:101:17)
[00:24:01]                 │ 
[00:24:01]                 │ 

Stack Trace

Error: expected 0 to be above 0
    at Assertion.assert (/dev/shm/workspace/parallel/3/kibana/packages/kbn-expect/expect.js:100:11)
    at Assertion.greaterThan.Assertion.above (/dev/shm/workspace/parallel/3/kibana/packages/kbn-expect/expect.js:317:8)
    at Function.greaterThan (/dev/shm/workspace/parallel/3/kibana/packages/kbn-expect/expect.js:531:15)
    at Context.it (test/functional/apps/infra/home_page.ts:101:17)

Build metrics

✅ unchanged

History

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

@cee-chen cee-chen merged commit 641a5ad into elastic:master Aug 28, 2020
@cee-chen cee-chen deleted the enterprise-search-request-handler branch August 28, 2020 15:39
cee-chen pushed a commit that referenced this pull request Aug 28, 2020
…xisting routes to use shared handler (#76106) (#76232)

* Refactor enterprise_search_request_handler to a class that stores config/log

- So that routes don't have to continuously pass it in - just params that actually change (paths, queries)

+ misc refactors/lint fixes from code review

* Update mocks/dependencies so other tests pass type checks

* Update /api/workplace_search/overview endpoint to use new request handler

* Update /api/app_search/engines route to use new handler

- This required updating the shared handler to accept custom params set by the route, since the engines route transmutes some param names
- createRequest mock also had to be updated to correctly reflect a curried function in order to get tests passing

* DRY out hasValidData to a reusable/cleaner call

* Update shared handler to output specific message for auth errors

- Check for /login URL (indicates auth issue)
- Refactor final catch return to allow being passed messages from previous throw
- Change hasValidData fallback to only log (potentially sensitive?) JSON data to server, not to client
- Minor test cleanup - move error tests to single describe block, minor URL/newline cleanup

* Update handler to pass method & body requests + pass back response code

- This will support future POST requests as well as support (e.g.) 404 responses

Minor test refactors:
- Set up new request defaults (method, empty body) + expected output & convert KibanaAuthHeader to string since they're set so close to one another
- group request pass tests into a describe block, remove response body portion of their tests (since we don't really care about that for those tests)
- group response tests into describe block
- clarify how passed handler params arg overrides request.params

* PR feedback: Update custom params arg to take an object instead of a query string
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 31, 2020
…s-for-710

* 'master' of github.com:elastic/kibana: (43 commits)
  [APM] Chart units don't update when toggling the chart legends (elastic#74931)
  [ILM] Add support for frozen phase in UI (elastic#75968)
  Hides advanced json for count metric (elastic#74636)
  add client-side feature usage API (elastic#75486)
  [Maps] add drilldown support map embeddable (elastic#75598)
  [Enterprise Search] Request handler refactors/enhancements + update existing routes to use shared handler (elastic#76106)
  [Resolver] model `location.search` in redux (elastic#76140)
  [APM] Prevent imports of public in server code (elastic#75979)
  fix eslint issue
  skip flaky suite (elastic#76223)
  [APM] Transaction duration anomaly alerting integration (elastic#75719)
  [Transforms] Avoid using "Are you sure" (elastic#75932)
  [Security Solution][Exceptions] - Fix bug of alerts not updating after closure from exceptions modal (elastic#76145)
  [plugin-helpers] improve 3rd party KP plugin support (elastic#75019)
  [docs/getting-started] link to yarn v1 specifically (elastic#76169)
  [Security_Solution][Resolver] Resolver loading and error state (elastic#75600)
  Fixes App Search documentation links (elastic#76133)
  Fix alerts unable to create / update when the name has trailing whitepace(s) (elastic#76079)
  [Resolver] Fix useSelector usage (elastic#76129)
  [Enterprise Search] Migrate util and components from ent-search (elastic#76051)
  ...

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/node_allocation.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/services/policies/types.ts
#	x-pack/plugins/index_lifecycle_management/public/application/services/policies/warm_phase.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes v7.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants