-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Move CCR out of legacy #62890
Move CCR out of legacy #62890
Conversation
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
46405cb
to
7beacfb
Compare
6313a9c
to
12a3bb5
Compare
be75026
to
77ffce5
Compare
c0f8311
to
e53aa4f
Compare
- Remove deserializeAutoFollowPattern behavior that returned an empty object if the pattern was undefined.
- Localize mocks with the component integration tests.
- Remove security dependency. - Render timestamp for autofollow errors. - Fix license check so that CCR won't render if the license is invalid. - Fix server security check to be more precise by checking if ES has security disabled.
aebaae9
to
1daf9ad
Compare
@elasticmachine merge upstream |
Just a note: I don't think the test plan in Testrail has all the usecases mentioned in this PR description. Back to our conversation from last week, we should have a matrix of what can and what cannot be automated. The "Security" part will have to be manual for sure. But almost all the rest could/should be automated. e.g.
We just automated the "Missing entities" part of the testing. cc @cuff-links |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @cjcenizal , thanks for cleaning up the server side code!
Most of my comments do not need to be blocked on, however;
- I would highly recommend make the setup functions synchronous however, this is something we will have to do in the future at any rate.
- Would you mind answering my q's below before I approve?
Running through your tests I noted the following:
Auto-follow patterns
Open the details flyout of one of the auto-follow patterns and verify there is a list of recent errors.
I was not able to see the recent errors you mentioned here 👆🏻. Probably a user error on my part. I did create a follower index before testing this, would that have affected it? Would appreciate you confirming this
Partial errors
...danger toast should appear notifying you there was an error with the one you deleted.
I saw a success notification after performing the bulk update here (not the error notification I expected)
DOC_LINK_VERSION: string; | ||
}): Promise<UnmountCallback> { | ||
// Initialize additional services. | ||
initBreadcrumbs(setBreadcrumbs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency across our plugins, could we move these init
calls to the plugin.setup
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved them here based on guidance in #62487 (comment). The gist that I got was that we should try to exclude as many imports from the main bundle as possible, to reduce its size. I'll add a comment to the code to clarify this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I see what you're saying. I think the merit (in KB) of importing here vs. plugin is very small. But we can leave as is for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! It's negligible. But it's also a negligible effort on my part, and the difference in readability isn't worth a debate IMO. :)
initUiMetric(usageCollection); | ||
initNotification(toasts, fatalErrors); | ||
|
||
management.sections.getSection('elasticsearch')!.registerApp({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep all registration functionality synchronous. See x-pack/plugins/watcher/public/plugin.ts
for an instance of using license but keeping registration sync.
}, | ||
}); | ||
|
||
// The UI is also dependent upon the Remote Clusters UI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow this comment, I'm guessing we needed to add Remote Clusters UI config setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The remote_clusters.ui.enabled
config setting is what drives the value remoteClusters.isUiEnabled
. It sounds like that's not clear? My intention for this comment was to explain that we care about this setting's value because the actual CCR UI cross-links to the Remote Clusters UI, so it won't function without it. I will add these details to the comment but let me know if there's anything else that isn't clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, I understand now - user error :)
{ licensing, indexManagement, remoteClusters }: Dependencies | ||
): Promise<void> { | ||
const router = http.createRouter(); | ||
const config = await this.config$.pipe(first()).toPromise(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can update this to this.config$.pipe(first()).toPromise().then(() => /* do the things */)
to keep setup synchronous
const mockRouteContext = ({ | ||
crossClusterReplication: { | ||
client: { | ||
callAsCurrentUser: jest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit; this seems like a pattern that would benefit from being slightly more terse by creating a helper for creating the route context.
}, | ||
}, | ||
license.guardApiRoute(async (context, request, response) => { | ||
const { id } = request.params as typeof paramsSchema.type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit; the license guardApiRoute
is missing the <P, Q, B>
type annotation. See x-pack/plugins/painless_lab/server/services/license.ts
. Then we can remove all of the as typeof
declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit 2: I personally think it is easier to read like this. I agree there are a few more chars (as typeof
), but the overall handler is easier to parse for me at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I think there are a few issues with using the as
keyword (verbosity is one of them, another being taking on the work of the type system - which can lead to unintended side effects). I would really recommend not using unless necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you both for your input here. I think the connection between request.params
and paramsSchema
is not too hard to make, considering we define params: paramsSchema
in the validation config a few lines above. So I'm going to go ahead and apply JL's suggestion.
export interface RouteDependencies { | ||
router: IRouter; | ||
license: License; | ||
lib: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the index.scss
being imported anywhere. Maybe the styles aren't all that necessary? Or you need to import it inside plugin.ts
@elasticmachine merge upstream |
- Import and use History type. - Make public and server plugin setup functions synchronous. - Add comments to explain role of remote_clusters.ui.enabled setting and purpose for initializing services inside of the app mount function.
@cchaos @jloleysens I've addressed your feedback. Could you please take another look? Caroline, I ended up removing the styles. |
Auto-follow patternsSorry, I should have clarified in the instructions that you need to index the document in the remote cluster after setting up the auto-follow patterns, since they won't capture existing documents. I just tested locally and verified. I also updated the instructions. Partial errorsCan you confirm that you were attempting to delete a non-existing follower index? I.e., one that you had already deleted via Index Management or Console? Also, there is a 30 second refresh interval which you might be racing against. If this interval triggers a refresh, the list will refresh and it might appear as if there was no error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Awesome. Deletions are always good :)
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates to the PR description (as Seb mentioned, definitely a good source of testing information when we review our current automated vs. manual testing).
I trust you have tested the two points I had questions about, and am happy this contribution to be merged.
DOC_LINK_VERSION: string; | ||
}): Promise<UnmountCallback> { | ||
// Initialize additional services. | ||
initBreadcrumbs(setBreadcrumbs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I see what you're saying. I think the merit (in KB) of importing here vs. plugin is very small. But we can leave as is for now
}, | ||
}); | ||
|
||
// The UI is also dependent upon the Remote Clusters UI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, I understand now - user error :)
Totally! I've shared this PR with @cuff-links and he'll update TestRail with the testing information. |
* Convert common/services and server/lib to TypeScript. Update Jest tests. - Remove deserializeAutoFollowPattern behavior that returned an empty object if the pattern was undefined. * Localize mocks with the component integration tests. * Update API unit tests to use NP mocks. - Break up test files. - Use inline mocked ES response instead of fixture files. - Move remaining fixture files into client integration tests directory. * Make API route validation more strict. * Publish isUiDisabled as part of Remote Clusters contract. * Default trackUiMetric service to be a no-op. * Remove security dependency. - Fix license check so that CCR won't render if the license is invalid. - Fix server security check to be more precise by checking if ES has security disabled. * Render timestamp for autofollow errors.
* Convert common/services and server/lib to TypeScript. Update Jest tests. - Remove deserializeAutoFollowPattern behavior that returned an empty object if the pattern was undefined. * Localize mocks with the component integration tests. * Update API unit tests to use NP mocks. - Break up test files. - Use inline mocked ES response instead of fixture files. - Move remaining fixture files into client integration tests directory. * Make API route validation more strict. * Publish isUiDisabled as part of Remote Clusters contract. * Default trackUiMetric service to be a no-op. * Remove security dependency. - Fix license check so that CCR won't render if the license is invalid. - Fix server security check to be more precise by checking if ES has security disabled. * Render timestamp for autofollow errors.
Other changes
Reviewing
Reviewing each commit individually might be easier than reviewing the end result. I tried to make each one as atomic as possible, but there may be some slight overlap as I ended up catching and fixing some errors in the later commits.
Testing
Setup
You can run a local cluster and simulate a remote cluster within a single Kibana directory.
yarn es snapshot --license=trial
and kill the process once the snapshot has been installed.cp -aR .es/8.0.0 .es/8.0.0-2
..es/8.0.0/bin/elasticsearch
and starting Kibana..es/8.0.0-2/bin/elasticsearch -E cluster.name=europe -E transport.port=9400
.curl -X PUT http://elastic:changeme@localhost:9201/my-leader-index --data '{"settings":{"number_of_shards":1,"soft_deletes.enabled":true}}' --header "Content-Type: application/json"
. Note that these settings are required for testing auto-follow pattern conflicts errors (see below).Now you can create follower indices and auto-follow patterns to replicate the
my-leader-index
index on the remote cluster that's available at127.0.0.1:9400
.Settings
With the above setting, verify that CCR isn't visible in the UI and you can't see a "Follower" badge next to follower indices in Index Management.
With the above setting, verify the same effect.
With the above setting, verify the same effect.
With the above setting, verify the same effect.
License
Permissions
Create a user with just a
kibana_user
role and verify that a permission error callout is shown (per #27273).Security
Disable security by setting
xpack.security.enabled: false
in the elastiscearch.yml file of your local cluster and ensure you can still access CCR (per #35333).Actions
Auto-follow pattern conflict errors
my*
andmy-*
) that will both capture themy-leader-index
index on your remote cluster.my-leader-index2
on your remote cluster, since auto-follow patterns don't replicate existing indices.Partial errors
Missing entities