Skip to content

Commit

Permalink
Fix issue with docker volume-mounted config file (#1130)
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.

Signed-off-by: Robin Böning <robin.boening@gmail.com>
  • Loading branch information
robinboening authored Jan 5, 2022
1 parent 36516f8 commit 39464ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ if [ -d "$OPENSEARCH_DASHBOARDS_HOME/plugins/$SECURITY_DASHBOARDS_PLUGIN" ]; the
if [ "$DISABLE_SECURITY_DASHBOARDS_PLUGIN" = "true" ]; then
echo "Disabling OpenSearch Security Dashboards Plugin"
./bin/opensearch-dashboards-plugin remove securityDashboards
sed -i /^opensearch_security/d $OPENSEARCH_DASHBOARDS_HOME/config/opensearch_dashboards.yml
sed -i 's/https/http/' $OPENSEARCH_DASHBOARDS_HOME/config/opensearch_dashboards.yml
sed "/^opensearch_security/d" $OPENSEARCH_DASHBOARDS_HOME/config/opensearch_dashboards.yml | tee $OPENSEARCH_DASHBOARDS_HOME/config/opensearch_dashboards.yml
sed "s/https/http/" $OPENSEARCH_DASHBOARDS_HOME/config/opensearch_dashboards.yml | tee $OPENSEARCH_DASHBOARDS_HOME/config/opensearch_dashboards.yml
fi
fi

Expand Down
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 39464ae

Please sign in to comment.