Skip to content

Backport PR #16365 to 8.15: [Bugfix] Resolve the array and char (single | double quote) escaped values of ${ENV}#16371

Merged
mashhurs merged 1 commit into8.15from
backport_16365_8.15
Aug 6, 2024
Merged

Backport PR #16365 to 8.15: [Bugfix] Resolve the array and char (single | double quote) escaped values of ${ENV}#16371
mashhurs merged 1 commit into8.15from
backport_16365_8.15

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Aug 6, 2024

Backport PR #16365 to 8.15 branch, original message:


Release notes

A bug (introduced in 8.13.1) fix to use array value with docker environment variables (such as XPACK_MANAGEMENT_PIPELINE_ID, XPACK_MANAGEMENT_ELASTICSEARCH_HOSTS).

What does this PR do?

Fixes the bug introduced by #16026. After 8.13.1, running Logstash on docker with list environment variable (example: -e XPACK_MANAGEMENT_ELASTICSEARCH_HOSTS='[es.host.1, es.host.2:9500]') doesn't work. Current change fixes this issue.

Why is it important/What is the impact to the user?

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • [ ]

How to test this PR locally

  • run rake artifact:docker to build docker image

  • use the hash value created by rake and replace b6c644b81357d29d9ae30b788fad327ece26d363c3541e566c543dc9dc084874 with your hash value

  • ENV var carries list:

docker run --rm --name=local-ls-docker -p 9600:9600 -e API_ENABLED=true -e XPACK_MANAGEMENT_ENABLED=true -e XPACK_MANAGEMENT_PIPELINE_ID="['*']" -e XPACK_MANAGEMENT_ELASTICSEARCH_HOSTS="['https://es1:9200', 'https://es2:9200']" -e XPACK_MONITORING_ENABLED=false sha256:b6c644b81357d29d9ae30b788fad327ece26d363c3541e566c543dc9dc084874

docker run --rm --name=local-ls-docker -p 9600:9600 -e API_ENABLED=true -e XPACK_MANAGEMENT_ENABLED=true -e XPACK_MANAGEMENT_PIPELINE_ID='["*"]' -e XPACK_MANAGEMENT_ELASTICSEARCH_HOSTS='["https://es1:9200", "https://es2:9200"]' -e XPACK_MONITORING_ENABLED=false b6c644b81357d29d9ae30b788fad327ece26d363c3541e566c543dc9dc084874
  • ENV var carries single value:
docker run --rm --name=local-ls-docker -p 9600:9600 -e API_ENABLED=true -e XPACK_MANAGEMENT_ENABLED=true -e XPACK_MANAGEMENT_PIPELINE_ID="*" -e XPACK_MANAGEMENT_ELASTICSEARCH_HOSTS="https://es1:9200" -e XPACK_MONITORING_ENABLED=false b6c644b81357d29d9ae30b788fad327ece26d363c3541e566c543dc9dc084874

docker run --rm --name=local-ls-docker -p 9600:9600 -e API_ENABLED=true -e XPACK_MANAGEMENT_ENABLED=true -e XPACK_MANAGEMENT_PIPELINE_ID='*' -e XPACK_MANAGEMENT_ELASTICSEARCH_HOSTS='https://es1:9200' -e XPACK_MONITORING_ENABLED=false -it b6c644b81357d29d9ae30b788fad327ece26d363c3541e566c543dc9dc084874

docker run --rm --name=local-ls-docker -p 9600:9600 -e API_ENABLED=true -e XPACK_MANAGEMENT_ENABLED=true -e XPACK_MANAGEMENT_PIPELINE_ID="'*'" -e XPACK_MANAGEMENT_ELASTICSEARCH_HOSTS="https://es1:9200" -e XPACK_MONITORING_ENABLED=false -it b6c644b81357d29d9ae30b788fad327ece26d363c3541e566c543dc9dc084874
			
docker run --rm --name=local-ls-docker -p 9600:9600 -e API_ENABLED=true -e XPACK_MANAGEMENT_ENABLED=true -e XPACK_MANAGEMENT_PIPELINE_ID='"*"' -e XPACK_MANAGEMENT_ELASTICSEARCH_HOSTS="https://es1:9200" -e XPACK_MONITORING_ENABLED=false -it b6c644b81357d29d9ae30b788fad327ece26d363c3541e566c543dc9dc084874
  • To run docker acceptance test, use following commands
./gradlew clean bootstrap assemble installDefaultGems && rake artifact:docker
cd qa
bundle install
# make sure docker engine is running
bundle exec rspec docker/spec/full/container_spec.rb

Related issues

Use cases

Screenshots

Logs

…alues of ${ENV} (#16365)

* Properly resolve the values from ENV vars if literal array string provided with ENV var.

* Docker acceptance test for persisting  keys and use actual values in docker container.

* Review suggestion.

Simplify the code by stripping whitespace before `gsub`, no need to check comma and split.

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>

---------

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
(cherry picked from commit 62ef8a0)
Copy link
Copy Markdown
Contributor

@mashhurs mashhurs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mashhurs mashhurs merged commit 0ab0e75 into 8.15 Aug 6, 2024
@mashhurs mashhurs deleted the backport_16365_8.15 branch August 6, 2024 18:13
@elastic-sonarqube
Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@elasticmachine
Copy link
Copy Markdown

💚 Build Succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants