opensearch-project / helm-charts

:wheel_of_dharma: A community repository for Helm Charts of OpenSearch Project.
https://opensearch.org/docs/latest/opensearch/install/helm/
Apache License 2.0
170 stars 228 forks source link

[BUG][opensearch] CrashLoop when keystore secret has no data #433

Open hobti01 opened 1 year ago

hobti01 commented 1 year ago

Describe the bug When a keystore secret is configured and it does not have any entries, the shell script incorrectly attempts to import a non-existent file due to fileglobbing.

To Reproduce Steps to reproduce the behavior:

  1. Create a Kubernetes Secret with no data

    apiVersion: v1
    kind: Secret
    metadata:
    name: opensearch-keystore
    type: Opaque
    data: {}
  2. Configure a keystore secret

    keystore:
    - secretName: opensearch-keystore
  3. Deploy the chart and observe CrashLoop from the keystore init container. Logs:

    Created opensearch keystore in /usr/share/opensearch/config/opensearch.keystore
    Adding file /tmp/keystoreSecrets/*/* to keystore key *
    ERROR: File [/tmp/keystoreSecrets/*/*] does not exist

Expected behavior No CrashLoop

Chart Name opensearch

Screenshots N/A

Host/Environment (please complete the following information):

Additional context N/A

zelinh commented 1 year ago

[Triage] @hobti01 What is the cause/use case of creating an empty keystore? @prudhvigodithi

hobti01 commented 1 year ago

I propose there are two issues here:

  1. The shell script code is naive. This is a common shell/bash gotcha with globs that it tries a literal match when no files match. It should simply be written to work as intended.
  2. In real-world scenarios the script fails

In order to add sensitive data a Secret must exist before deploying the chart.

There may be several cases where the Secret has no data: