Terraform Enterprise Upgrade Fails with Error: 'No-Code Provisioning: Could not get module metadata'
Problem
The Terraform Enterprise application may fail to start when upgrading to versions v202310-1, v202311-1, v202312-1, or v202401-1. This failure occurs because the PopulateWorkspaceNoCodeModuleVersion migration fails.
The Docker container logs show an error similar to the following.
== 20230821102201 PopulateWorkspaceNoCodeModuleVersion: migrating ============"}0/45 0% calculating..."}[ERROR] msg=No-Code Provisioning: Could not get module metadata name=<MODULE> provider=<PROVIDER> version=<VERSION> organization=<ORG> response={"errors":["Error loading module metadata"]}"}Cause
The PopulateWorkspaceNoCodeModuleVersion is a required migration that must complete successfully for the application to start. The migration fails when the module metadata endpoint returns a 500 error. This occurs in a specific scenario where Terraform Enterprise looks up metadata for a module version that did not ingress correctly.
Solution
HashiCorp Engineering released a hotfix for this issue in Terraform Enterprise version v202401-2. In this version, the module metadata endpoint returns a 404 response instead of a 500 response when looking up a module version that failed to ingress. This change prevents the migration from failing when it encounters a module version in an unhealthy state.
To recover the environment, you must roll back the application. Follow your standard rollback procedures, and then upgrade directly to v202401-2 or a later version during your next upgrade attempt.
Additional Information
For more details on this fix, refer to the Terraform Enterprise v202401-2 release notes.