farmOS will not update. Wrong volume mount

I’ll move this discussion from the chatroom to here…

I learned that my volume mapping was wrong, so the docker never was properly updated.

I made a snapshot of these 2 containers

farmos
 |-- farmos_db_1
 |-- farmos_www_1

Created a new stack from those images:

my_restore_of_farmos 
|-- my_restore_of_farmos-db-1
|-- my_restore_of_farmos-www-1

Then I copied the volumes over, and I had a working duplicate to play with.

I changed the volum mount from

 volumes:
      - './farmos-www:/opt/drupal'

to


 volumes:
      - './farmos-sites:/opt/drupal/web/sites'

Now the fun begins… Some modules are missing.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "document" plugin does not exist. Valid plugin IDs for Drupal\farm_entity\AssetTypeManager are: animal, equipment, group, land, material, plant, seed, sensor, structure, water in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php). 

How do I fix the document plugin?
I have this in my composer.json


    "require": {
        "drupal/farm_template": "^1.0@alpha",
        "drupal/backup_migrate": "^5.1",
        "drupal/farm_calendar": "^1.1",
        "drupal/farm_map_custom_layers": "^1.2",
        "drupal/farm_nrcs": "^2.2",
        "drupal/farm_organic": "^2.1",
        "drupal/farm_project_plan": "1.1.1",
        "drupal/farm_template": "^1.0@alpha",
        "drupal/farmos_asset_link": "^1.0@alpha",
        "drupal/phpmailer_smtp": "^2.2",
        "farmier/hosting": "^1.0",
        "farmos/farmos": "3.2.3",
        "mstenta/farm_document": "1.x-dev",
        "oomphinc/composer-installers-extender": "^2.0",
        "wikimedia/composer-merge-plugin": "^2.0"
    },
1 Like
drush cr
error - Document plugin missing

drush config:status:
Everything is listed as "Only in db"

drush config:export
drush config:status
 [notice] No differences between DB and sync directory.

composer update
fixes a few things

Still get this

@pat You must have had the farm_document module installed, and maybe you had the files for it in web/modules (just guessing). So now that it is no longer being mounted into the container, Drupal can’t find it anymore.

You can try putting farm_document into web/sites/all/modules and then drush cr. That should fix it.

1 Like

Ah wait… just read your first comment and saw that you have a composer.json file with other modules. I didn’t realize you were including other modules. I thought you were just trying to get a “stock” farmOS updated.

This changes things. Since you are maintaining a composer.json with other dependencies, you are essentially taking responsibility for maintaining your own farmOS codebase (not just using the “stock” one with only core modules). This means the codebase that is included in the Docker container is not enough for you.

You actually might need to change back to mounting the whole codebase after all, and you will need to update your codebase via composer instead of by just pulling the latest Docker image.

More explanation:

The Docker image essentially serves two purposes: 1. It sets up the server environment with all of the prerequisite dependencies for Drupal and farmOS (including Apache, PHP, server configuration, etc), and 2. it contains a “default” build of the Drupal+farmOS codebase in /opt/drupal. This “default” build just uses the composer.json from here: GitHub - farmOS/composer-project

Since you want to include other community modules, that means you are essentially taking control over the composer.json and maintaining your own build. This means that the code that comes in the Docker container in /opt/drupal is not enough, and you need to override it completely. There are two ways to do this: 1. mount the entire /opt/drupal directory in as a volume, or 2. build your own Docker image, that extends from farmos/farmos.

Option 1 is a bit simpler (and is closer to what you had originally when you were mounting all of /opt/drupal). It just means that you need to learn to use composer commands to update your codebase.

I would recommend reading through this documentation to understand everything: Building farmOS with Composer | farmOS

Ultimately, in order to update farmOS, you will need to edit your composer.json file and change "farmos/farmos": "3.2.3" to "farmos/farmos": "3.3.3", then run composer update && composer update (it’s important to run it twice, see docs I just linked for why). This will instruct composer to download the new version of farmOS, and update all other dependencies. It’s a good idea to put your composer.json file in source control. For reference, this is the repository I use to build the default platform on Farmier: https://github.com/farmier/composer-project - so your repo would look similar to that (minus the settings.platform.php, which is specific to Farmier).

Sorry if I sent you down the wrong track earlier when I suggested changing your volume mount to /opt/drupal/web/sites. I wasn’t considering the fact that you might be including other modules.

Hope this all makes sense.

1 Like

Ok. Nice to narrow it down. Seems clear enough.
I will read up on in. (Git repo gives 404 error)

So:

Change version number in 'composer.json'
And 2x 'composer update'

should update the instance without issues.

And my docker image will always be

image: farmos/farmos:3.2.2

Ah right, that repo isn’t public. But it doesn’t matter - you have what you need already in composer.json.

Best practice would be to update your Docker container version to match the farmOS version in your composer.json. That way you can be sure you have everything you need in the Docker container, and are in line with automated tests.

You could potentially just set it to image: farmos/farmos:3.x if you don’t want to update it every time. But you will need to change that when it’s time to upgrade to farmOS v4. So maybe better to just get in the practice of keeping them updated together.

2 Likes

Eventually I managed to clone my production container, and rsync the volumes.

Now I can test updating for real.

Added 3.3.3 to compser.json
composer update
composer update

I get

The website encountered an unexpected error. Try again later.

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "view.farm_log_quantity.page" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 211 of core/lib/Drupal/Core/Routing/RouteProvider.php).

Drupal\Core\Routing\UrlGenerator->getRoute('view.farm_log_quantity.page') (Line: 276)
Drupal\Core\Routing\UrlGenerator->generateFromRoute('view.farm_log_quantity.page', Array, Array, 1) (Line: 108)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('view.farm_log_quantity.page', Array, Array, ) (Line: 765)
Drupal\Core\Url->toString() (Line: 30)
farm_ui_views_help('farm.dashboard', Object) (Line: 96)
Drupal\help\Plugin\Block\HelpBlock->Drupal\help\Plugin\Block\{closure}(Object, 'farm_ui_views') (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('help', Object) (Line: 94)
Drupal\help\Plugin\Block\HelpBlock->build() (Line: 171)
Drupal\block\BlockViewBuilder::preRender(Array)
call_user_func_array('Drupal\block\BlockViewBuilder::preRender', Array) (Line: 113)
Drupal\Core\Render\Renderer->doTrustedCallback('Drupal\block\BlockViewBuilder::preRender', Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 870)
Drupal\Core\Render\Renderer->doCallback('#pre_render', 'Drupal\block\BlockViewBuilder::preRender', Array) (Line: 432)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
Drupal\Core\Render\Renderer->render(Array) (Line: 484)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 161)
__TwigTemplate_7e9199ef6b9fe182069ae3d7b09b9000->doDisplay(Array, Array) (Line: 387)
Twig\Template->yield(Array, Array) (Line: 343)
Twig\Template->display(Array) (Line: 358)
Twig\Template->render(Array) (Line: 51)
Twig\TemplateWrapper->render(Array) (Line: 33)
twig_render_template('themes/gin/templates/page/page.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 491)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
Drupal\Core\Render\Renderer->render(Array) (Line: 484)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 92)
__TwigTemplate_f2572ecb4cd95d2c7ea879ff01c0150e->doDisplay(Array, Array) (Line: 387)
Twig\Template->yield(Array, Array) (Line: 343)
Twig\Template->display(Array) (Line: 358)
Twig\Template->render(Array) (Line: 51)
Twig\TemplateWrapper->render(Array) (Line: 33)
twig_render_template('themes/gin/templates/html.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 491)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
Drupal\Core\Render\Renderer->render(Array) (Line: 158)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 153)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 54)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Tried drush cr and drush updb
Nothing changed.

What does this indicate?
Can I do some drush woodoo to fix this?

Hmm.

I went to /admin/reports/status
That page was fine. And then everything else was fine too.

Some magic after all…

2 Likes

Glad you got it working @pat!

Once you update the codebase (via composer update), the database updates MUST be run before any other code (before you access any farmOS page or run any other Drush commands).

So you should run drush updb directly after composer update. Then run drush cr.

This is documented as steps 3 and 4 here (right after step 2 which is updating the code): Updating farmOS | farmOS

  1. Run automated updates. Navigate to https://[hostname]/update.php in your browser and follow the steps to run automated updates. It is important to do this before using the new version of farmOS to ensure that any necessary changes to the database or configuration are made.
  2. Clear caches. farmOS caches can be cleared by going to https://[hostname]/admin/config/development/performance in your browser and clicking “Clear all caches”, or via the command line with Drush: drush cr. Cache clearing is only necessary if no updates are performed during update.php, otherwise they will be cleared automatically.

This probably explains why you received the error Route "view.farm_log_quantity.page" does not exist. That route would not exist until the database updates were run because it was introduced in a recent version.

3 Likes

Thanks for info.

2 Likes