-
Notifications
You must be signed in to change notification settings - Fork 694
feat: Enable configurable priority for zeebe-record Index templates #36207
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
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.
Pull Request Overview
This PR adds configurable priority support for index templates in both Elasticsearch and OpenSearch exporters. It allows users to set custom priority values for Zeebe record index templates, providing better control over template precedence in environments with multiple index templates.
- Adds
priority
configuration field to both exporters with validation (>= 0) - Implements a mutable builder pattern for Template DTOs to enable safe modification
- Updates template readers to use the configured priority value when creating index templates
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
OpensearchExporterConfiguration.java |
Adds priority field with default value of 20 and getter/setter methods |
ElasticsearchExporterConfiguration.java |
Adds templatePriority field with default value of 20 and getter/setter methods |
OpensearchExporter.java |
Adds validation to ensure priority is non-negative |
ElasticsearchExporter.java |
Adds validation to ensure templatePriority is non-negative |
opensearch/.../dto/Template.java |
Implements MutableCopyBuilder pattern for safe template modification |
elasticsearch/.../dto/Template.java |
Implements MutableCopyBuilder pattern for safe template modification |
opensearch/.../TemplateReader.java |
Updates to use builder pattern and set priority from configuration |
elasticsearch/.../TemplateReader.java |
Updates to use builder pattern and set templatePriority from configuration |
OpensearchExporterTest.java |
Adds test for negative priority validation |
ElasticsearchExporterTest.java |
Adds test for negative templatePriority validation |
OpensearchExporterIT.java |
Adds integration tests for priority configuration and default behavior |
ElasticsearchExporterIT.java |
Adds integration tests for templatePriority configuration and default behavior |
Comments suppressed due to low confidence (3)
zeebe/exporters/opensearch-exporter/src/main/java/io/camunda/zeebe/exporter/opensearch/OpensearchExporterConfiguration.java:219
- The field name 'priority' is inconsistent with the Elasticsearch exporter which uses 'templatePriority'. For consistency between the two exporters, consider renaming this field to 'templatePriority'.
private int priority = DEFAULT_INDEX_TEMPLATE_PRIORITY;
zeebe/exporters/opensearch-exporter/src/main/java/io/camunda/zeebe/exporter/opensearch/OpensearchExporterConfiguration.java:237
- The method name 'getPriority' is inconsistent with the Elasticsearch exporter which uses 'getTemplatePriority'. For consistency between the two exporters, consider renaming this method to 'getTemplatePriority'.
public int getPriority() {
zeebe/exporters/opensearch-exporter/src/main/java/io/camunda/zeebe/exporter/opensearch/OpensearchExporterConfiguration.java:241
- The method name 'setPriority' is inconsistent with the Elasticsearch exporter which uses 'setTemplatePriority'. For consistency between the two exporters, consider renaming this method to 'setTemplatePriority'.
public void setPriority(final int priority) {
aliases.clear(); | ||
aliases.put(aliasName, Collections.emptyMap()); | ||
}) | ||
.withPriority(Long.valueOf(config.getPriority())) |
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.
Using Long.valueOf() for autoboxing is unnecessary. Since getPriority() returns an int, you can cast directly to long: (long) config.getPriority().
.withPriority(Long.valueOf(config.getPriority())) | |
.withPriority((long) config.getPriority()) |
Copilot uses AI. Check for mistakes.
aliases.clear(); | ||
aliases.put(aliasName, Collections.emptyMap()); | ||
}) | ||
.withPriority(Long.valueOf(config.index.getTemplatePriority())) |
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.
Using Long.valueOf() for autoboxing is unnecessary. Since getTemplatePriority() returns an int, you can cast directly to long: (long) config.index.getTemplatePriority().
.withPriority(Long.valueOf(config.index.getTemplatePriority())) | |
.withPriority((long) config.index.getTemplatePriority()) |
Copilot uses AI. Check for mistakes.
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.
Some small comments but generally LGTM 👍
...rch-exporter/src/main/java/io/camunda/zeebe/exporter/ElasticsearchExporterConfiguration.java
Show resolved
Hide resolved
...lasticsearch-exporter/src/test/java/io/camunda/zeebe/exporter/ElasticsearchExporterTest.java
Outdated
Show resolved
Hide resolved
...arch-exporter/src/test/java/io/camunda/zeebe/exporter/opensearch/OpensearchExporterTest.java
Outdated
Show resolved
Hide resolved
@@ -896,6 +896,7 @@ | |||
# | |||
# numberOfShards: 3 | |||
# numberOfReplicas: 0 | |||
# templatePriority: 100 |
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.
❓ should this not be the default of 20 then?
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.
this is just an example, like the number of shards above is not the default one
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.
interesting, I thought we always aimed to match these templates up to the default values. But all good, no big deal 👍
@@ -978,6 +979,7 @@ | |||
# | |||
# numberOfShards: 3 | |||
# numberOfReplicas: 0 | |||
# templatePriority: 100 |
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.
same as above
@@ -831,6 +832,7 @@ | |||
# | |||
# numberOfShards: 3 | |||
# numberOfReplicas: 0 | |||
# templatePriority: 100 |
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.
same as above in this file too
b13e769
to
71a40d3
Compare
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-36207-to-main
git worktree add --checkout .worktree/backport-36207-to-main backport-36207-to-main
cd .worktree/backport-36207-to-main
git reset --hard HEAD^
git cherry-pick -x 3816688dd321d5f68018e55bdb12f4d5bcb40352 42980cbaff84bfaae5b6598f2ecd86c090e30eec 71a40d3a2bb67e111baeedefce61a7d67230bb06
git push --force-with-lease |
Description
Adds a new property in Elasticsearch and Opensearch exporters configuration
zeebe.broker.exporters.elasticsearch.args.index.template-priority
zeebe.broker.exporters.opensearch.args.index.template-priority
This configuration is set in zeebe records index templates priority setting, and it defaults to 20 when the configuration is not provided. 20 being the hardcoded value that was part of the existing index templates.
Checklist
Related issues
closes #36084