-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Record whether data streams for logs-*-* exist for logsdb enablement in 9.x #120708
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
Conversation
Add LogsPatternUsageService that records whether there are data streams matching with logs-*-* pattern. This is recorded via logsdb.prior_logs_usage cluster setting. Upon upgrade to 9.x this can be used to determine whether logsdb should be enabled by default if cluster.logsdb.enabled hasn't been set.
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
| import java.util.function.Supplier; | ||
|
|
||
| /** | ||
| * A component that check in the background whether there are data streams that match log-*-* pattern and if so records this as persistent |
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: checks*
|
|
||
| /** | ||
| * A component that check in the background whether there are data streams that match log-*-* pattern and if so records this as persistent | ||
| * setting in cluster state. If logs-*-* data stream usage has been found then this component will no longer in the background. |
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: no longer run
0486afe to
85f1c6b
Compare
|
|
||
| var clusterService = services.clusterService(); | ||
| Supplier<Metadata> metadataSupplier = () -> clusterService.state().metadata(); | ||
| var historicLogsUsageService = new LogsPatternUsageService(services.client(), settings, services.threadPool(), metadataSupplier); |
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.
Consider initializing in the constructor and calling an init function here, similar to LogsdbIndexModeSettingsProvider.
| Supplier<Metadata> metadataSupplier = () -> clusterService.state().metadata(); | ||
| var historicLogsUsageService = new LogsPatternUsageService(services.client(), settings, services.threadPool(), metadataSupplier); | ||
| clusterService.addLocalNodeMasterListener(historicLogsUsageService); | ||
| clusterService.addLifecycleListener(new LifecycleListener() { |
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.
Add a function in LogsPatternUsageService to construct and return a listener?
| */ | ||
| final class LogsPatternUsageService implements LocalNodeMasterListener { | ||
|
|
||
| private static final String LOGS_PATTERN = "logs-*-*"; |
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.
Deduplicate with LogsdbIndexModeSettingsProvider.LOGS_PATTERN ?
| private static final Logger LOGGER = LogManager.getLogger(LogsPatternUsageService.class); | ||
| static final Setting<TimeValue> USAGE_CHECK_PERIOD = Setting.timeSetting( | ||
| "logsdb.usage_check.period", | ||
| new TimeValue(24, TimeUnit.HOURS), |
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.
Consider adding a comment explaining how this value is picked.
| new TimeValue(24, TimeUnit.HOURS), | ||
| Setting.Property.NodeScope | ||
| ); | ||
| static final Setting<Boolean> LOGSDB_PRIOR_LOGS_USAGE = Setting.boolSetting( |
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.
Do we want to restrict this as internal? Or, maybe allow updates in case we get it wrong?
At any rate, let's document expectations.
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.
Only index settings can be made internal/private. Not node/ cluster settings.
I think we shouldn't document this setting. If someone sets this setting, then they might just as well configure cluster.logsdb.enabled? The advantage of this being public, is that for debugging purposes we can see that a 8.18 cluster is the right state to upgrade.
I will add a comment on top of this setting constant.
| } | ||
|
|
||
| void scheduleNext(TimeValue waitTime) { | ||
| if (isMaster && hasPriorLogsUsage == false) { |
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.
So, if the master changes, we may miss an update in 24h? Worth documenting, though this seems fine.
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 updated this wait time logic a bit via this commit: e0a5c11
| .actionGet(); | ||
| assertThat(response.persistentSettings().get("logsdb.prior_logs_usage"), equalTo("true")); | ||
| }); | ||
| } |
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.
Add a test for a non-matching pattern?
Also, is it possible to test that it only applies to master and it no longer runs after setting to true?
kkrik-es
left a comment
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.
Looks good, just a few minor comments.
…elected. Changed `logsdb.usage_check.period` to `logsdb.usage_check.max_period` and starting to check 60s after node has been elected as master. This gets doubled after each check that doesn't see any log-*-* usage upto `logsdb.usage_check.max_period` (defaults to 24h)
| assertThat(indexResponse.getResult(), equalTo(DocWriteResponse.Result.CREATED)); | ||
|
|
||
| ensureGreen("log-myapp-prod"); | ||
| assertBusy(() -> { |
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.
In fairness, add a short sleep() to give time for the usage service to run?
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.
Good point. I did this which is better than a thread.sleep() :572d670010d88ff1f1639197fe18fec7544ddf88
|
@elasticmachine update branch |
|
@elasticmachine update branch |
💔 Backport failed
You can use sqren/backport to manually backport by running |
…in 9.x (elastic#120708) Add LogsPatternUsageService that records whether there are data streams matching with logs-*-* pattern. This is recorded via the new logsdb.prior_logs_usage cluster setting. Upon upgrade to 9.x this can be used to determine whether logsdb should be enabled by default if cluster.logsdb.enabled hasn't been set. The recommended upgrade path to 9.x is always to go to 8.latest. This component will run in clusters with version greater than 8.18.0 but not on 9.0 and newer.
…ement in 9.x (#121025) Backporting #120708 to 8.x branch. Add LogsPatternUsageService that records whether there are data streams matching with logs-*-* pattern. This is recorded via the new logsdb.prior_logs_usage cluster setting. Upon upgrade to 9.x this can be used to determine whether logsdb should be enabled by default if cluster.logsdb.enabled hasn't been set. The recommended upgrade path to 9.x is always to go to 8.latest. This component will run in clusters with version greater than 8.18.0 but not on 9.0 and newer.
Enable logsdb by default if logsdb.prior_logs_usage has not been set to true. Meaning that if no data streams were created matching with the logs-- pattern in 8.x, then logsdb will be enabled by default for data streams matching with logs-*-* pattern. Also removes LogsPatternUsageService as with version 9.0 and beyond, this component is no longer necessary. Followup from #120708 Closes #106489
Add LogsPatternUsageService that records whether there are data streams matching with
logs-*-*pattern. This is recorded via the newlogsdb.prior_logs_usagecluster setting. Upon upgrade to 9.x this can be used to determine whether logsdb should be enabled by default if cluster.logsdb.enabled hasn't been set.The recommended upgrade path to 9.x is always to go to 8.latest. This component will run in clusters with version greater than 8.18.0 but not on 9.0 and newer.
Note that a follow change is required that removes / disables
LogsPatternUsageServicein main. Additionally updating the default of theLogsDBPlugin.CLUSTER_LOGSDB_ENABLEDsetting: