Menus unset from locations on deploy

This is an issue I’ve been trying to track down that only affects some of my trellis installs - on deploy, menus become unset from their respective menu locations. The menus are still there, but I’m hoping to prevent this to keep deploy testing time down.

Any ideas what might be causing this?

Are you using a Sage-based theme?

Does it happen predictably?

Is your Trellis relatively up to date?

1 Like

This trellis is not up to date (Once things go into production, I honestly have a lot of difficulty updating trellis and rebuilding droplets isn’t always a good option on my end - Is there a discussion about procedures for updating trellis on production sites? I’d love to improve my process here but the docs are light on this information) This is circa 2016 Trellis, so it’s getting old school.

It happens predictably on these installs, and this is a Sage 8 theme.

Is it feasible to set up a new droplet with a fresh copy of Trellis, some demo data, and one of your themes to see if the problem follows you there?

1 Like

I can give this a shot, just have to build a process for it, but I can also see the value. Just need to be pretty careful not to bork it up on my end. I’m very eager to make the process of updating trellis on production servers a lot more manageable - especially with Ubuntu security patches - because right now each droplet rebuild is at least a day of error checking and testing with all our client data unless the process can be a bit more streamlined. Back in 2016 Trellis updates could be a lot more disruptive, and some patches back then broke stuff and I got a bit gunshy about keeping on the bleeding edge of Trellis, and tried to stay up to date with stable releases. I know that’s something I just need to get over :wink:

(I also see the ongoing discussion about the upgrade process and documentation on Slack now - thanks for continuing to think through this. All our sites are on DO, few of them use media storage offsite but those that do are on AWS, no remote DBs, pretty much everything I have uses Let’s Encrypt SSL)

I don’t doubt that your data checking is valuable, but I’ve had nothing but luck in rebuilding droplets simply by wp db export'ing the database (and saving it local) and copying uploads local, rebuilding the droplet, reprovisioning with Trellis, and then wp db import'ing the database and uploading the uploads.

Do you have more complicated data that needs more thorough checking than that?

The rsync process for uploads is just pretty time consuming so we couldn’t do this on a regular basis (and then for me typically needs a ownership change www-data after completion). I find there’s little things like that that come up which are not hard to execute, but they can be hard to diagnose depending on which version of Trellis you’re coming from.

In the past, reprovisioning SSL certificates was another glitch with this process but I believe that should be fairly stable now.

Our clients all present events on tight budgets, so they can generate tons of of media content in a year , and we haven’t been able to account manage them (yet!) into offsite media libraries, which would greatly simplify things.

I’ll give this a try and document any major glitches that come up. I would love to get this process and common troubleshooting steps for updating Trellis on production environments into the Docs, and would be happy to contribute to that once I’ve run through the process a few times.

2 Likes

Follow up on this issue: I was able to successfully update Trellis (woo hoo!) and deploy / update the production server without really needing to rebuild the droplet, so the backup just ended up looking pretty and holding my hand during the process, which is fine by me.
But the update to Trellis also didn’t end up correcting this problem of missing menus on deploy. I’m still not sure what’s causing it - it might be some odd effect of one of my deploy hooks, and given that other projects don’t have this problem I think it’s a quirk of this project, not a bug with Trellis or Bedrock.

But I was able to write up a deploy hook that corrects this issue via WP CLI as the deploy finalizes. Hopefully this helps anyone else with this issue - you’d just need to modify your menu slug and location name in the snippet below:

# Add to deploy-hooks/finalize-after.yml
- name: Select Main Menu Location
  command: wp menu location assign [menu-slug] [menu-location]
  args:
    chdir: "{{ deploy_helper.new_release_path }}/web/wp"

Oh! And I also have some procedures written up for updating and deploying a Trellis update on an existing project and production with the following conditions -

  • Mac OS X
  • Trellis is set up as a git subtree with --prefix=trellis so that it’s easier to merge into a full roots stack git repo
  • Ansible installed via pip using virtualenv, and assuming you want to maintain multiple versions of ansible in different environments

Let me know if this would be helpful to post somewhere or add as a pull request to the docs.

A pull request to the docs would be very welcome. :slight_smile:

It’s a challenging topic and may take a bit of collaboration, so don’t invest a lot of time polishing initially.