Skip to content
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

[8.15] Use deprecation logger for CLDR date format specifiers (#112917) #113190

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/reference/cat/component-templates.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

[IMPORTANT]
====
cat APIs are only intended for human consumption using the command line or {kib}
console. They are _not_ intended for use by applications. For application
cat APIs are only intended for human consumption using the command line or {kib}
console. They are _not_ intended for use by applications. For application
consumption, use the <<getting-component-templates,get component template API>>.
====

Expand Down Expand Up @@ -82,8 +82,7 @@ PUT _component_template/my-template-2
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/reference/esql/esql-rest.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ POST /_query
}
----
// TEST[setup:library]
// TEST[skip:This can output a warning, and asciidoc doesn't support allowed_warnings]

[discrete]
[[esql-rest-params]]
Expand Down
3 changes: 1 addition & 2 deletions docs/reference/indices/index-templates.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ PUT _index_template/template_1
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
},
Expand Down
3 changes: 1 addition & 2 deletions docs/reference/indices/put-component-template.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ PUT _component_template/template_1
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
}
Expand Down
13 changes: 6 additions & 7 deletions docs/reference/indices/put-index-template-v1.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<titleabbrev>Create or update index template (legacy)</titleabbrev>
++++

IMPORTANT: This documentation is about legacy index templates,
which are deprecated and will be replaced by the composable templates introduced in {es} 7.8.
IMPORTANT: This documentation is about legacy index templates,
which are deprecated and will be replaced by the composable templates introduced in {es} 7.8.
For information about composable templates, see <<index-templates>>.

Creates or updates an index template.
Expand All @@ -27,8 +27,7 @@ PUT _template/template_1
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
}
Expand Down Expand Up @@ -67,8 +66,8 @@ that you can automatically apply when creating new indices.
{es} applies templates to new indices
based on an index pattern that matches the index name.

NOTE: Composable templates always take precedence over legacy templates.
If no composable template matches a new index,
NOTE: Composable templates always take precedence over legacy templates.
If no composable template matches a new index,
matching legacy templates are applied according to their order.

Index templates are only applied during index creation.
Expand Down Expand Up @@ -263,4 +262,4 @@ The API returns the following response:
"version" : 123
}
}
--------------------------------------------------
--------------------------------------------------
23 changes: 11 additions & 12 deletions docs/reference/indices/simulate-template.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ PUT _index_template/template_1
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
},
Expand Down Expand Up @@ -74,19 +73,19 @@ privilege>> to use this API.
`<index-template>`::
(Optional, string)
Name of the index template to simulate.
To test a template configuration before you add it to the cluster,
To test a template configuration before you add it to the cluster,
omit this parameter and specify the template configuration in the request body.

[[simulate-template-api-query-params]]
==== {api-query-parms-title}
////
`cause`::
(Optional, string) The reason for using the specified template for the simulation.
(Optional, string) The reason for using the specified template for the simulation.
////

`create`::
(Optional, Boolean) If `true`, the template passed in the body is
only used if no existing templates match the same index patterns.
(Optional, Boolean) If `true`, the template passed in the body is
only used if no existing templates match the same index patterns.
If `false`, the simulation uses the template with the highest priority.
Note that the template is not permanently added or updated in either case;
it is only used for the simulation.
Expand Down Expand Up @@ -114,7 +113,7 @@ include::{es-ref-dir}/indices/put-index-template.asciidoc[tag=index-template-api
.Properties of `overlapping`
[%collapsible%open]
====
`index_patterns`::
`index_patterns`::
(array) Index patterns that the superseded template applies to.

`name`::
Expand All @@ -123,7 +122,7 @@ include::{es-ref-dir}/indices/put-index-template.asciidoc[tag=index-template-api

`template`::
(object)
The settings, mappings, and aliases that would be applied to matching indices.
The settings, mappings, and aliases that would be applied to matching indices.
+
.Properties of `template`
[%collapsible%open]
Expand Down Expand Up @@ -227,8 +226,8 @@ The response shows the index settings, mappings, and aliases applied by the `fin
[[simulate-template-config-ex]]
===== Simulating an arbitrary template configuration

To see what settings will be applied by a template before you add it to the cluster,
you can pass a template configuration in the request body.
To see what settings will be applied by a template before you add it to the cluster,
you can pass a template configuration in the request body.
The specified template is used for the simulation if it has a higher priority than existing templates.

[source,console]
Expand Down Expand Up @@ -266,8 +265,8 @@ The response shows any overlapping templates with a lower priority.
}
},
"mappings" : {
"properties" : {
"@timestamp" : {
"properties" : {
"@timestamp" : {
"type" : "date"
}
}
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/ingest/common-log-format-example.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Pipelines**.
image::images/ingest/ingest-pipeline-list.png[Kibana's Ingest Pipelines list view,align="center"]

. Click **Create pipeline > New pipeline**.
. Set **Name** to `my-pipeline` and optionally add a description for the
. Set **Name** to `my-pipeline` and optionally add a description for the
pipeline.
. Add a <<grok-processor,grok processor>> to parse the log message:

Expand Down Expand Up @@ -128,6 +128,7 @@ PUT _ingest/pipeline/my-pipeline
// end::common-log-pipeline[]
}
----
// TEST[skip:This can output a warning, and asciidoc doesn't support allowed_warnings]
////
--

Expand Down
14 changes: 14 additions & 0 deletions modules/ingest-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ tasks.named("thirdPartyAudit").configure {
)
}

tasks.named("yamlRestTest").configure {
systemProperty 'tests.rest.blacklist', [
// for some reason, allowed_warnings on the test isn't working here
'ingest/30_date_processor/Test date processor with no timezone configured',
].join(',')
}

tasks.named("yamlRestTestV7CompatTest").configure {
systemProperty 'tests.rest.blacklist', [
// for some reason, allowed_warnings on the test isn't working here
'ingest/30_date_processor/Test date processor with no timezone configured',
].join(',')
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->
task.addAllowedWarningRegex("\\[types removal\\].*")
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
setup:
- requires:
test_runner_features: allowed_warnings
---
teardown:
- do:
Expand Down Expand Up @@ -97,6 +100,8 @@ teardown:
"Test date processor with no timezone configured":

- do:
allowed_warnings:
- 'Date format [dd/MMM/yyyy:H:m:s Z] contains textual field specifiers that could change in JDK 23'
ingest.put_pipeline:
id: "my_pipeline"
# sample formats from beats, featuring mongodb, icinga, apache
Expand Down Expand Up @@ -165,6 +170,8 @@ teardown:
- match: { acknowledged: true }

- do:
allowed_warnings:
- 'Date format [dd/MMM/yyyy:H:m:s Z] contains textual field specifiers that could change in JDK 23'
index:
index: test
id: "1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
setup:
- requires:
test_runner_features: allowed_warnings
---
"Test with date processor":
- do:
allowed_warnings:
- 'Date format [dd/MMM/yyyy:HH:mm:ss xx] contains textual field specifiers that could change in JDK 23'
ingest.put_pipeline:
id: "_id"
body: >
Expand Down Expand Up @@ -41,6 +46,8 @@
- match: { acknowledged: true }

- do:
allowed_warnings:
- 'Date format [dd/MMM/yyyy:HH:mm:ss xx] contains textual field specifiers that could change in JDK 23'
index:
index: test
id: "1"
Expand Down Expand Up @@ -70,6 +77,8 @@
---
"Test with date processor and ECS-v1":
- do:
allowed_warnings:
- 'Date format [dd/MMM/yyyy:HH:mm:ss xx] contains textual field specifiers that could change in JDK 23'
ingest.put_pipeline:
id: "_id"
body: >
Expand Down Expand Up @@ -99,6 +108,8 @@
- match: { acknowledged: true }

- do:
allowed_warnings:
- 'Date format [dd/MMM/yyyy:HH:mm:ss xx] contains textual field specifiers that could change in JDK 23'
index:
index: test
id: "1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
setup:
- requires:
test_runner_features: allowed_warnings
---
"Test Index and Search locale dependent mappings / dates":
- do:
allowed_warnings:
- 'Date format [E, d MMM yyyy HH:mm:ss Z] contains textual field specifiers that could change in JDK 23'
indices.create:
index: test_index
body:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ public class ComponentTemplatesFileSettingsIT extends ESIntegTestCase {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
},
Expand Down Expand Up @@ -159,8 +158,7 @@ public class ComponentTemplatesFileSettingsIT extends ESIntegTestCase {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
},
Expand Down Expand Up @@ -190,8 +188,7 @@ public class ComponentTemplatesFileSettingsIT extends ESIntegTestCase {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
},
Expand Down Expand Up @@ -259,8 +256,7 @@ public class ComponentTemplatesFileSettingsIT extends ESIntegTestCase {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
},
Expand Down Expand Up @@ -290,8 +286,7 @@ public class ComponentTemplatesFileSettingsIT extends ESIntegTestCase {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
},
Expand Down Expand Up @@ -335,8 +330,7 @@ public class ComponentTemplatesFileSettingsIT extends ESIntegTestCase {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
},
Expand Down Expand Up @@ -662,8 +656,7 @@ private TransportPutComposableIndexTemplateAction.Request sampleIndexTemplateRes
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
},
Expand Down Expand Up @@ -704,8 +697,7 @@ private TransportPutComposableIndexTemplateAction.Request sampleIndexTemplateRes
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
"type": "date"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.core.Predicates;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.logging.LogManager;

import java.time.Clock;
import java.time.Duration;
Expand Down Expand Up @@ -391,13 +390,17 @@ public static ZonedDateTime nowWithMillisResolution(Clock clock) {
// check for all textual fields, and localized zone offset
// the weird thing with Z is to ONLY match 4 in a row, with no Z before or after (but those groups can also be empty)
private static final Predicate<String> CONTAINS_CHANGING_TEXT_SPECIFIERS = System.getProperty("java.locale.providers", "")
.contains("COMPAT") ? Pattern.compile("[BEGOavz]|LLL|MMM|QQQ|ccc|eee|(?<!Z)Z{4}(?!Z)").asPredicate() : Predicates.never();
.contains("COMPAT") ? Pattern.compile("[BEGOavz]|LLL|MMM|QQQ|qqq|ccc|eee|(?<!Z)Z{4}(?!Z)").asPredicate() : Predicates.never();

@UpdateForV9 // this can be removed, we will only use CLDR on v9
static void checkTextualDateFormats(String format) {
if (CONTAINS_CHANGING_TEXT_SPECIFIERS.test(format)) {
LogManager.getLogger(DateFormatter.class)
.warn("Date format [{}] contains textual field specifiers that could change in JDK 23", format);
deprecationLogger.warn(
DeprecationCategory.PARSING,
"cldr_date_formats_" + format,
"Date format [{}] contains textual field specifiers that could change in JDK 23",
format
);
}
}
}
Loading