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

Pantheon Recipe: Solr Version Handling #15

Closed
kerasai opened this issue Oct 27, 2021 · 8 comments
Closed

Pantheon Recipe: Solr Version Handling #15

kerasai opened this issue Oct 27, 2021 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@kerasai
Copy link

kerasai commented Oct 27, 2021

For Drupal 9 sites, Pantheon allows for Solr 8 by defining it in the pantheon.yml file.

This is a feature request to make Lando consider the Solr version as defined in the pantheon.yml file when building/rebuilding the containers for the project.

See Pantheon YAML Configuration Files and Using Solr 8 on Drupal 9.

@rtfm-47 rtfm-47 transferred this issue from lando/lando Nov 24, 2021
@fyaconiello
Copy link

We're seeing the same thing at our shop and haven't figured it out yet. We are working on it by adding a /private/solr directory
and copying in https://github.com/docker-solr/docker-solr/tree/master/8.0 and then modifying the image to run @ //index:449/ then doing something like this in the lando.yml

services:
  index:
    type: compose
    services:
      build:
        context: ./private/solr
        dockerfile: Dockerfile

to override the default 3.x.x solr version thats part of the pantheon recipe.

@kerasai
Copy link
Author

kerasai commented Nov 30, 2021

I did something similar to this, just adding a service that uses the Solr 8 image and adjusting the app server's ENV vars to utilize that.

In the end it ended up being a moot point. Pantheon wants you to "have a chat with an account rep" in order to use Solr 8--not worth my time. I'll be using Solr 3 for the foreseeable future.

@kdginther
Copy link

@kerasai I understand where you are coming from. However, we (@fyaconiello and I) are on the opposite side. Solr 8 is up and running on Pantheon for our recently migrated D9 site. So everything works great on Pantheon, it's the local environment that's having issues.

Was your attempt with adding the service and adjusting the ENV vars successful?

@AleMadLei
Copy link

Maybe this will help someone who's also having this issue. I spent a couple of days banging my head.

We also needed to use SOLR 8 for some autocomplete suggestions on our project and it wasn't working with the older SOLR.

So, I added a separate SOLR 8 server to our lando.yml file.

  solr8:
    type: solr:8
    ssl: true
    config:
      dir: web/modules/composer/search_api_solr/jump-start/solr8/config-set

We use the default config from the search_api_solr module.

Then I proceeded to create the "production" (pantheon) search api server and a "development" (local_dev) search api server. The development one by default is disabled.

Then, I create the index as part of the production one and setup as needed.

Now, by default this won't work, it will throw some errors when using version 8 from pantheon-systems/search_api_pantheon.

However, I made these changes in my settings.local.php

// For our local environments, the Search API Server is the SOLR8 service.
$config['search_api.server.local_dev']['status'] = TRUE;
$config['search_api.index.glossary_terms']['server'] = 'local_dev';

// Until it is supported, the Pantheon server is disabled.
$config['search_api.server.pantheon']['status'] = FALSE;
$config['search_api.server.pantheon']['description'] = "This will always remain disabled on your local environment.";

// SOLR on Pantheon defines the scheme as an environment variable.
// We define this just so that the module doesn't break.
putenv('PANTHEON_INDEX_SCHEME=https');
putenv('PANTHEON_INDEX_PORT=449');

This basically puts some environment variables the Pantheon module requires and changes the server for the index locally.

After this I got it to work for both our local environments and the pantheon workflow.

@dalin-
Copy link

dalin- commented Mar 30, 2022

First I just tried to get search_api_pantheon module to recognize Lando's Solr by setting environment variables. I had no luck.

@AleMadLei 's post above got me in the right direction. But I needed more:

Step 1) .lando.yml

config:
  # Don't build Pantheon's default Solr 3.  We use Solr 8 further down.
  index: false
services:
  solr8:
    type: solr:8.8
    core: new_core
    portforward: true
    config:
      dir: web/modules/contrib/search_api_solr/jump-start/solr8/config-set

Step 2) Create a new Search API Server

Screen Shot 2022-03-29 at 11 36 52 PM

Step 3) settings.php

/**
 * Setup Solr paths for Lando.
 */
if ($_ENV['PANTHEON_ENVIRONMENT'] === 'lando') {
  // For our local environments, the Search API Server is the SOLR8 service.
  $config['search_api.server.local_dev']['status'] = TRUE;
  $config['search_api.index.content']['server'] = 'local_dev';

  // Until it is supported, the Pantheon server is disabled.
  $config['search_api.server.pantheon_solr8']['status'] = FALSE;
  $config['search_api.server.pantheon_solr8']['description'] = "This will always remain disabled on your local environment.";
}

@generalredneck
Copy link

generalredneck commented Aug 26, 2022

As an FYI, I did some poking around here... I implemented the default solr:8.0 image and putzed around with Enviornment Variables and traced some requirements through the Search API Pantheon V8.0.1. Some requirements that we will need to fulfill are the following:

We must add the following Environment variables to appserver:
PANTHEON_INDEX_SCHEME:
PANTHEON_INDEX_HOST:
PANTHEON_INDEX_PORT:
PANTHEON_INDEX_PATH:
PANTHEON_INDEX_CORE:

But that isn't quite enough because the Pantheon custom endpoints expect the following:

  • There must be the string "v1" as a directory in the path, Otherewise, the code will add v1 to the uri and cause it to fail.
  • There must be the sites's has id in the path as a directory, otherwise, pantheon will add the core-name to the uri again because it's supposed to contain the site's id...

If you fail these checks (say you make PATH=solr and CORE=new_core) you will end up with something like this... /solr/new_core/v1/new_core as the uri which is logic from search_api_pantheon... (see link at bottom of this comment)

As an example, pantheon's Environment variables look like this:

ENV NAME VALUE
PANTHEON_INDEX_HOST search-gateway-us-central1-f.svc.pantheon.io
PANTHEON_INDEX_PORT 443
PANTHEON_INDEX_SCHEME https
PANTHEON_INDEX_PATH v1
PANTHEON_INDEX_CORE /site/12345678-90ab-cdef-1234-567890abcdef/environment/live/backend
PANTHEON_INDEX_SCHEMA /site/12345678-90ab-cdef-1234-567890abcdef/environment/live/configs
PANTHEON_SITE 12345678-90ab-cdef-1234-567890abcdef

An acceptable outcome may look like this

ENV NAME VALUE
PANTHEON_INDEX_HOST index
PANTHEON_INDEX_PORT 8983
PANTHEON_INDEX_SCHEME http
PANTHEON_INDEX_PATH v1
PANTHEON_INDEX_CORE 12345678-90ab-cdef-1234-567890abcdef
PANTHEON_INDEX_SCHEMA NOT SURE IF THIS IS EVEN USED...
PANTHEON_SITE 12345678-90ab-cdef-1234-567890abcdef

As far as I know I haven't been able to change the default path for the solr implementation from something like index:8983/solr. The /solr part seems to be hard coded into the docker container somewhere... It would be much easier to patch the (what I feel) are stupid checks in the pantheon solrarium guzzle client located at https://github.com/pantheon-systems/search_api_pantheon/blob/8.0.1/src/Services/PantheonGuzzle.php#L155-L162

I hope this gets some traction toward this feature... Until then... using workarounds like ☝️ AleMadLei's or Dalin's is going to be the way to go.

The other thing I would add... is that if you don't know what config got posted to Pantheon the first time, you can go grab the config.zip from a url like admin/config/search/search-api/server/global_search/solr_configset/current-config-zip and point your lando configuration at that.

reynoldsalec added a commit that referenced this issue Nov 23, 2022
reynoldsalec added a commit that referenced this issue Nov 23, 2022
@pirog
Copy link
Member

pirog commented Nov 24, 2022

@generalredneck nice sleuthing here. we ran into similar issues while trying to build out support for solr8. i think the paths to least resistance here are:

  1. PR against search_api_pantheon so that it doesnt hardcode things like v1
  2. Generate some webserver config for solr8 so that the paths line up better to what search_api_pantheon needs

reynoldsalec added a commit that referenced this issue Dec 5, 2022
reynoldsalec added a commit that referenced this issue Dec 7, 2022
reynoldsalec added a commit that referenced this issue Dec 7, 2022
reynoldsalec added a commit that referenced this issue Dec 7, 2022
reynoldsalec added a commit that referenced this issue Mar 1, 2023
* #15: Initial solr8 setup.

* #15: Portforwarding for solr8.

* Correct volume for M1 MariaDB data directory.

* #15: Add jetty rewrites to get Solr paths operating correctly for Solr8.

* #15: Add tests and documentation for setting Solr version.

* #15: Feed the linter.

* Update pr-wordpress-tests.yml

* #15: Address PR comments to update docs and make sure Solr8 config doesn't bleed in to Solr3.

* #15: Don't hardcode the index service into the main builder.js.

* #15: Add a test to D9 testing out the Jetty redirects.

* release v0.8.0

* #15: Correct referencing of Solr tag.

* release v0.8.1

* #15: Additional tests for Solr 8 env vars.
reynoldsalec added a commit that referenced this issue Mar 16, 2023
reynoldsalec added a commit that referenced this issue Mar 16, 2023
reynoldsalec added a commit that referenced this issue Mar 20, 2023
* #15: Install Drupal configset for Solr8 via custom Solr8 image.

* #15: Update solrTag logic for solr8.

* #15: Update CHANGELOG and feed the linter.

* #15: Update solr8 tests to reflect 8.8.2 Pantheon version.

* release v0.10.0
@reynoldsalec
Copy link
Member

reynoldsalec commented Mar 20, 2023

Ok, finally integrated in solr8 compatibility that should get most folks up-and-running. I think the big to-do here is getting custom schema uploading working (#166) but folks using the default schema provided by the configset from search_api_solr (AKA most users) should be happy with what's in here.

This won't get packaged with Lando until v3.15.0+, but if you want to custom-install the plugin you can use these instructions or run it from source by cloning this repo to ~/.lando/plugins/@lando/pantheon and running yarn install to retrieve its dependencies.

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

No branches or pull requests

10 participants