Skip to content

Commit

Permalink
Fix issue with docker volume-mounted config file
Browse files Browse the repository at this point in the history
Using `sed -i` was causing an issue when a custom opensearch.yml file was mounted as a volume.

```
sed: cannot rename /usr/share/opensearch/config/sedqdMb0d: Device or resource busy
```

The reason for the issue was found by @unhipzippo opensearch-project/OpenSearch#768 (comment) ❤️

> The "sed -i" is an attempt to modify the opensearch.yml file "in place" -- But according to the GNU sed documentation (https://www.gnu.org/software/sed/manual/sed.html#Command_002dLine-Options), "in-place" actually "does this by creating a temporary file and sending output to this file rather than to the standard output. ... the temporary file is renamed to the output file’s original name".
>
> I believe this rename would require changing the inode of the original file -- something that Docker volume mounts don't permit.
  • Loading branch information
robinboening committed Nov 23, 2021
1 parent c3d0129 commit ccf0b8c
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ if [ -d "$OPENSEARCH_HOME/plugins/$SECURITY_PLUGIN" ]; then

if [ "$DISABLE_SECURITY_PLUGIN" = "true" ]; then
echo "Disabling OpenSearch Security Plugin"
sed -i '/plugins.security.disabled/d' $OPENSEARCH_HOME/config/opensearch.yml
echo "plugins.security.disabled: true" >> $OPENSEARCH_HOME/config/opensearch.yml
sed 's/plugins.security.disabled.*$/plugins.security.disabled: true' $OPENSEARCH_HOME/config/opensearch.yml | tee $OPENSEARCH_HOME/config/opensearch.yml
else
echo "Enabling OpenSearch Security Plugin"
sed -i '/plugins.security.disabled/d' $OPENSEARCH_HOME/config/opensearch.yml
sed '/plugins.security.disabled/d' $OPENSEARCH_HOME/config/opensearch.yml | tee $OPENSEARCH_HOME/config/opensearch.yml
fi
fi

Expand Down

0 comments on commit ccf0b8c

Please sign in to comment.