Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datacube OWS doesn't start up if there's no actual config file #1074

Open
alexgleith opened this issue Oct 9, 2024 · 4 comments
Open

Datacube OWS doesn't start up if there's no actual config file #1074

alexgleith opened this issue Oct 9, 2024 · 4 comments

Comments

@alexgleith
Copy link
Contributor

Description

Running the new 1.9 version of Datacube OWS that's configured using environment variables crashes if there's no config file at all.

Steps to Reproduce

  1. Configure OWS using env vars (ODC_DEFAULT_DB_USERNAME, ODC_DEFAULT_DB_PASSWORD, ODC_DEFAULT_DB_DATABASE)
  2. Note that datacube-ows-update command works fine
  3. Launching OWS results in the below error
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/local/lib/python3.10/dist-packages/datacube_ows/wsgi.py", line 20, in <module>
    from datacube_ows.ogc import app  # isort:skip
  File "/usr/local/lib/python3.10/dist-packages/datacube_ows/ogc.py", line 35, in <module>
    cfg = parse_config_file()
  File "/usr/local/lib/python3.10/dist-packages/datacube_ows/startup_utils.py", line 176, in parse_config_file
    cfg = get_config()
  File "/usr/local/lib/python3.10/dist-packages/datacube_ows/ows_configuration.py", line 1562, in get_config
    cfg = OWSConfig(refresh=refresh, called_from_update_ranges=called_from_update_ranges)
  File "/usr/local/lib/python3.10/dist-packages/datacube_ows/ows_configuration.py", line 1269, in __init__
    self.parse_global(cast(CFG_DICT, cfg["global"]), ignore_msgfile)
  File "/usr/local/lib/python3.10/dist-packages/datacube_ows/ows_configuration.py", line 1366, in parse_global
    self.default_env = ODCConfig.get_environment(env=default_env)
  File "/usr/local/lib/python3.10/dist-packages/datacube/cfg/api.py", line 159, in get_environment
    cfg = ODCConfig(paths=config, raw_dict=raw_config)
  File "/usr/local/lib/python3.10/dist-packages/datacube/cfg/api.py", line 112, in __init__
    text = find_config(paths)
  File "/usr/local/lib/python3.10/dist-packages/datacube/cfg/cfg.py", line 88, in find_config
    raise ConfigException("No configuration file found in the provided locations")
datacube.cfg.exceptions.ConfigException: No configuration file found in the provided locations

Context (Environment)

datacube-ows version (datacube-ows-update --version):

1.9.0rc1.post25+ga9eacd5

ows_config.py file (link, sample code)

Config root

datacube product metadata (datacube product show product_name)

Not relevant.

Further notes

Running with an empty config file (like echo "[default]" > /tmp/datacube.conf, and an environment variable set as ODC_CONFIG_PATH=/tmp/datacube.fong) works fine.

@SpacemanPaul
Copy link
Contributor

Don't forget $ODC_DEFAULT_INDEX_DRIVER (if using postgis) and use $ODC_DEFAULT_DB_URL in preference to the individual DB_ elements - iirc the Dockerfile doesn't pass the individual DB_ elements on - you must use _DB_URL instead.

@alexgleith
Copy link
Contributor Author

Don't forget $ODC_DEFAULT_INDEX_DRIVER (if using postgis)

Yep, that's set to postgis.

and use $ODC_DEFAULT_DB_URL in preference

This is hard to do in kubernetes, when some parts of the URI come from some places and some from others.

@SpacemanPaul
Copy link
Contributor

Then you'll probably need to write your own docker-compose.yaml file and possibly make changes to the Docker image itself. The current 1.9 docker build assumes DB_URL format.

@alexgleith
Copy link
Contributor Author

I have a workaround, it's fine. But I still think it's a bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants