[bitnami/elasticsearch] do not fail if asked to chown read-only files #77526
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the change
Add
-f
and|| :
tochown
commands that operate recursively on folders that are expected to be mounted into the container from volumes or bind mounts, so that thechown
does not cause a fatal error if any of the target directories or their children are mounted read-only.Benefits
Currently when running as root the elasticsearch container will fail to start if any folder under
/opt/bitnami/elasticsearch/config
is mounted from a read-only filesystem. In particular this happens in the corresponding bitnami Helm chart, where the TLS certificates for Elasticsearch are mounted in from a Kubernetes secret. This change means that such cases are no longer fatal errors - the files in the read-only filesystems will not of course have their ownership changed, but there's not really anything better we can do if the filesystem is read-only.Possible drawbacks
If a mounted filesystem should have been read-write but was mounted read-only by mistake, this change will make that a silent no-op rather than a fatal error.
Applicable issues
Additional information
This fix should probably be applied before bitnami/charts#31960 is merged.