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

[Fix]: Solr remote url and properties settings #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GridexX
Copy link

@GridexX GridexX commented Jul 14, 2023

Context

Setting an external instance of Solr isn't working.
As describing in the documentation, you must change the INDEX_HOST and INDEX_PORT for that.

It should then update the xwiki.properties file with the following content:

solr.type=remote
solr.remote.baseURL=http://$INDEX_HOST:$INDEX_PORT/solr

Test

After some tests, it appears that the properties baseURL is not added in the file.

Step to reproduce this issue

  1. Launch the docker image with variables settled:
 docker run --rm -p 8080:8080 --name xwiki -e INDEX_HOST=solr -e INDEX_PORT=7000 xwiki:lts
  1. Retrieve the solr properties inside the xwiki.properties file:
docker exec xwiki cat /usr/local/tomcat/webapps/ROOT/WEB-INF/xwiki.properties | grep solr 

Which output the following:

solr.type=remote
#-# The default is the subfolder "store/solr" inside folder defined by the property "environment.permanentDirectory".
# solr.embedded.home=/var/local/xwiki/store/solr
# solr.remote.baseURL=http://localhost:8983/solr
# solr.remote.corePrefix=xwiki
# solr.indexer.batch.size=50
# solr.indexer.batch.maxLength=10000
# solr.indexer.queue.capacity=100000
# solr.synchronizeAtStartup=false
#-# Indicates which wiki synchronization to perform when the "solr.synchronizeAtStartup" property is set to true.
# solr.synchronizeAtStartupMode=FARM
# eventstream.store = solr

As we can see, the baseURL is not the expected one (http://localhost:8983/solr). We should have the following value, based on what was filled in the environment variables:
solr.remote.baseURL=http://solr:7000/solr

ℹ️ This problem concerns both LTS and Stable version, every docker images are impacted.

@GridexX GridexX force-pushed the fix/replace-properties-function branch from a2f074e to 3ffa03f Compare July 14, 2023 10:06
@GridexX
Copy link
Author

GridexX commented Jul 14, 2023

Changes

  1. Rewrite the old solr.remote.url property to solr.remote.baseURL. From the warning message:
    [solr.remote.url] property in xwiki.properties file is deprecated, use [solr.remote.baseURL] instead
  2. Update the xwiki_replace function to add an entry if it was missing in a file

Test

To ensure the fix is working, you can reproduce the following steps:

  1. Download the docker-entrypoint.sh
  2. Create the Dockerfile with the new entrypoint by copy the content:
FROM xwiki:14

COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["xwiki"]
  1. Build and run the container:
docker build -t gridexx/xwiki .
docker run --rm -p 8080:8080 --name xwiki -e INDEX_HOST=solr -e INDEX_PORT=7000 gridexx/xwiki
  1. Launch and retrieve the config file:
docker exec xwiki cat /usr/local/tomcat/webapps/ROOT/WEB-INF/xwiki.properties | grep solr 

Here is the output:

solr.type=remote
#-# The default is the subfolder "store/solr" inside folder defined by the property "environment.permanentDirectory".
# solr.embedded.home=/var/local/xwiki/store/solr
solr.remote.baseURL=http://solr:7000/solr/xwiki
...

As we can see, we get the expected properties filled

@vmassol
Copy link
Member

vmassol commented Jul 17, 2023

Thanks @GridexX I see several open issues related to Solr, see https://jira.xwiki.org/issues/?jql=text%20~%20%22solr%22%20and%20resolution%20%3D%20Unresolved%20and%20project%20%3D%20%22XWiki%20Docker%20images%22%20

Is this PR trying to fix https://jira.xwiki.org/browse/XDOCKER-183 ?

Note that the way we work is by having a jira issue first and then doing a PR to fix it (and referencing the issue in the commit). See https://dev.xwiki.org/xwiki/bin/view/Community/DevelopmentPractices#HRule:AlwaysputaJIRAissuereferenceincommitmessages

Also, should the documentation at https://github.com/xwiki/xwiki-docker/blob/master/README.md#using-an-external-solr-service be updated too or not?

I've not tested your changes yet but I've noticed that you haven't updated the xwiki_replace_or_add function in docker-entrypoint.sh file located in the template directory. This is needed as it's the one that gets instantiated for the various environments when building with Gradle.

Thanks!

@GridexX GridexX force-pushed the fix/replace-properties-function branch from 3ffa03f to 8812f1e Compare July 17, 2023 14:24
  improve replace properties function
  change solr remote url

Signed-off-by: GridexX <[email protected]>
@GridexX GridexX force-pushed the fix/replace-properties-function branch from 8812f1e to a91dcb8 Compare July 17, 2023 14:25
@GridexX
Copy link
Author

GridexX commented Jul 17, 2023

Hello @vmassol, thanks a lot for the details!
I need this fix in order to make the integration of Remote Solr inside Kubernetes possible.
It is (unintentional) the JIRA issue I was trying to fix 😄

The documentation doesn't need to be updated, as I have fixed what was written and didn't work previously.

According to what you said, I have modified my PR to include the JR issue number in the commit message and also modified the docker-entrypoint.sh 👍

Feel free to test it when you will have time. Have a nice day !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants