-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[RAC] Disable RAC multi-tenancy #108506
Merged
Kerry350
merged 5 commits into
elastic:master
from
Kerry350:108393-rac-turn-off-multi-tenancy
Aug 16, 2021
Merged
[RAC] Disable RAC multi-tenancy #108506
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
51170ac
Disable RAC multi-tenancy
Kerry350 a82ecf4
Amend index check
Kerry350 8486d7e
Amend tests / comments
Kerry350 d306974
Merge remote-tracking branch 'upstream/master' into 108393-rac-turn-o…
Kerry350 9043a9b
Merge remote-tracking branch 'upstream/master' into 108393-rac-turn-o…
Kerry350 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import { | |
KibanaRequest, | ||
CoreStart, | ||
IContextProvider, | ||
SharedGlobalConfig, | ||
} from 'src/core/server'; | ||
import { SecurityPluginSetup } from '../../security/server'; | ||
import { AlertsClientFactory } from './alert_data_client/alerts_client_factory'; | ||
|
@@ -20,7 +21,7 @@ import { RacApiRequestHandlerContext, RacRequestHandlerContext } from './types'; | |
import { defineRoutes } from './routes'; | ||
import { SpacesPluginStart } from '../../spaces/server'; | ||
|
||
import { RuleRegistryPluginConfig } from './config'; | ||
import { INDEX_PREFIX, RuleRegistryPluginConfig } from './config'; | ||
import { RuleDataPluginService } from './rule_data_plugin_service'; | ||
import { EventLogService, IEventLogService } from './event_log'; | ||
import { AlertsClient } from './alert_data_client/alerts_client'; | ||
|
@@ -53,6 +54,7 @@ export class RuleRegistryPlugin | |
RuleRegistryPluginStartDependencies | ||
> { | ||
private readonly config: RuleRegistryPluginConfig; | ||
private readonly legacyConfig: SharedGlobalConfig; | ||
private readonly logger: Logger; | ||
private eventLogService: EventLogService | null; | ||
private readonly alertsClientFactory: AlertsClientFactory; | ||
|
@@ -61,6 +63,8 @@ export class RuleRegistryPlugin | |
|
||
constructor(initContext: PluginInitializerContext) { | ||
this.config = initContext.config.get<RuleRegistryPluginConfig>(); | ||
// TODO: Can be removed in 8.0.0. Exists to work around multi-tenancy users. | ||
this.legacyConfig = initContext.config.legacy.get(); | ||
this.logger = initContext.logger.get(); | ||
this.eventLogService = null; | ||
this.ruleDataService = null; | ||
|
@@ -82,10 +86,25 @@ export class RuleRegistryPlugin | |
|
||
this.security = plugins.security; | ||
|
||
const isWriteEnabled = (config: RuleRegistryPluginConfig, legacyConfig: SharedGlobalConfig) => { | ||
const hasEnabledWrite = config.write.enabled; | ||
const hasSetCustomKibanaIndex = legacyConfig.kibana.index !== '.kibana'; | ||
const hasSetUnsafeAccess = config.unsafe.legacyMultiTenancy.enabled; | ||
|
||
if (!hasEnabledWrite) return false; | ||
|
||
// Not using legacy multi-tenancy | ||
if (!hasSetCustomKibanaIndex) { | ||
return hasEnabledWrite; | ||
} else { | ||
return hasSetUnsafeAccess; | ||
} | ||
Comment on lines
+90
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: maybe this could be easier to grasp (totally subjective) if (hasEnabledWrite) {
return hasSetCustomKibanaIndex ? hasSetUnsafeAccess : true;
}
return false; |
||
}; | ||
|
||
const service = new RuleDataPluginService({ | ||
logger: this.logger, | ||
isWriteEnabled: this.config.write.enabled, | ||
index: this.config.index, | ||
isWriteEnabled: isWriteEnabled(this.config, this.legacyConfig), | ||
index: INDEX_PREFIX, | ||
getClusterClient: async () => { | ||
const deps = await startDependencies; | ||
return deps.core.elasticsearch.client.asInternalUser; | ||
|
@@ -112,8 +131,8 @@ export class RuleRegistryPlugin | |
|
||
const eventLogService = new EventLogService({ | ||
config: { | ||
indexPrefix: this.config.index, | ||
isWriteEnabled: this.config.write.enabled, | ||
indexPrefix: INDEX_PREFIX, | ||
isWriteEnabled: isWriteEnabled(this.config, this.legacyConfig), | ||
}, | ||
dependencies: { | ||
clusterClient: startDependencies.then((deps) => deps.core.elasticsearch.client), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shall we change
xpack.ruleRegistry.write.enabled
totrue
by default 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.
It'll happen as part of #105237 and the "final wrap up" 👍