Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: implement runtime configuration package with multi-org support #14470

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

Closed
wants to merge 19 commits into from

Conversation

dannykopping
Copy link
Contributor

@dannykopping dannykopping commented Aug 28, 2024

RFC.

What this does

Adds a new runtimeconfig package for managing all runtime related configuration. The goal of this package is to create a consistent method for CRUD on runtime configuration (as opposed to startup values).

The motivation and driver is mutli-org. Multi org settings must be configured at runtime. Instead of creating ad-hoc CRUD operations to a key/val store, this package creates a single code path for all settings.

Design

The design uses a Manager singleton that produces Resolvers to enable a cache layer in the future. A pure singleton cannot be used as the Resolver requires a database.Store, which could be a tx. So the user of the package must create the Resolver on demand with their local instance of the db.

Usage

The design is intentionally created so that we can deprecate startup values in favor of runtime in the future. The DeploymentEntry type specifically uses startup values as a fallback.

This will allow us to move some startup values into runtime, which has been a sticky point for configuring aspects of coder for awhile now.

Future work

Caching layer :: #14586

A follow up to this PR will be a caching layer that uses pubsub to update it's cached values. Adding a cache layer will make all settings essentially free to read, allowing use in hot paths such as httpmw (as we currently do for startup values).

RBAC layer :: coder/internal#154

When caching is implemented, dbauthz will not be called for cache hits. So this layer, or some layer above, needs to be RBAC aware.

Maybe in the initialize? the New? The field could know it's own RBAC properties??

Remove old runtime settings in favor of this

Pretty much all these sql queries: https://github.com/coder/coder/blob/e461d2773b5a2f1bd04ff899a922032b373e187f/coderd/database/queries/siteconfig.sql

Upside is we will remove a lot of database.Store queries (always nice to trim)

Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the look aside cache just going to be a wrapper on the resolver?

I like the interface simplicity. The only thing that I don't 100% follow is the usage of reflect. It would be good to drop comments on why it is required.

@dannykopping dannykopping force-pushed the dk/runtime-configs branch 3 times, most recently from 3650ee6 to 12e798f Compare September 4, 2024 12:06
@dannykopping dannykopping changed the title WIP: runtime config implementation Runtime config implementation proposal Sep 4, 2024
@Emyrk Emyrk changed the title Runtime config implementation proposal feat: runtime configuration package that support organization namespaces Sep 6, 2024
@Emyrk Emyrk changed the title feat: runtime configuration package that support organization namespaces feat: runtime configuration package with multi-org support Sep 6, 2024
@Emyrk Emyrk changed the title feat: runtime configuration package with multi-org support feat: implement runtime configuration package with multi-org support Sep 6, 2024
@Emyrk Emyrk marked this pull request as ready for review September 6, 2024 14:19
@dannykopping
Copy link
Contributor Author

@Emyrk good to go 👍

Emyrk and others added 6 commits September 6, 2024 10:19
* chore: refactor entry into deployment and runtime

RuntimeEntry has no startup value, and omits functions required
to be serpent compatible.

Co-authored-by: Danny Kopping <[email protected]>

---------

Co-authored-by: Danny Kopping <[email protected]>
@Emyrk Emyrk force-pushed the dk/runtime-configs branch from 0f7deba to 9f546d0 Compare September 6, 2024 15:19
@Emyrk Emyrk requested a review from johnstcn September 9, 2024 14:35
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to unblock.

@dannykopping
Copy link
Contributor Author

@github-actions github-actions bot deleted the dk/runtime-configs branch March 7, 2025 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This issue is like stale bread.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants