Conversation
|
The latest Buf updates on your PR. Results from workflow proto / lint (pull_request).
|
f9611c0 to
e523cdb
Compare
|
We need to ensure at deployment time that a plugin can fulfill the matched name statically. |
Signed-off-by: Bailey Hayes <bailey@cosmonic.com>
e523cdb to
8eb3657
Compare
Signed-off-by: Bailey Hayes <bailey@cosmonic.com>
|
Second commit covers... Deployment-Time ValidationWhen a workload specifies multiple named entries of the same
|
|
Associating a name is similar to how we will on day in the Component Model have a feature called wit templates (currently scoped post-mvp): https://gist.github.com/lukewagner/e4bab34bbe73d4ce9cb6d8959bc69243 The name in this case has two uses, first as the identifier in the * import enumeration (it will be the world name in the future). We're additionally using that same identifier as the identifier for the connection. |
Signed-off-by: Bailey Hayes <bailey@cosmonic.com>
|
suggestion: hold off so we can chat about this post bytecodealliance plumbers summit. |
Named Host Interfaces: Multi-Backend Binding
A component may need multiple implementations of the same interface type (e.g., one
wasi:keyvaluebacked by NATS for caching and another backed by Redis for sessions). Previously, the WorkloadDeployment spec only supported one host interface entry pernamespace:packagecombination --EnsureHostInterfacemerged duplicate entries. This design adds anamefield toHostInterfaceto allow multiple named entries of the same interface type.Design
1. WorkloadDeployment YAML Schema
An optional
namefield on each hostInterface entry. When present, it allows multiple entries of the samenamespace:packageand serves as the identifier components pass to resource-opening functions (e.g.,store::open("cache")).Component code uses the
nameas theidentifierinstore::open:2. Naming Rules
nameis optional. When absent, behavior is identical to before (backwards compatible).namespace:package, all of them must have a non-emptyname.namespace:package.[a-z0-9][a-z0-9-]*(DNS label style).identifierparameter in resource-opening functions (store::open(name)for keyvalue,create-container(name)for blobstore, etc.).3. Type Changes
3a. Go CRD (
HostInterface)File:
runtime-operator/api/runtime/v1alpha1/workload_types.goAdded
Namefield with kubebuilder validation:3b.
EnsureHostInterfaceMerge LogicFile:
runtime-operator/api/runtime/v1alpha1/workload_types.goUpdated to match on
namespace+package+name(was justnamespace+package):3c. Protobuf (
WitInterface)File:
proto/wasmcloud/runtime/v2/wit_interface.protoAdded field 6:
3d. Rust
WitInterfaceFile:
crates/wash-runtime/src/wit.rsAdded
name: Option<String>field. Method changes:instance()namespace:package/name@versionmerge()instance())contains()Hashimplnamein hashDisplayimplnamespace:package [name]/interfaces@versionFrom<&str>3e. Rust
FromConversionsFile:
crates/wash-runtime/src/washlet/mod.rsBoth directions handle the new field:
From<types::v2::WitInterface>: maps empty string toNone, non-empty toSomeFrom<crate::wit::WitInterface>: mapsNoneto empty string,Someto the value4. Runtime Multiplexing
The runtime side would work as follows (for future implementation):
Single plugin per interface type: Only one
wasi-keyvalueplugin registers with the linker. This is a wasmtime constraint (add_to_linkercan only be called once per interface).Multiplexing plugin: A
MultiplexKeyValueplugin wraps multiple backend implementations (NATS, Redis, in-memory, filesystem). It registers once and routesstore::open(identifier)to the correct backend based on thenamefrom the spec.bind_pluginsunchanged: The existing matching logic inbind_plugins()already passes all matchedWitInterfaceentries to the plugin viaon_workload_bind. With named entries, the plugin receives multipleWitInterfaceobjects (one per name), each with its ownconfig. The plugin uses these to configure its routing table.Default fallback: When
nameisNone, the plugin falls back to its default backend (equivalent to single-backend behavior).5. Applicability to Other Interfaces
The
namefield is generic -- it works for any interface type. The routing mechanism is interface-specific:namemaps towasi:keyvaluestore::open(identifier)identifierwasi:blobstorecreate-container(name)namewasmcloud:messagingwasmcloud:postgres6. Backwards Compatibility
All changes are fully backwards compatible:
Nameis optional withomitempty. Existing manifests withoutnamework identically.name: Option<String>defaults toNone. All existing matching/merging/binding logic is unchanged whennameis absent.EnsureHostInterface: When both entries haveName == "", the match condition is the same as before.7. CRD Validation (Future)
Add a validation webhook or CEL rule:
hostInterfacesentries share the samenamespace+package, all of them must have a non-empty, uniquename.namespace+package+nametriple.8. Files Modified
runtime-operator/api/runtime/v1alpha1/workload_types.goNametoHostInterface, updatedEnsureHostInterfaceruntime-operator/api/runtime/v1alpha1/workload_types_test.goproto/wasmcloud/runtime/v2/wit_interface.protonamefield (field number 6)crates/wash-runtime/src/wit.rsname: Option<String>, updatedinstance,merge,Hash,Displaycrates/wash-runtime/src/washlet/mod.rsFrom<WitInterface>conversionscrates/wash-runtime/src/host/mod.rsname: Noneto struct constructionscrates/wash-runtime/src/engine/workload.rsname: Noneto test struct constructionscrates/wash-runtime/tests/integration_*.rsname: Noneto test struct constructions9. Verification
instance()with name, merge with matching/different/unnamed names,containsignoring name,Hashincluding name, andDisplaywith name. All 20 wit tests passing.name: None, preserving identical behavior.