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

[Bug]: Snake case environment variables for settings do not work #20 #4451

Open
gowrizrh opened this issue Feb 14, 2024 · 8 comments
Open

[Bug]: Snake case environment variables for settings do not work #20 #4451

gowrizrh opened this issue Feb 14, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@gowrizrh
Copy link

gowrizrh commented Feb 14, 2024

Describe the bug

We are migrating from Elasticsearch to Opensearch. We mostly use bitbucket pipelines to run functional or integration api testing where Elasticsearch is required as a service.

Currently, configuration of Opensearch via Docker variables is possible. -e discovery.type=single-node

However, Bitbucket pipelines does not allow dots in variable definition for services.

See https://jira.atlassian.com/browse/BCLOUD-18007

As a very quick example, running echo $DOT.VARIABLE in Shell or Bash would evaluate $DOT as a variable and then append .VARIABLE verbatim, rather than evaluate $DOT.VARIABLE as a whole. Though there are some scenarios where this does work as expected, such as how Elasticsearch reads the variables.

As far as I can tell from this ticket, this feature was needed primarily for the Elasticsearch Docker image. And Elasticsearch has offered a workaround for this problem:

See Elasticsearch's workaround elastic/elasticsearch#74036

For example discovery.type would become ES_SETTING_DISCOVERY_TYPE. This type of environment variable no longer works in Opensearch and it fails to boot up because of the bootstrap checks.

To reproduce

Start a simple container passing in a snake cased variant of the configuration option.

docker run --rm -it -e "ES_SETTING_DISCOVERY_TYPE=single-node" opensearchproject/opensearch:latest

Results in the following logs

[2023-03-16T23:39:08,792][INFO ][o.o.b.BootstrapChecks    ] [fcd52ae49431] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_cluster_manager_nodes / cluster.initial_master_nodes] must be configured
ERROR: OpenSearch did not exit normally - check the logs at /usr/share/opensearch/logs/docker-cluster.log

Expected behavior

A workaround or an alternative syntax to pass in variables without the dot format like Elasticsearch.

For example the docker environment variable ES_SETTING_DISCOVERY_TYPE is the same as discovery.type

Screenshots

No response

Host / Environment

Docker version 23.0.1, build a5ee5b1

Additional context

This is a copy of opensearch-project/docker-images#20

Relevant log output

No response

Acceptance Criteria

  • Evaluate the potential solutions to use non-snake case environment variables for docker
  • Verify if the change should come from core repo or build repo
  • Docker image should support both snake case and non-snake case environment variables
@gowrizrh gowrizrh added bug Something isn't working untriaged Issues that have not yet been triaged labels Feb 14, 2024
@rishabh6788
Copy link
Collaborator

Thanks for creating this issue.
While we work on providing you a work around, is it possible for you mount opensearch.yml from your local to the container to overcome this issue?
Tagging @peterzhuamazon for any other work around that he may know of.

Also, https://github.com/opensearch-project/docker-images is on deprecation path, if you want to create OpenSearch docker images form source please follow https://github.com/opensearch-project/opensearch-build/blob/main/docker/release/README.md.

@rishabh6788 rishabh6788 removed the untriaged Issues that have not yet been triaged label Feb 15, 2024
@gowrizrh
Copy link
Author

@rishabh6788 No, not at least for us. This is in a throw away CI environment. There is no way to mount files in Bitbucket's pipeline runners

https://support.atlassian.com/bitbucket-cloud/docs/databases-and-service-containers/

Our current workaround is using Elasticsearch.

@peterzhuamazon
Copy link
Member

peterzhuamazon commented Feb 19, 2024

Hi @gowrizrh are you able to run docker with this command?
Basically wrapping the env var with double quotes such as this: https://opensearch.org/docs/latest/install-and-configure/install-opensearch/docker/#configure-opensearch

docker run -it -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" opensearchproject/opensearch:latest

@peterzhuamazon
Copy link
Member

Hi @andrross @mch2 seems like we do not see similar env var for discovery.type in core.
Could you help checking this up so @gowrizrh can use a env var that without . to specify discovery.type during docker deployment?

Thanks.

@bbarani
Copy link
Member

bbarani commented Mar 18, 2024

Hello @andrross @mch2 Can you please provide your inputs?

@andrross
Copy link
Member

@peterzhuamazon Does the double quote approach work? If not, we could add snake case environment variables in core if that make things easier.

@jhauserdev
Copy link

jhauserdev commented Mar 27, 2024

Screenshot 2024-03-27 at 3 03 17 PM Screenshot 2024-03-27 at 3 03 35 PM

This is what happens when attempting to use a list, or a map with dot notation in Bitbucket Pipelines.

I've attempted the following formats for environment (taken from the sample yml):

 environment:
        - cluster.name=opensearch-cluster
        - node.name=opensearch
        - discovery.seed_hosts=opensearch
        - cluster.initial_cluster_manager_nodes=opensearch
        - bootstrap.memory_lock=true
        - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
        - "DISABLE_INSTALL_DEMO_CONFIG=true"
        - "DISABLE_SECURITY_PLUGIN=true"

environment:
        cluster.name: opensearch-cluster
        node.name: opensearch
        discovery.seed_hosts: opensearch
        cluster.initial_cluster_manager_nodes: opensearch
        bootstrap.memory_lock: "true"
        OPENSEARCH_JAVA_OPTS: "-Xms512m -Xmx512m"
        DISABLE_INSTALL_DEMO_CONFIG: "true"
        DISABLE_SECURITY_PLUGIN: "true"

What Bitbucket Pipelines would require:

environment:
        CUSTER_NAME: opensearch-cluster
        NODE_NAME: opensearch
        DISCOVERY_SEED_HOSTS: opensearch
        CLUSTER_INITIAL_CLUSTER_MANAGER_NODES: opensearch
        BOOTSTRAP_MEMORY_LOCK: "true"
        OPENSEARCH_JAVA_OPTS: "-Xms512m -Xmx512m"
        DISABLE_INSTALL_DEMO_CONFIG: "true"
        DISABLE_SECURITY_PLUGIN: "true"

@andrewazores
Copy link

Sorry for the drive-by comment without much knowledge of the particular context here. I'm only aware of this because a contributor to my project wants to add an OpenSearch container as a test case for our project.

Anyway, this configuration property name vs environment variable problem looks familiar to me. MicroProfile (and therefore SmallRye, and therefore Quarkus) solve it like this:

https://github.com/eclipse/microprofile-config/blob/main/spec/src/main/asciidoc/configsources.asciidoc#environment-variables-mapping-rules

https://smallrye.io/smallrye-config/Main/config/environment-variables/

Just some food for thought or maybe inspiration on the name transformation approach.

@bshien bshien moved this from Backlog to Now(This Quarter) in Engineering Effectiveness Board Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 📦 Backlog
Development

No branches or pull requests

7 participants