* Instead of cloning, reindex legacy index
* Reindex for every v2 migration
* Use _reindex?require_alias=true and a write block toggle to prevent lost deletes
* Use a ..._reindex_in_progress alias so that waiting for and preventing other reindex operations is idempotent
The first version of the reindex block had only the instance which was able to mark the migration as complete
set and remove the write block. This means other instances couldn't know if any reindex operaitons were in
progress if the migration was already marked as complete. It also meant that a failure in this critical step
could result in a permanent write block.
* Revert "Use a ..._reindex_in_progress alias so that waiting for and preventing other reindex operations is idempotent"
This reverts commit 8baf9b13db.
* Revert "Use _reindex?require_alias=true and a write block toggle to prevent lost deletes"
This reverts commit d7237ca42c.
* Use reindex + clone as a way to prevent lost deletes
* Fix numbering and ignore index_not_found_exceptionfor temporary index
* Apply suggestions from code review
Co-authored-by: Josh Dover <me@joshdover.com>
Co-authored-by: Josh Dover <me@joshdover.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
The staging registry is used in Kibana builds which are not built of the master branch or release version. This means, any build ending with `-SNAPSHOT` not the master branch will use the staging registry.
Closes https://github.com/elastic/kibana/issues/90131
Co-authored-by: Jen Huang <its.jenetic@gmail.com>
We were incorrectly including records with is_interim: true in our
query, which lead to false positive signals if the rule executed while
an anomaly's score was (temporarily) above the specified threshold, but
then dipped below after it was finalized.
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [Maps] convert HeatmapLayer to TS
* make VectorLayer implement IVectorLayer
* fix jest test and functional test
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* add anomaly threshold configuration to settings
* hide panel if not ml capable
* send threshold value to query
* update license
* update api integration to expect anomalyThreshold to exist
* add some tests to the anomaly queries
* change type to number
* api validate in source update and config for anamolyThreshold and tests
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* Add import rules
- newlines between each group
- mocks in test files before everything else
- React before all other externals
* Run --fix on public/applications/workplace_search
* Manually fix errors still present in WS public files
- these appear to be mostly due to jest.mock() or const mixed in with imports, which confuses the autofixer
* Run --fix on public/applications/app_search
+ some manual fixes/tweaks along the way
* Run --fix on public/applications/shared
- some opinionated changes, particularly around IFlashMessages and grouping together types coming from Kibana (src->../../src)
* Run --fix on public/applications/enterprise_search
- mostly straightforward
* Run --fix on public/applications/__mocks__
* Fix remaining top-level public files
- Some opinionated changes (src/core -> ../../src/core) to keep types/mocks together
* Run --fix on server/ files
- same opinionated src->../src changes to keep deps grouped together
- opinionated require->import fetch change in enterprise_esarch_config_api.test.ts
- opinionated [] inclusion of builtins & external imports together (mostly for enterprise_search_request_handler.ts)
* remove rollover indicator on timeline and relative timing text
* simplify rollover description text
* remove non-existent export
* incorporate copy recommendations
* slight visual adjustment to timeline, infinity icon more subdued, moved icon to left
* update visual appearance of delete icon on timeline, grey circle and trash can
* remove tooltip next to recommended defaults
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [ML] Lazy ml node UI improvements
* fixing test
* adding awaitingMlNodeAllocation to default datafeed response
* changing datafeed icon when node is not assigned
* updating text
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [Maps] use chart pallete registry to support sync colors in dashboard
* pass getColor to createLayerInstance
* use chartsPaletteServiceGetColor to get categorical color
* revert changes to layer_actions
* tslint and jest test updates
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
## Summary
Add guard to `/agents/enroll` API preventing agents from enrolling in managed policies
closes#90435
- [x] No Agents can be enrolled into this policy by the user.
- [x] The install & enroll commands should print an error to the console if the enroll command fails (due to being a managed policy or any other reason)
#### So how do you associate an agent with a managed policy?
Enroll in an unmanaged policy then set that policy to managed.
We don't restrict the agent policy, only what other things (agents, integrations) can do if they're associated with a managed policy.
A _force flag_ has been mentioned for some other actions. It might work here as well, but I'd like to handle discussion & implementation of those later.
### Manual testing
<details><summary>Prevent enroll for managed policies</summary>
1. Created a managed agent policy
```
curl --user elastic:changeme -X POST localhost:5601/api/fleet/agent_policies -H 'Content-Type: application/json' -d'{ "name": "User created MANAGED", "namespace": "default", "is_managed": true}' -H 'kbn-xsrf: true'
{"item":{"id":"3bd07db0-67d0-11eb-b656-21ad68ebfa8a","name":"User created MANAGED","namespace":"default","is_managed":true,"revision":1,"updated_at":"2021-02-05T16:36:01.931Z","updated_by":"elastic"}}
```
2. Try `install` command show in the UI
```
sudo ./elastic-agent install -f --kibana-url=http://localhost:5601 --enrollment-token=WmcwTWMzY0IzWlBUUWJJUjZqRDA6UGRZelVlaS1STml1cVdjSUVwSkJRQQ== --insecure
Password:
The Elastic Agent is currently in BETA and should not be used in production
Error: fail to enroll: fail to execute request to Kibana: Status code: 400, Kibana returned an error: Bad Request, message: Cannot enroll in managed policy 3bd07db0-67d0-11eb-b656-21ad68ebfa8a
Error: enroll command failed with exit code: 1
```
3. Observe `Cannot enroll in managed policy 3bd07db0-67d0-11eb-b656-21ad68ebfa8a` error
4. Try `enroll` instead:
```
sudo ./elastic-agent enroll http://localhost:5601 WmcwTWMzY0IzWlBUUWJJUjZqRDA6UGRZelVlaS1STml1cVdjSUVwSkJRQQ== --insecure
The Elastic Agent is currently in BETA and should not be used in production
This will replace your current settings. Do you want to continue? [Y/n]:
Error: fail to enroll: fail to execute request to Kibana: Status code: 400, Kibana returned an error: Bad Request, message: Cannot enroll in managed policy 3bd07db0-67d0-11eb-b656-21ad68ebfa8a
```
5. Observe same `Cannot enroll in managed policy 3bd07db0-67d0-11eb-b656-21ad68ebfa8a` error
</details>
<details><summary>Enroll in unmanaged policy, then update it to managed</summary>
Agent policies are `is_managed: false` by default, or we can update the policy to `is_managed: false`, like:
```
curl --user elastic:changeme -X PUT localhost:5601/api/fleet/agent_policies/3bd07db0-67d0-11eb-b656-21ad68ebfa8a -H 'Content-Type: application/json' -d'{ "is_managed": false, "name": "xyz", "namespace": "default" }' -H 'kbn-xsrf: true'
{"item":{"id":"3bd07db0-67d0-11eb-b656-21ad68ebfa8a","name":"xyz","namespace":"default","is_managed":false,"revision":4,"updated_at":"2021-02-05T17:42:05.610Z","updated_by":"elastic","package_policies":[]}}
```
then enroll
```
sudo ./elastic-agent install -f --kibana-url=http://localhost:5601 --enrollment-token=WmcwTWMzY0IzWlBUUWJJUjZqRDA6UGRZelVlaS1STml1cVdjSUVwSkJRQQ== --insecure
The Elastic Agent is currently in BETA and should not be used in production
Successfully enrolled the Elastic Agent.
Installation was successful and Elastic Agent is running.
```
and set the policy back to managed
```
curl --user elastic:changeme -X PUT localhost:5601/api/fleet/agent_policies/3bd07db0-67d0-11eb-b656-21ad68ebfa8a -H 'Content-Type: application/json' -d'{ "is_managed": true, "name": "xyz", "namespace": "default" }' -H 'kbn-xsrf: true'
{"item":{"id":"3bd07db0-67d0-11eb-b656-21ad68ebfa8a","name":"xyz","namespace":"default","is_managed":true,"revision":5,"updated_at":"2021-02-05T17:44:18.757Z","updated_by":"elastic","package_policies":[]}}
```
with all the restrictions that entails (cannot unenroll, reassign, etc)
```
curl --user elastic:changeme -X PUT 'http://localhost:5601/api/fleet/agents/8169f0a0-67d9-11eb-80f2-73dd45e7318e/reassign' -X 'PUT' -H 'kbn-xsrf: abc' -H 'Content-Type: application/json' --data-raw '{"policy_id":"729f8440-67cf-11eb-b656-21ad68ebfa8a"}'
{
"statusCode": 400,
"error": "Bad Request",
"message": "Cannot reassign an agent from managed agent policy 3bd07db0-67d0-11eb-b656-21ad68ebfa8a"
}
```
</details>
### Checklist
- [x] [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
* Apply awaits to avoid unhandled errors
* catch and ignore tracking error
* added reject test for search service
* Improve search service api test coverage
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>