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

Solr core not automatically created #551

Closed
hanoii opened this issue Nov 28, 2017 · 15 comments
Closed

Solr core not automatically created #551

hanoii opened this issue Nov 28, 2017 · 15 comments

Comments

@hanoii
Copy link
Contributor

hanoii commented Nov 28, 2017

I wanted to have, for now, just a solr service on a drupal project, not going full lando yet.

I have the following .yml file:

name: moog-drupal

proxy:
  # Lets get a nice lndo url for the solr web interface
  solrsearch2:
    - moog-solr.lndo.site:8983

# Spin up services to run a basic LAMP stack
services:
  solrsearch2:
    type: solr:6.6
    portforward: true
    core: drupal
    config:
      conf: .platform/solr-conf

For some reason the core is not created or found automatically.

Solr is there without core. I can see the configs on /opt/solr/server/solr/mycores/drupal, but the core is not there.

When I went to try to add the core manually, providing mycores/drupal as the instanceDir, it complained that it didn't have access to /opt/solr/server/solr/mycores/drupal/core.properties.

I ssh to the service and saw that /opt/solr/server/solr/mycores/drupal was owned by root:root. I then chowned it to solr:solr and added the core and that worked, but this surely have been automatically.

Using lando master.

@heshanlk
Copy link

heshanlk commented Dec 12, 2017

I have the same issue, the Solr core would not create automatically. This was working before in beta.16

@heshanlk
Copy link

heshanlk commented Dec 12, 2017

After couple of different config attempts following configs appeared to be working fine for me for search api solr with Solr 5.5.

The Core name should be the same as the name you put in top of your .lando.yml file.

  solr:
    type: solr:5.5
    portforward: true
    core: [LANDOENVNAME]
    config:
      conf: docroot/modules/contrib/search_api_solr/solr-conf/5.x

@heshanlk
Copy link

I was wrong, something this is working sometimes not so we need to fix for this.

@hanoii
Copy link
Contributor Author

hanoii commented Dec 13, 2017

@heshanlk you might want to check my pull request/fork and report back.

@dmsmidt
Copy link

dmsmidt commented Dec 21, 2017

The PR of @hanoii fixes the problem.
This is currently keeping a complete company (20+ devs) from using Lando.

@jbertoen
Copy link
Contributor

jbertoen commented Jan 3, 2018

I talked a lot in slack, a lot to myself as well, viva la rubberducking. @Mirnaxvb and @MikeWong1991 know what I mean.

The problem is the following:

  • /solrconf is mapped to the conf dir as a volume by setting the conf value in the .lando.yml file
  • /opt/solr/server/solr/mycores/CORENAME/conf is also mapped as a volume as a volume by setting the conf value in the .lando.yml file

But the thing is, when creating your solr service from scratch, without preexisting volumes or containers. The core needs to be created. Which would mostly mean that within /opt/solr/server/solr/mycores/CORENAME 2 things need to be added:

  • core.properties
  • data

But because the conf directory within the core is mapped BEFORE executing this command. /opt/solr/server/solr/mycores/CORENAME is not accessible by solr (owned by root), which would prevent the data folder to be created when solr is started. But also the solr precreate scripts can't be run because it thinks the core is already created, which would add the core.properties.

Allowing this PR to go through would arise the problem that the core schema and such will not be synced without recreating the whole container and it's volumes. Becuase we need the precreate to run to make sure everything is copied and created correctly.

We got a view options to fix this:

  1. Allow this PR and accept the fact that we need to rebuild an entire container and it's volumes when the schema changes.
  2. Allow this PR and add a script that would copy the /solrconf folder to /opt/solr/server/solr/mycores/CORENAME/conf if the core already exists. And run it before the precreate script. https://github.com/docker-solr/docker-solr#extending-the-image has an explanation about adding scripts to extend solr.
  3. Reject this PR and also somehow volume map the core.properties file and set the ownership to solr:solr on the core. Which would mean to map the entire core as a volume instead of only the conf directory within the core. Or individually map core.properties and conf within the core as a 2 volumes and execute a chown command to set the ownership to the solr user.

My preference would be to go for 1 or 2. Because solr schema's do not change that much.

  1. would be the quickfix, at least to make solr working again for a lot of people.
  2. would be the most desired way, it would make sure that a restart and a rebuild would suffice to sync the configuration to the core. Keeping volumes and containers intact.

@pirog
Copy link
Sponsor Member

pirog commented Jan 4, 2018

@jbertoen this write up is INCREDIBLE! this saves me tons of time.

I need to try this out but there might be a an easy option 4 which is to just make sure the solr core conf directory is owned by solr. Will report back to you all soon. thanks for bearing with us on this on.

@pirog
Copy link
Sponsor Member

pirog commented Jan 4, 2018

ok yeah i can definitely confirm the two major items here:

  1. This PR (Do not map to the conf folder within the named volume #553) does create the core successfully
  2. The core config can only be changed with a destroy/start

pirog added a commit that referenced this issue Jan 4, 2018
@pirog
Copy link
Sponsor Member

pirog commented Jan 4, 2018

ok, so to handle 2. we are using lando to destroy the core conf directory on every start and then recreate it as a symlink to the /solrconf/conf mounted volume. This should resolve the issue and allow people to change their solr conf ON THE FLY (eg without a restart).

im going to close this and it should be available in the beta.32 i plan on rolling tonight.

@pirog pirog closed this as completed Jan 4, 2018
pirog added a commit that referenced this issue Jan 4, 2018
@jbertoen
Copy link
Contributor

jbertoen commented Jan 4, 2018

The solr-precreate calls the precreate-core script. This checks if the directory of the corename exists, if so cancel the precreate.

So this would not work if we already mapped a volume to the corename/conf directory. The script would think the core is already created. Thus not creating the core.properties in the corename directory which is needed to load the core. So fixing file rights would not be enough.

Maybe creating a symlink of the conf folder after running the solr-precreate command?
ln -sf /solrconf /opt/solr/server/solr/mycores/CORENAME/conf

@pirog
Copy link
Sponsor Member

pirog commented Jan 4, 2018

yup! see: c4925bb setting up the symlink is exactly what i ended up doing. in basic testing it seems to satisfy the two big things we wanted to do.

@jbertoen
Copy link
Contributor

jbertoen commented Jan 4, 2018

Awesome!

@hanoii
Copy link
Contributor Author

hanoii commented Jan 12, 2018

I was away for a few weeks but I just tried master and again the solr core is not precreated. I will follow this up better but just wanted to not. Is there something I need to do? I destroyed/recreated everything.

EDIT: My bad, I updated my own fork's master.

@pirog
Copy link
Sponsor Member

pirog commented Jan 12, 2018 via email

@hanoii
Copy link
Contributor Author

hanoii commented Jan 12, 2018

@pirog I was wrongly pulling my fork's master, tried it now with the latest lando and it does work. I edited my post soon after when I found this but you probably didn't receive the email notification of the edit. Thanks!

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

5 participants