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

init_solr should use authentication when creating default core and collection #20

Closed
baumanno opened this issue Mar 29, 2023 · 1 comment

Comments

@baumanno
Copy link

I'm trying to hook this solr-container up to a Drupal-instance, using https://github.com/wodby/docker4drupal.
I followed the steps outlined at https://wodby.com/docs/1.0/stacks/drupal/local/#solr-search-api, where it mentions:

Access Solr container via make shell solr and run make init -f /usr/local/bin/actions.mk. This will enable authentication for Solr Cloud mode and create a collection named default that will use _default config set.

However, the collection is never created: when I access the solr admin panel, I see no cores and no collections, and communication with Solr SearchAPI in Drupal cannot be established.

I believe this is due to the fact that init_solr first sets up a new authentication with user:pass, and then goes on to call the solr-API via curl without user:pass:

solr/bin/init_solr

Lines 13 to 24 in 02379f8

if [[ -n "${SOLR_CLOUD_PASSWORD}" ]]; then
sleep 5
make update-password host="${host}" username=solr password=SolrRocks new_password="${SOLR_CLOUD_PASSWORD}" \
-f /usr/local/bin/actions.mk
fi
# Create default collection if there are no collections.
if curl -s "http://${host}:8983/solr/admin/collections?action=LIST" | grep -q '"collections":\[\]'; then
echo "No collections found, creating a default collection"
IFS=',' read -ra num_shards <<< "$ZK_HOST"
make create-collection collection="default" host="${host}" num_shards="${#num_shards[@]}" config="_default" \
-f /usr/local/bin/actions.mk
fi

When I run make init -f /usr/local/bin/actions.mk in the solr-container, then execute the curl-call for listing collections manually, I get this:

/opt/solr/server/solr $ curl -s "http://solr:8983/solr/admin/collections?action=LIST"
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 401 require authentication</title>
</head>
<body><h2>HTTP ERROR 401 require authentication</h2>
<table>
<tr><th>URI:</th><td>/solr/admin/collections</td></tr>
<tr><th>STATUS:</th><td>401</td></tr>
<tr><th>MESSAGE:</th><td>require authentication</td></tr>
<tr><th>SERVLET:</th><td>default</td></tr>
</table>

</body>
</html>

I believe the call that sets up authentication should either be made after creating cores/collections, or the respective curl-calls should be provided the newly created credentials.

@csandanov
Copy link
Member

You're right, we should create the collection before setting up the auth, thank you for reporting this

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

No branches or pull requests

2 participants