Documentation ¶
Overview ¶
Package registry provides a registry of runtimes supported by the running oasis-node. It serves as a central point of runtime configuration.
Index ¶
- Constants
- Variables
- func EnsureRuntimeStateDir(dataDir string, runtimeID common.Namespace) (string, error)
- func GetRuntimeStateDir(dataDir string, runtimeID common.Namespace) string
- func NewRuntimeHostHandler(env RuntimeHostHandlerEnvironment, runtime Runtime, ...) protocol.Handler
- func NewRuntimeHostNotifier(ctx context.Context, runtime Runtime, host host.Runtime, ...) protocol.Notifier
- func NewStorageRouter(runtimeGetter RouterRuntimeStorageFunc, waiter RouterInitWaitFunc) api.Backend
- func ParseRuntimeMap(rawItems []string) (map[common.Namespace]string, error)
- type Registry
- type RouterInitWaitFunc
- type RouterRuntimeStorageFunc
- type Runtime
- type RuntimeConfig
- type RuntimeHostConfig
- type RuntimeHostHandlerEnvironment
- type RuntimeHostHandlerFactory
- type RuntimeHostNode
Constants ¶
const ( // CfgSupported configures a supported runtime ID. CfgSupported = "runtime.supported" // CfgRuntimeProvisioner configures the runtime provisioner. // // The same provisioner is used for all runtimes. CfgRuntimeProvisioner = "runtime.provisioner" // CfgRuntimePaths confgures the paths for supported runtimes. // // The value should be a map of runtime IDs to corresponding resource paths (type of the // resource depends on the provisioner). CfgRuntimePaths = "runtime.paths" // CfgSandboxBinary configures the runtime sandbox binary location. CfgSandboxBinary = "runtime.sandbox.binary" // CfgRuntimeSGXLoader configures the runtime loader binary required for SGX runtimes. // // The same loader is used for all runtimes. CfgRuntimeSGXLoader = "runtime.sgx.loader" // CfgRuntimeSGXSignatures configures signatures for supported runtimes. // // The value should be a map of runtime IDs to corresponding resource paths. CfgRuntimeSGXSignatures = "runtime.sgx.signatures" // CfgRuntimeConfig configures node-local runtime configuration. CfgRuntimeConfig = "runtime.config" // CfgHistoryPrunerStrategy configures the history pruner strategy. CfgHistoryPrunerStrategy = "runtime.history.pruner.strategy" // CfgHistoryPrunerInterval configures the history pruner interval. CfgHistoryPrunerInterval = "runtime.history.pruner.interval" // CfgHistoryPrunerKeepLastNum configures the number of last kept // rounds when using the "keep last" pruner strategy. CfgHistoryPrunerKeepLastNum = "runtime.history.pruner.num_kept" )
const ( // RuntimeProvisionerMock is the name of the mock runtime provisioner. // // Use of this provisioner is only allowed if DebugDontBlameOasis flag is set. RuntimeProvisionerMock = "mock" // RuntimeProvisionerUnconfined is the name of the unconfined runtime provisioner that executes // runtimes as regular processes without any sandboxing. // // Use of this provisioner is only allowed if DebugDontBlameOasis flag is set. RuntimeProvisionerUnconfined = "unconfined" // RuntimeProvisionerSandboxed is the name of the sandboxed runtime provisioner that executes // runtimes as regular processes in a Linux namespaces/cgroups/SECCOMP sandbox. RuntimeProvisionerSandboxed = "sandboxed" )
const ( // MaxRuntimeCount is the maximum number of runtimes that can be supported // by a single node. MaxRuntimeCount = 64 // LocalStorageFile is the filename of the worker's local storage database. LocalStorageFile = "worker-local-storage.badger.db" )
const ( // RuntimesDir is the name of the directory located inside the node's data // directory which contains the per-runtime state. RuntimesDir = "runtimes" )
Variables ¶
var ErrRuntimeHostNotConfigured = errors.New("runtime/registry: runtime host not configured")
ErrRuntimeHostNotConfigured is the error returned when the runtime host is not configured for a specified runtime and a request is made to get the runtime host provisioner.
var Flags = flag.NewFlagSet("", flag.ContinueOnError)
Flags has the configuration flags.
Functions ¶
func EnsureRuntimeStateDir ¶
EnsureRuntimeStateDir ensures a specific per-runtime directory exists and returns its full path.
func GetRuntimeStateDir ¶ added in v0.2100.0
func NewRuntimeHostHandler ¶ added in v0.2103.0
func NewRuntimeHostHandler( env RuntimeHostHandlerEnvironment, runtime Runtime, consensus consensus.Backend, ) protocol.Handler
NewRuntimeHostHandler returns a protocol handler that provides the required host methods for the runtime to interact with the outside world.
The passed identity may be nil.
func NewRuntimeHostNotifier ¶ added in v0.2103.0
func NewRuntimeHostNotifier( ctx context.Context, runtime Runtime, host host.Runtime, consensus consensus.Backend, ) protocol.Notifier
NewRuntimeHostNotifier returns a protocol notifier that handles key manager policy updates.
func NewStorageRouter ¶ added in v0.2102.0
func NewStorageRouter(runtimeGetter RouterRuntimeStorageFunc, waiter RouterInitWaitFunc) api.Backend
Types ¶
type Registry ¶
type Registry interface { // GetRuntime returns the per-runtime interface if the runtime is supported. GetRuntime(runtimeID common.Namespace) (Runtime, error) // Runtimes returns a list of all supported runtimes. Runtimes() []Runtime // NewUnmanagedRuntime creates a new runtime that is not managed by this // registry. NewUnmanagedRuntime(ctx context.Context, runtimeID common.Namespace) (Runtime, error) // AddRoles adds available node roles to the runtime. Specify nil as the runtimeID // to set the role for all runtimes. AddRoles(roles node.RolesMask, runtimeID *common.Namespace) error // StorageRouter returns a storage backend which routes requests to the // correct per-runtime storage backend based on the namespace contained // in the request. StorageRouter() storageAPI.Backend // Cleanup performs post-termination cleanup. Cleanup() // FinishInitialization finalizes setup for all runtimes and starts their // tag indexers. FinishInitialization(ctx context.Context) error }
Registry is the running node's runtime registry interface.
type RouterInitWaitFunc ¶ added in v0.2102.0
type RouterInitWaitFunc func()
type RouterRuntimeStorageFunc ¶ added in v0.2102.0
type Runtime ¶
type Runtime interface { // ID is the runtime identifier. ID() common.Namespace // RegistryDescriptor waits for the runtime to be registered and // then returns its registry descriptor. RegistryDescriptor(ctx context.Context) (*registry.Runtime, error) // WatchRegistryDescriptor subscribes to registry descriptor updates. WatchRegistryDescriptor() (<-chan *registry.Runtime, pubsub.ClosableSubscription, error) // ActiveDescriptor waits for runtime to be initialized and then returns // currently active runtime descriptor. ActiveDescriptor(ctx context.Context) (*registry.Runtime, error) // WatchActiveDescriptor subscribes to runtime active descriptor updates. WatchActiveDescriptor() (<-chan *registry.Runtime, pubsub.ClosableSubscription, error) // RegisterStorage sets the given local storage backend for the runtime. RegisterStorage(storage storageAPI.Backend) // AddRoles adds available node roles to the runtime. AddRoles(roles node.RolesMask) // HasRoles checks if the node has all of the roles specified for this runtime. HasRoles(roles node.RolesMask) bool // History returns the history for this runtime. History() history.History // Storage returns the per-runtime storage backend. Storage() storageAPI.Backend // LocalStorage returns the per-runtime local storage. LocalStorage() localstorage.LocalStorage // HasHost checks whether this runtime can be hosted by the current node. HasHost() bool // Host returns the runtime host configuration and provisioner if configured. Host(ctx context.Context) (runtimeHost.Config, runtimeHost.Provisioner, error) }
Runtime is the running node's supported runtime interface.
type RuntimeConfig ¶
type RuntimeConfig struct { // Host contains configuration for the runtime host. It may be nil if no runtimes are to be // hosted by the current node. Host *RuntimeHostConfig // History configures the runtime history keeper. History history.Config }
RuntimeConfig is the node runtime configuration.
type RuntimeHostConfig ¶ added in v0.2100.0
type RuntimeHostConfig struct { // Provisioners contains a set of supported runtime provisioners, based on TEE hardware. Provisioners map[node.TEEHardware]runtimeHost.Provisioner // Runtimes contains per-runtime provisioning configuration. Some fields may be omitted as they // are provided when the runtime is provisioned. Runtimes map[common.Namespace]*runtimeHost.Config }
RuntimeHostConfig is configuration for a node that hosts runtimes.
type RuntimeHostHandlerEnvironment ¶ added in v0.2103.0
type RuntimeHostHandlerEnvironment interface { // GetCurrentBlock returns the most recent runtime block. GetCurrentBlock(ctx context.Context) (*block.Block, error) // GetKeyManagerClient returns the key manager client for this runtime. GetKeyManagerClient(ctx context.Context) (keymanagerClientApi.Client, error) }
RuntimeHostHandlerEnvironment is the host environment interface.
type RuntimeHostHandlerFactory ¶ added in v0.2100.0
type RuntimeHostHandlerFactory interface { // GetRuntime returns the registered runtime for which a runtime host handler is to be created. GetRuntime() Runtime // NewRuntimeHostHandler creates a new runtime host handler. NewRuntimeHostHandler() protocol.Handler // NewRuntimeHostNotifier creates a new runtime host notifier. NewRuntimeHostNotifier(ctx context.Context, host host.Runtime) protocol.Notifier }
RuntimeHostHandlerFactory is an interface that can be used to create new runtime handlers and notifiers when provisioning hosted runtimes.
type RuntimeHostNode ¶ added in v0.2100.0
RuntimeHostNode provides methods for nodes that need to host runtimes.
func NewRuntimeHostNode ¶ added in v0.2100.0
func NewRuntimeHostNode(factory RuntimeHostHandlerFactory) (*RuntimeHostNode, error)
NewRuntimeHostNode creates a new runtime host node.
func (*RuntimeHostNode) GetHostedRuntime ¶ added in v0.2100.0
func (n *RuntimeHostNode) GetHostedRuntime() host.RichRuntime
GetHostedRuntime returns the provisioned hosted runtime (if any).
func (*RuntimeHostNode) ProvisionHostedRuntime ¶ added in v0.2100.0
func (n *RuntimeHostNode) ProvisionHostedRuntime(ctx context.Context) (host.RichRuntime, protocol.Notifier, error)
ProvisionHostedRuntime provisions the configured runtime.
This method may return before the runtime is fully provisioned. The returned runtime will not be started automatically, you must call Start explicitly.
func (*RuntimeHostNode) WaitHostedRuntime ¶ added in v0.2103.0
func (n *RuntimeHostNode) WaitHostedRuntime(ctx context.Context) (host.RichRuntime, error)
WaitHostedRuntime waits for the hosted runtime to be provisioned and returns it.