-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Make Watch transport actions project-aware #129612
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
base: main
Are you sure you want to change the base?
Make Watch transport actions project-aware #129612
Conversation
Pinging @elastic/es-data-management (Team:Data Management) |
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.
LGTM with some minor comments
@@ -37,6 +38,7 @@ public class TransportGetWatcherSettingsAction extends TransportLocalClusterStat | |||
GetWatcherSettingsAction.Response> { | |||
|
|||
private final IndexNameExpressionResolver indexNameExpressionResolver; | |||
private final ProjectResolver projectResolver; |
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.
You can make this class extend TransportLocalProjectMetadataAction
instead of storing the field here.
@@ -73,7 +77,7 @@ public ClusterState execute(ClusterState clusterState) { | |||
XPackPlugin.checkReadyForXPackCustomMetadata(clusterState); | |||
|
|||
WatcherMetadata newWatcherMetadata = new WatcherMetadata(manuallyStopped); | |||
final var project = clusterState.metadata().getProject(); | |||
final var project = clusterState.metadata().getProject(projectResolver.getProjectId()); |
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.
Super small nit:
final var project = clusterState.metadata().getProject(projectResolver.getProjectId()); | |
final var project = projectResolver.getProjectMetadata(clusterState); |
when(clusterState.getMetadata()).thenReturn(Metadata.EMPTY_METADATA); | ||
when(clusterService.state()).thenReturn(clusterState); | ||
when(clusterState.metadata()).thenReturn(Metadata.builder().put(ProjectMetadata.builder(projectId).build()).build()); |
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.
Can we avoid returning two different metadata objects to avoid confusion? Ideally, we'd align the production code to only use one of the two getter methods (metadata()
being the preference), but if that results in a very large number of changes, I'm also ok with leaving that part.
Make Watcher transport actions project-aware.