Skip to content

API startup requires /ref to be mounted read-write (cv_cmip7_aft.yaml missing + sqlite journal) #29

@lewisjared

Description

@lewisjared

Deploying climate-ref-frontend:v0.2.3 against the climate-ref-aft Helm chart (0.1.0) against an existing REF state volume surfaces two issues that together force /ref to be mounted read-write in the API pod when a read-only mount should be sufficient.

1. cv_cmip7_aft.yaml missing from packaged climate_ref_core

On startup the API resolves the dimensions CV via climate_ref.config._dimensions_cv_factory:

filename = "cv_cmip7_aft.yaml"
return Path(str(importlib.resources.files("climate_ref_core.pycmec") / filename))

In the worker image (ghcr.io/climate-ref/climate-ref:v0.13.0) the file is present at:

/app/.venv/lib/python3.11/site-packages/climate_ref_core/pycmec/cv_cmip7_aft.yaml

In the frontend image (ghcr.io/climate-ref/climate-ref-frontend:v0.2.3) climate_ref_core is installed but that YAML is not in the wheel, so the API crashes with:

FileNotFoundError: [Errno 2] No such file or directory:
'/app/.venv/lib/python3.11/site-packages/climate_ref_core/pycmec/cv_cmip7_aft.yaml'

The image's build process appears to strip or omit package-data from climate_ref_core. Fixing the frontend image (or vendoring the file) so that the packaged wheel includes climate_ref_core/pycmec/*.yaml resolves this.

Current workaround: an init container copies the file from the worker image onto the shared /ref PVC and the API is pointed at it via REF_DIMENSIONS_CV_PATH.

2. SQLite DB opened read-write at startup

With REF_DATABASE_URL=sqlite:////ref/ref.db (or the default derived from REF_CONFIGURATION), the API opens the DB in read-write mode and SQLite tries to create a journal/WAL sidecar next to the DB file. When /ref is mounted readOnly: true this fails:

OperationalError: (sqlite3.OperationalError) unable to open database file

For a read-only consumer (API just reads the state written by workers), the DB should either be opened via a read-only URI (sqlite:///file:/ref/ref.db?mode=ro&immutable=1&uri=true) or the API should not require write access to /ref at all.

Current workaround: drop readOnly: true on the API's /ref mount.

Environment

  • Chart: climate-ref-aft 0.1.0 (climate-ref-aft PR #7)
  • Worker image: ghcr.io/climate-ref/climate-ref:v0.13.0
  • Frontend image: ghcr.io/climate-ref/climate-ref-frontend:v0.2.3
  • REF core: 0.13.0
  • Kubernetes 1.x, Talos Linux

Suggested fixes

  1. Frontend image build: include climate_ref_core/pycmec/*.yaml in the wheel / image.
  2. API: open the configured SQLite DB with mode=ro&immutable=1 (or accept a URI-form URL) when the API is the sole reader, so /ref can stay read-only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions