opsmill / infrahub

Infrahub - A new approach to Infrastructure Management
https://opsmill.com/
GNU Affero General Public License v3.0
176 stars 7 forks source link

bug: The schema_hash has not been loaded for this branch #3409

Closed pietos closed 1 week ago

pietos commented 3 months ago

Component

No response

Current Behavior

On a fresh installation one of our developers gets the following error:

[2m2024-05-20T20:01:15.962019Z[0m [[31m[1merror [0m][1mTraceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 734, in lifespan async with self.lifespan_context(app) as maybe_state: File "/usr/local/lib/python3.12/contextlib.py", line 210, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "/source/backend/infrahub/server.py", line 78, in lifespan await app_initialization(application) File "/source/backend/infrahub/server.py", line 59, in app_initialization await initialization(db=db) File "/source/backend/infrahub/core/initialization.py", line 77, in initialization hash_in_db = default_branch.active_schema_hash.main ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/source/backend/infrahub/core/branch.py", line 97, in active_schema_hash raise InitializationError("The schema_hash has not been loaded for this branch") infrahub.exceptions.InitializationError: The schema_hash has not been loaded for this branch [0m [[34m[1muvicorn.error[0m] [2m2024-05-20T20:01:15.962292Z[0m [[31m[1merror [0m][1mApplication startup failed. Exiting.[0m [[34m[1muvicorn.error[0m]

photo_2024-05-22_14-06-14 (2)

Expected Behavior

No response

Steps to Reproduce

Latest code from the Development branch Docker compose pull In the compose file only changed the INFRAHUB_ADDRESS & INFRAHUB_INTERNAL_ADDRESS to localhost docker compose up --build

Additional Information

Tested on: Develop branch Docker 26.1.1 Ubuntu 22.04 LTS 64bit

We tried removing all the volumes and starting from scratch, but he kept having this error.

dgarros commented 3 months ago

most likely this is related to changing INFRAHUB_ADDRESS & INFRAHUB_INTERNAL_ADDRESS to localhost Similar to #3407, we need to fix the error message to provide something more actionable that helps with the resolution

petercrocker commented 2 months ago

I could reproduce a similar issue when I followed the backend development guide steps: https://develop.infrahub.pages.dev/development/backend

I started running the e2e tests: INFRAHUB_LOG_LEVEL=CRITICAL pytest -v backend/tests/unit but abandoned them partway through. This leaves the database in an inconsistent state. The fix in my case was:

infrahub db init

Note this applies to the development workflow only.

ogenstad commented 1 month ago

I'm removing this from the milestones for now as I've not been able to reproduce it, please add more comments if this shows up again.

dgarros commented 1 week ago

Closing this issue since this hasn't come up recently, please reopen it if the issue is still present