-
Notifications
You must be signed in to change notification settings - Fork 5
Gavin webstuff solr9 #140
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
Open
gavin-webstuff
wants to merge
13
commits into
Annertech:main
Choose a base branch
from
gavin-webstuff:gavin-webstuff-solr9
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Gavin webstuff solr9 #140
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
356dae0
Add install-solr script for ddev addon
gavin-webstuff 1331a89
Add helper to get solr9 up and running locally
gavin-webstuff dfc0c11
Update settings override for solr local settings file
gavin-webstuff 39baff0
Update Solr manifest and repository checks
gavin-webstuff c3f1b6f
Update the precommit check for ddev solr
gavin-webstuff 22a91eb
handle solr version other than 8 to 9
gavin-webstuff e24628d
Merge branch 'Annertech:main' into gavin-webstuff-solr9
gavin-webstuff abe3c3f
rename solr9 commands
gavin-webstuff 496e145
update command descriptions
gavin-webstuff edf925d
Merge branch 'Annertech:main' into gavin-webstuff-solr9
gavin-webstuff 40f7c82
Merge branch 'Annertech:main' into gavin-webstuff-solr9
gavin-webstuff 88bde7a
address issue where dir is missing
gavin-webstuff bc4fbf9
Merge branch 'gavin-webstuff-solr9' of github.com:gavin-webstuff/anne…
gavin-webstuff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,25 @@ | ||
| #ddev-generated | ||
| #annertech-ddev | ||
| SOLR_MANIFEST="$APPROOT/.ddev/addon-metadata/solr/manifest.yaml" | ||
| SOLR_MANIFEST="$APPROOT/.ddev/addon-metadata/ddev-solr/manifest.yaml" | ||
|
|
||
| if [[ ! -f "$SOLR_MANIFEST" ]]; then | ||
| pass "ddev-drupal-solr not installed — project does not use Solr" | ||
| pass "ddev-solr not installed — project does not use Solr" | ||
| else | ||
| SOLR_VERSION=$(grep -E '^version:' "$SOLR_MANIFEST" | awk -F': ' '{print $2}' | tr -d '"' | xargs) | ||
| SOLR_REPO=$(grep -E '^repository:' "$SOLR_MANIFEST" | awk -F': ' '{print $2}' | tr -d '"' | xargs) | ||
|
|
||
| if [[ "$SOLR_REPO" == "ddev/ddev-drupal-solr" || "$SOLR_REPO" == "ddev/ddev-drupal9-solr" ]]; then | ||
| pass "ddev-drupal-solr repository is correct ($SOLR_REPO)" | ||
| if [[ "$SOLR_REPO" == "ddev/ddev-solr" ]]; then | ||
| pass "ddev-solr repository is correct ($SOLR_REPO)" | ||
| else | ||
| fail "ddev-drupal-solr repository is '$SOLR_REPO' — expected 'ddev/ddev-drupal-solr' or 'ddev/ddev-drupal9-solr'" | ||
| warn "Install the correct addon with: 'ddev add-on get ddev/ddev-drupal-solr --version $DDEV_SOLR_VERSION'" | ||
| fail "ddev-solr repository is '$SOLR_REPO' — expected 'ddev/ddev-solr'" | ||
| warn "Install the correct addon with: 'ddev add-on get ddev/ddev-solr --version $DDEV_SOLR_VERSION'" | ||
| fi | ||
|
|
||
| if [[ "$SOLR_VERSION" == "$DDEV_SOLR_VERSION" ]]; then | ||
| pass "ddev-drupal-solr version is $DDEV_SOLR_VERSION" | ||
| pass "ddev-solr version is $DDEV_SOLR_VERSION" | ||
| else | ||
| fail "ddev-drupal-solr version '$SOLR_VERSION' is not supported — only $DDEV_SOLR_VERSION is compatible" | ||
| warn "Install the correct version with: 'ddev add-on get ddev/ddev-drupal-solr --version $DDEV_SOLR_VERSION'" | ||
| fail "ddev-solr version '$SOLR_VERSION' is not supported — only $DDEV_SOLR_VERSION is compatible" | ||
| warn "Install the correct version with: 'ddev add-on get ddev/ddev-solr --version $DDEV_SOLR_VERSION'" | ||
| fi | ||
| fi | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #!/usr/bin/env bash | ||
| #annertech-ddev | ||
|
|
||
| ## Description: setup ddev-solr for local use, creates a collection & rebuilds index | ||
| ## Usage: solr9-local [-c] | ||
| ## Example: "ddev solr9-local" | ||
| ## Example: "ddev solr9-local -c" | ||
| ## Flags: [{"Name":"c","Usage":"Run Solr setup and configuration"}] | ||
|
|
||
| RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' | ||
| echo_red() { echo -e "${RED}$1${NC}" >&2; } | ||
| echo_green() { echo -e "${GREEN}$1${NC}"; } | ||
| echo_yellow() { echo -e "${YELLOW}$1${NC}"; } | ||
|
|
||
| SOLR_SERVER_NAME="solr" | ||
| SOLR_COLLECTION="collection_1" | ||
| RUN_SETUP=false | ||
|
|
||
| # Optional setup argument | ||
| if [ "$1" = "-c" ] || [ "$1" = "c" ]; then | ||
| RUN_SETUP=true | ||
| fi | ||
|
|
||
| echo_yellow "Configuring ddev/ddev-solr for local development" | ||
|
|
||
| collection_exists() { | ||
| ddev solr status 2>/dev/null | grep -q "${SOLR_COLLECTION}" | ||
| } | ||
|
|
||
| module_enabled() { | ||
| ddev drush pm:list --status=enabled --field=name 2>/dev/null | grep -q "search_api_solr_admin" | ||
| } | ||
|
|
||
| configset_uploaded() { | ||
| ddev solr zk ls /configs 2>/dev/null | grep -q "${SOLR_COLLECTION}" | ||
| } | ||
|
|
||
| configure_local_drupal_setup() { | ||
| if collection_exists; then | ||
| echo_yellow "↳ Collection '${SOLR_COLLECTION}' already exists, skipping creation." | ||
| else | ||
| echo_yellow "↳ Creating collection '${SOLR_COLLECTION}'..." | ||
| ddev solr create_collection --name=${SOLR_COLLECTION} | ||
| fi | ||
|
|
||
| if module_enabled; then | ||
| echo_yellow "↳ Module 'search_api_solr_admin' already enabled, skipping." | ||
| else | ||
| echo_yellow "↳ Enabling search_api_solr_admin module..." | ||
| ddev drush en search_api_solr_admin -y | ||
| fi | ||
|
|
||
| if configset_uploaded; then | ||
| echo_yellow "↳ Configset already uploaded, skipping." | ||
| else | ||
| echo_yellow "↳ Uploading configset..." | ||
| ddev drush --numShards=1 search-api-solr:upload-configset ${SOLR_SERVER_NAME} | ||
| fi | ||
| } | ||
|
|
||
| rebuild_index() { | ||
| echo_yellow "↳ Rebuilding search index..." | ||
| ddev drush search-api:reset-tracker | ||
| ddev drush search-api:index | ||
| } | ||
|
|
||
| if [ "$RUN_SETUP" = true ]; then | ||
| if ! configure_local_drupal_setup; then | ||
| echo_red "✗ Setup failed." | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| if collection_exists; then | ||
| echo_yellow "Running search index rebuild..." | ||
| if ! rebuild_index; then | ||
| echo_red "✗ Index rebuild failed." | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo_yellow "↳ No collection found, skipping index rebuild. Run with -c to configure." | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo_green "✓ Solr setup complete and search index rebuilt successfully." | ||
| echo_green "Visit ${DDEV_PRIMARY_URL}/admin/config/search/search-api/server/${SOLR_SERVER_NAME}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| #!/usr/bin/env bash | ||
| #annertech-ddev | ||
|
|
||
| ## Description: Installs ddev/ddev-solr addon and will attempt to update solr for upsun configuration | ||
| ## Usage: solr9-migrate | ||
| ## Example: "ddev solr9-migrate" | ||
|
|
||
| set -e | ||
|
|
||
| RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' | ||
| echo_red() { echo -e "${RED}$1${NC}" >&2; } | ||
| echo_green() { echo -e "${GREEN}$1${NC}"; } | ||
| echo_yellow() { echo -e "${YELLOW}$1${NC}"; } | ||
|
|
||
| SERVICES_FILE=".platform/services.yaml" | ||
| SOLR_CONF_SOURCE="web/modules/contrib/search_api_solr/solr-conf-templates/9.x" | ||
|
|
||
| echo_yellow "Installing ddev/ddev-solr addon..." | ||
|
|
||
| remove_old_config() { | ||
| echo_yellow "Removing old ddev solr configuration..." | ||
|
|
||
| if [ -f .ddev/docker-compose.solr.yaml ]; then | ||
| git rm .ddev/docker-compose.solr.yaml | ||
| else | ||
| echo_yellow "↳ .ddev/docker-compose.solr.yaml not found, skipping." | ||
| fi | ||
|
|
||
| if git ls-files .ddev/solr | grep -q .; then | ||
| git rm -rf .ddev/solr | ||
| else | ||
| echo_yellow "↳ No tracked files in .ddev/solr, skipping." | ||
| fi | ||
|
|
||
| git commit -m "remove the ddev drupal solr" || echo_yellow "↳ Nothing to commit for old config removal." | ||
| echo_green "✓ Old ddev solr configuration removed." | ||
| } | ||
|
|
||
| install_new_addon() { | ||
| echo_yellow "Installing ddev/ddev-solr..." | ||
| ddev add-on get ddev/ddev-solr | ||
| git add .ddev/ | ||
| git commit -m "install ddev/ddev-solr" | ||
| echo_green "✓ ddev/ddev-solr installed." | ||
| } | ||
|
|
||
| configure_upsun() { | ||
| echo_yellow "Configuring upsun solr..." | ||
|
|
||
| # Replace solr conf directory | ||
| if [ ! -d "$SOLR_CONF_SOURCE" ]; then | ||
| echo_red "✗ Solr config templates not found at $SOLR_CONF_SOURCE. Is search_api_solr installed?" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo_yellow "↳ Removing old solr conf for upsun..." | ||
| OLD_SOLR_CONF=$(find .platform/solr-conf -mindepth 1 -maxdepth 1 -type d ! -name "9.x" 2>/dev/null | head -1) | ||
|
|
||
| if [ -n "$OLD_SOLR_CONF" ]; then | ||
| echo_yellow "↳ Found old solr conf: $OLD_SOLR_CONF, removing..." | ||
| git rm -rf "$OLD_SOLR_CONF" | ||
| git commit -m "remove the old solr configuration ($OLD_SOLR_CONF)" | ||
| else | ||
| echo_yellow "↳ No old solr conf directory found, skipping removal." | ||
| fi | ||
|
|
||
| echo_yellow "↳ Copying new solr 9 configuration..." | ||
| if [ -d ".platform/solr-conf/9.x" ]; then | ||
| echo_yellow "↳ .platform/solr-conf/9.x already exists, overwriting..." | ||
| rm -rf .platform/solr-conf/9.x | ||
| fi | ||
|
|
||
| cp -r "$SOLR_CONF_SOURCE" .platform/solr-conf | ||
| git add .platform/solr-conf | ||
| git commit -m "add new solr 9 configuration" || echo_yellow "↳ Nothing to commit for solr 9 configuration." | ||
| echo_green "✓ Old solr configuration replaced with solr 9 configuration." | ||
|
|
||
| # Update services.yaml | ||
| if [ ! -f "$SERVICES_FILE" ]; then | ||
| echo_red "✗ File not found: $SERVICES_FILE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo_yellow "Updating $SERVICES_FILE..." | ||
|
|
||
| # Solr version | ||
| if grep -q "type: solr:9.4" "$SERVICES_FILE"; then | ||
| echo_yellow "↳ Solr version already updated, skipping." | ||
| else | ||
| CURRENT_VERSION=$(grep -E 'type: solr:' "$SERVICES_FILE" | awk -F'solr:' '{print $2}' | xargs) | ||
| sed -i 's/type: solr:[0-9]\+\.[0-9]\+/type: solr:9.4/g' "$SERVICES_FILE" | ||
| echo_green "✓ solr:${CURRENT_VERSION} -> 9.4" | ||
| fi | ||
|
|
||
| # Solr core name | ||
| if grep -q "maincore" "$SERVICES_FILE"; then | ||
| echo_yellow "↳ Solr core name already updated, skipping." | ||
| else | ||
| sed -i 's/solr8core/maincore/g' "$SERVICES_FILE" | ||
| echo_green "✓ solr8core -> maincore" | ||
| fi | ||
|
|
||
| # Solr conf_dir | ||
| if grep -q "solr-conf/9.x" "$SERVICES_FILE"; then | ||
| echo_yellow "↳ Solr conf_dir already updated, skipping." | ||
| else | ||
| sed -i 's|conf_dir: !archive "solr-conf/8\.x"|conf_dir: !archive "solr-conf/9.x"|g' "$SERVICES_FILE" | ||
| echo_green "✓ solr-conf/8.x -> solr-conf/9.x" | ||
| fi | ||
|
|
||
| echo "" | ||
| echo_yellow "Review changes with: 'git diff $SERVICES_FILE'" | ||
| echo_yellow "If changes look good, commit with: 'git commit $SERVICES_FILE -m \"update solr to 9 configuration\"'" | ||
| } | ||
|
|
||
| remove_old_config | ||
| install_new_addon | ||
| configure_upsun | ||
|
|
||
| echo "" | ||
| echo_green "✓ ddev-solr installed successfully." | ||
| echo_yellow "↳ Running 'ddev restart' to apply changes." | ||
| echo_yellow "↳ After restart, run 'ddev solr9 -c' to configure Solr and rebuild the index." | ||
| ddev restart | ||
| echo_green "✓ Done. Solr will be available at: ${DDEV_PRIMARY_URL}:8983" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this break all projects that update the add-on but haven't updated SOLR yet?
What is our plan of action here? We update everything at the same time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah i was thinking we would be updating everything as it should be, but i guess we could still do that and move the solr settings file to its own like the redis, e.g settings.ddev.solr.php and copy it in with the new command solr9-local, as its not a requirement on every project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would personally prefer the single file over multiple ones, feels like noise, but it's not a bad idea.
In any case, lets run this against a couple of projects next week, see how it works, and then merge it.