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

auto-generate consistent environment variables for options #5754

Closed
indirectlylit opened this issue Jul 9, 2019 · 1 comment · Fixed by #8050
Closed

auto-generate consistent environment variables for options #5754

indirectlylit opened this issue Jul 9, 2019 · 1 comment · Fixed by #8050
Assignees
Labels
DEV: backend Python, databases, networking, filesystem... P2 - normal Priority: Nice to have TAG: tech update / debt Change not visible to user
Milestone

Comments

@indirectlylit
Copy link
Contributor

Observed behavior

  • We allow configuration to be set in both options.ini and as environment variables
  • Environment variables usually follow the pattern KOLIBRI_[option_name]
  • We've had a couple recent deviations from this pattern, e.g. SENTRY and OIDC
  • The main reason we allowed vars to be specified separately from options was so that we could still handle some legacy envvars

base_option_spec = {
"Cache": {
"CACHE_BACKEND": {
"type": "option",
"options": ("memory", "redis"),
"default": "memory",
"envvars": ("KOLIBRI_CACHE_BACKEND",),
},
"CACHE_TIMEOUT": {
"type": "integer",
"default": 300,
"envvars": ("KOLIBRI_CACHE_TIMEOUT",),
},
"CACHE_PASSWORD": {
"type": "string",
"default": "",
"envvars": ("KOLIBRI_CACHE_PASSWORD",),
},
"CACHE_LOCATION": {
"type": "string",
"default": "localhost:6379",
"envvars": ("KOLIBRI_CACHE_LOCATION",),
},
"CACHE_REDIS_MIN_DB": {
"type": "integer",
"default": 0,
"envvars": ("KOLIBRI_CACHE_REDIS_MIN_DB",),
},
},
"Database": {
"DATABASE_ENGINE": {
"type": "option",
"options": ("sqlite", "postgres"),
"default": "sqlite",
"envvars": ("KOLIBRI_DATABASE_ENGINE",),
},
"DATABASE_NAME": {"type": "string", "envvars": ("KOLIBRI_DATABASE_NAME",)},
"DATABASE_PASSWORD": {
"type": "string",
"envvars": ("KOLIBRI_DATABASE_PASSWORD",),
},
"DATABASE_USER": {"type": "string", "envvars": ("KOLIBRI_DATABASE_USER",)},
"DATABASE_HOST": {"type": "string", "envvars": ("KOLIBRI_DATABASE_HOST",)},
"DATABASE_PORT": {"type": "string", "envvars": ("KOLIBRI_DATABASE_PORT",)},
},
"Server": {
"CHERRYPY_START": {
"type": "boolean",
"default": True,
"envvars": ("KOLIBRI_CHERRYPY_START",),
},
"CHERRYPY_THREAD_POOL": {
"type": "integer",
"default": calculate_thread_pool(),
"envvars": ("KOLIBRI_CHERRYPY_THREAD_POOL",),
},
"CHERRYPY_SOCKET_TIMEOUT": {
"type": "integer",
"default": 10,
"envvars": ("KOLIBRI_CHERRYPY_SOCKET_TIMEOUT",),
},
"CHERRYPY_QUEUE_SIZE": {
"type": "integer",
"default": 30,
"envvars": ("KOLIBRI_CHERRYPY_QUEUE_SIZE",),
},
"CHERRYPY_QUEUE_TIMEOUT": {
"type": "float",
"default": 0.1,
"envvars": ("KOLIBRI_CHERRYPY_QUEUE_TIMEOUT",),
},
"PROFILE": {
"type": "boolean",
"default": False,
"envvars": ("KOLIBRI_SERVER_PROFILE",),
},
},
"Paths": {
"CONTENT_DIR": {
"type": "string",
"default": "content",
"envvars": ("KOLIBRI_CONTENT_DIR",),
}
},
"Urls": {
"CENTRAL_CONTENT_BASE_URL": {
"type": "string",
"default": "https://studio.learningequality.org",
"envvars": (
"KOLIBRI_CENTRAL_CONTENT_BASE_URL",
"CENTRAL_CONTENT_DOWNLOAD_BASE_URL",
),
},
"DATA_PORTAL_SYNCING_BASE_URL": {
"type": "string",
"default": "https://kolibridataportal.learningequality.org",
"envvars": ("KOLIBRI_DATA_PORTAL_SYNCING_BASE_URL",),
},
},
"Deployment": {
"HTTP_PORT": {
"type": "integer",
"default": 8080,
"envvars": ("KOLIBRI_HTTP_PORT", "KOLIBRI_LISTEN_PORT"),
},
"RUN_MODE": {"type": "string", "envvars": ("KOLIBRI_RUN_MODE",)},
"URL_PATH_PREFIX": {
"type": "string",
"default": "/",
"envvars": ("KOLIBRI_URL_PATH_PREFIX",),
"clean": lambda x: x.lstrip("/").rstrip("/") + "/",
},
},
"Debug": {
"SENTRY_BACKEND_DSN": {
"type": "string",
"envvars": ("KOLIBRI_DEBUG_SENTRY_BACKEND_DSN",),
},
"SENTRY_FRONTEND_DSN": {
"type": "string",
"envvars": ("KOLIBRI_DEBUG_SENTRY_FRONTEND_DSN",),
},
"SENTRY_ENVIRONMENT": {
"type": "string",
"envvars": ("KOLIBRI_DEBUG_SENTRY_ENVIRONMENT",),
},
},
}

Expected behavior

  • In options.py, rather than specifying envvars we should specify envvar_aliases
  • All envvars should be generated by prepending KOLIBRI_ to the option name
  • Most existing envvar definitions can be removed

User-facing consequences

Inconsistent environment variable definitions

Context

0.12.5

@indirectlylit indirectlylit added TAG: tech update / debt Change not visible to user DEV: backend Python, databases, networking, filesystem... labels Jul 9, 2019
@indirectlylit indirectlylit added this to the 0.13.0 milestone Jul 9, 2019
@rtibbles
Copy link
Member

rtibbles commented Jul 9, 2019

Sounds good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... P2 - normal Priority: Nice to have TAG: tech update / debt Change not visible to user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants