use --fail flag without set -x, since elasticsearch can return a 404 on the template lookup

This commit is contained in:
reyesj2
2026-06-16 11:17:04 -05:00
parent 4456bde1c8
commit 3daed551df
+4 -8
View File
@@ -783,18 +783,14 @@ pin_elasticsearch_data_retention_method() {
# #
# Reference: https://github.com/elastic/kibana/issues/263048 # Reference: https://github.com/elastic/kibana/issues/263048
kibana_backport_streams_index_template() { kibana_backport_streams_index_template() {
local current_template updated_template current_template_exists local current_template updated_template
current_template_exists=$(so-elasticsearch-query "_index_template/.kibana_streams" -o /dev/null -w "%{http_code}") set +e
if [[ "$current_template_exists" == "404" ]]; then if ! current_template=$(so-elasticsearch-query "_index_template/.kibana_streams" --retry 3 --retry-delay 5 --fail); then
echo "Index template .kibana_streams does not exist, skipping backport." echo "Index template .kibana_streams does not exist, skipping backport."
return 0 return 0
fi fi
set -e
if ! current_template=$(so-elasticsearch-query "_index_template/.kibana_streams" --retry 3 --retry-delay 5 --fail); then
echo "Unable to retrieve .kibana_streams index template, skipping backport."
return 0
fi
updated_template=$(jq '.index_templates[0].index_template | .template.settings += {"index.auto_expand_replicas": "0-1"} | del(.created_date_millis, .modified_date_millis)' <<< "$current_template") updated_template=$(jq '.index_templates[0].index_template | .template.settings += {"index.auto_expand_replicas": "0-1"} | del(.created_date_millis, .modified_date_millis)' <<< "$current_template")