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

feat(*): Adds initial config interface implementation #4

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

thomastaylor312
Copy link
Collaborator

This is the most basic functionality needed to have a shared config interface that all components could use. It's goal is simplicity. There are many things we could add/polish, and all of those are called out in the documentation. For reference, this is what we are using in wasmCloud, but we aren't married to the interface as is. What we want is the ability for any runtime to be able to provide configuration to the components it is running in a standardized way. That will make it possible to actually have the cross runtime/platform experience that components promise

@thomastaylor312
Copy link
Collaborator Author

Please note that I'll be intermittently available the rest of the week and completely unavailable next week, so if I don't respond, that is why!

Copy link
Member

@lukewagner lukewagner left a comment

Choose a reason for hiding this comment

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

From a first glance, this looks reasonable to me; nice! I included some nits, but I don't feel super-strongly about them, so happy to discuss.

wit/runtime_config.wit Outdated Show resolved Hide resolved
wit/runtime_config.wit Outdated Show resolved Hide resolved
wit/world.wit Outdated Show resolved Hide resolved
Copy link
Collaborator

@Mossaka Mossaka left a comment

Choose a reason for hiding this comment

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

Thanks for contributing. Mostly LGTM just added one comment on the README.

README.md Outdated Show resolved Hide resolved
Copy link

@lann lann left a comment

Choose a reason for hiding this comment

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

I briefly looked at this months ago (#2) and came to the conclusion that - for the use cases I was coming up with - there wasn't much benefit to a separate runtime config interface over just implementing as a KV store.

As @Mossaka asked inline I think it would be really helpful to understand concrete use cases here and in particular where those use cases wouldn't be well served by wasi-keyvalue.

/// Gets a single opaque config value set at the given key if it exists
get: func(key: string) -> result<option<list<u8>>, config-error>;
/// Gets a list of all set config data
get-all: func() -> result<list<tuple<string, list<u8>>>, config-error>;
Copy link

Choose a reason for hiding this comment

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

What are some use cases for get-all?

Copy link

Choose a reason for hiding this comment

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

Some apps and libraries iterate over environment variables to look for prefix matches, e.g. "find all variables starting with FOO_BAR_" as a way of encoding a variable-length map or list. So perhaps this would make it easier to port such software.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah @dicej had it right. There is also a use case where you want to fetch all the config once and then iterate over it in memory rather than doing individual fetches

@thomastaylor312
Copy link
Collaborator Author

Great question @lann! So there are definitely some distinct differences between KV and config. But more importantly, the ultimate goal here are interfaces that increase interoperability. This is the absolute bare minimum interface that heads towards that goal and allows a component to indicate very clearly that "I am looking for config" rather than a datastore. Some additional points:

  • Having to do config via a KV means you have to have a KV store available. Some platforms and use cases might not have that immediately available. It also leads to an awkward experience: "To configure your component, write the following keys to Redis before running it."
  • Related to the last point, but there is a difference between a data store and configuration. Yes, config may possibly be derived from a remote database or tool like vault, but more often than not it is also combined with host specific things, for example what k8s passes to pods by default. There is also a reason why things like ConfigMaps and external config exists for K8s and Nomad. You could theoretically have people store stuff directly in etcd/consul and access that, but config is something that most applications need.
  • With those last points in mind, it is also important to note that this is meant to be the least common denominator for interoperability. Not everything is going to use wasi:cli/environment with environment variables (but it could be easily virtualized out with a component that converts from env vars to config values). wasmCloud is obviously my easiest example here, but any system that is running untrusted code or not as a FaaS type system could either not expose or have other security reasons for not wanting to expose environment variables to the system, instead delegating that layer of control to the host.

This is the most basic functionality needed to have a shared config
interface that all components could use. It's goal is simplicity.
There are many things we could add/polish, and all of those are called
out in the documentation. For reference, this is what we are using in
wasmCloud, but we aren't married to the interface as is. What we want
is the ability for any runtime to be able to provide configuration to
the components it is running in a standardized way. That will make it
possible to actually have the cross runtime/platform experience that
components promise

Signed-off-by: Taylor Thomas <taylor@cosmonic.com>
Copy link

@lhmzhou lhmzhou left a comment

Choose a reason for hiding this comment

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

LGTM

@thomastaylor312
Copy link
Collaborator Author

Hey all (particularly @Mossaka and @devigned)! Now that we're in the new year, I'd like to circle back to this and see if we can get it approved or have a concrete list of things to change. Please let me know your thoughts!

Copy link
Collaborator

@Mossaka Mossaka left a comment

Choose a reason for hiding this comment

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

Asked some questions, otherwise it LGTM

all sorts of crazy things with configuration values! Calling entirely different branches of code,
setting upstream URLs or services, configuring the number of threads to use, etc.
2. toggling on/off feature flags
3. A/B testing

and many more use cases.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is secrets management in-scope?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is an interesting discussion. For now, I'm going to say no. But I think that access to secret values could be through this interface. Implementors (generally hosts) would need to make sure that secret values are injected into the available config

all sorts of crazy things with configuration values! Calling entirely different branches of code,
setting upstream URLs or services, configuring the number of threads to use, etc.
2. toggling on/off feature flags
3. A/B testing

and many more use cases.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some advanced features I've seen from runtime config providers like Google Cloud's Runtime Configurator are:

  • versioning,
  • hierarchy
  • watching

Although this spec does not have to include any of above features but I would like to see they are mentioned somewhere in the spec.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you want those called out as "not addressed right now, but maybe in the future" or do you want it mentioned in some other way?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Calling out as not addressed right now is good.

I am going to merge this PR. This can be added later.

@Mossaka Mossaka merged commit 7207661 into WebAssembly:main Jan 12, 2024
@thomastaylor312 thomastaylor312 deleted the feat/pull-interface branch January 17, 2024 17:53
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

Successfully merging this pull request may close these issues.

6 participants