0

After many hurdles, struggles, and "learning moments", I pushed my site to staging successfully. Unfortunately, I am running into numerous issues when I try to push updates to a deployed site.

I read this question where the answer was basically that every deployment/update process is going to be different and you have to figure it out yourself. I researched this and came up with a process, but it is broken and results in a failed update, or loss of data added by test users. If I use this process in production I am concerned it will also result in an outage, so I am hoping to iron it out and understand what I'm doing wrong.

Change Context

In this case, assume I deployed a version of the site to staging. After this, I make local changes to the site, including:

  • Deleting a SAML module that is causing issues and replacing it with another module
  • Configuration changes including views and custom content type changes
  • Styling changes to my custom theme

In the meantime, the staging site is being tested, so users have created content. In other words, I can't simply import my local database, and instead need to update the staging database with any config changes that occurred in my local site. I also .gitignore my settings.php file and my files folder.

Lastly, all of these changes are working locally and dummy content in my local database is behaving as expected. It is only the staging site that is having problems when I try to pull my local changes and update the database.

Current Process

This is the broken process I have now. The steps marked i) are ones I found when researching the process, but which do not work for me. The steps marked ii) and subsequent steps are the workarounds I attempted to fix the issue, but either seem dubious, or outright fail to it.

  1. I make changes mentioned in the above context, and run drush cex to export my config.
  2. Using git, I merge changes into my main branch.
  3. i) I SSH into the staging server and attempt to pull the changes, but this results in an error saying that the pull failed because git would overwrite a large list of files. I don't have the list any more, but they included composer.json which I am okay to replace, but also includes numerous other files that were created automatically or are module dependencies.
  4. ii) I do a git reset --hard and git pull again, which works this time, but is slightly concerning because of the destroyed files.
  5. i) I run drush cim which results in the error:
[error]  Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization.

Unable to install the <em class="placeholder">miniorange_saml</em> module since it does not exist. in Drupal\Core\Config\ConfigImporter->validate() (line 814 of /var/www/websites/cabstg/web/core/lib/Drupal/Core/Config/ConfigImporter.php).
  1. ii) I figured this occurred because locally, I uninstalled the module before removing it from my composer.json and modules folder. When I pulled the change, it removed this module without uninstalling it from the staging database. I found answers that suggested to re-add the module and remove it as an admin so that it is removed from the staging database, then to remove it from root. I ran composer require 'drupal/miniorange_saml:^3.0' in staging, then manually uninstalled it, removed it from composer, and ran composer update like I did locally to remove this module. Then, I run Drush cim again. Unfortunately, it results in the same error once again.

  2. iii) I took the additional step of searching my config directory for "miniOrange" but could not find it, so I do not why Drush cim is attempting to "install the miniorange_saml" in the first place. If anything, it should be uninstalling miniorange and any related configuration/data.

  3. iiii) I ran Drush updb in case this error is caused by an old entry in the database, and rerun Drush cim but this does not work.

From here, I am not sure how to proceed further and I am forced to re-deploy the site. This means that I can either deploy a backup without the changes I made so I can keep the data added by users in staging, or I can push my change and import my working local database at the cost of losing content that the users added.

I feel like I am missing a step or misunderstanding this process. How do I push this change correctly?

Additional info

I read numerous questions on stack exchange with a similar error, but most of these were caused by blocks and not modules. I attempted the solutions where they seemed applicable, but no solution has worked for me yet.

5
  • In step 5)i, is the module code present when that command runs, or isn't it?
    – mona lisa
    Dec 8, 2023 at 18:40
  • First deployment should disable the module (removed entry in core.extension.yml and removed module config). Second deployment should remove the module from the filesystem (via compser.json/.lock). As @cilefen says: The module needs to be present to get uninstalled, to get possible uninstall hooks in that module run and clean up a bit. You can't uninstall a module that's not there.
    – leymannx
    Dec 8, 2023 at 18:49
  • 1
    I am ashamed to say I missed the obvious. Drush cex exports to my files/ directory by default which is in my .gitignore. The config folder contained outdated config from before, which is why it was failing. I used cyberduck to delete the old config folder and upload the new one, and "[success] The configuration was imported successfully." Dec 8, 2023 at 18:52
  • Does this answer your question? Order of drush commands for automated deployment?
    – leymannx
    Dec 8, 2023 at 18:52
  • Hahaha, we've all been there. Glad you sorted it out.
    – leymannx
    Dec 8, 2023 at 18:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.