service

package
v0.0.1-dev.80 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: MIT Imports: 41 Imported by: 0

Documentation

Overview

SnapshotService — namespace-scoped gRPC handlers for Snapshot resources.

Package service — StorageClassService gRPC handlers

VolumeService — namespace-scoped gRPC handlers for Volume resources.

Driver-capability lint for Volume resources at the API write path.

Today the storage drivers enforce capability invariants at provision time (Driver.Provision returns an error and the controller marks the Volume Failed/Stalled). Surfacing the same checks at the gRPC write path turns "operator submits cast → orchestrator quietly fails on next reconcile" into "operator submits cast → cast fails with a clear error". This file implements the cast-time half of that guarantee: AccessMode must be in driver Capabilities; local-host volumes must declare a parameters.hostPath that resolves inside the runefile allowlist. Anything we cannot determine without driver instantiation (e.g. block-device formatting) is intentionally left to the controller.

All checks fail OPEN: if the StorageClass is missing, if the driver is unregistered, or if driver instantiation errors, the lint defers to the controller. This keeps the unit-test surface small (callers that did not seed a StorageClass keep working) while the production path — where the controller seeds the built-in classes at boot — is fully covered.

Index

Constants

View Source
const (
	// DefaultNamespace is the default namespace for services.
	DefaultNamespace = "default"
)
View Source
const RestoreFromSnapshotParam = types.RestoreFromSnapshotParam

RestoreFromSnapshotParam is re-exported for compatibility; the canonical definition lives in pkg/types/snapshot.go.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error is a "not found" error.

Types

type AdminService

type AdminService struct {
	generated.UnimplementedAdminServiceServer
	// contains filtered or unexported fields
}

AdminService implements generated.AdminServiceServer

func NewAdminService

func NewAdminService(st store.Store, logger log.Logger) *AdminService

func (*AdminService) AddRegistry

func (*AdminService) AdminBootstrap

AdminBootstrap creates the built-in root subject and returns a management token (opaque secret once)

func (*AdminService) BootstrapAuth

func (*AdminService) GetRegistry

func (*AdminService) ListRegistries

Registry admin RPCs

func (*AdminService) NetworkStatus

NetworkStatus returns the current ClusterNetwork CIDR plus VIP allocation summary. Returns Unavailable if the allocator hasn't been wired in (e.g. during startup or in tests that don't construct one).

func (*AdminService) PolicyAttachToSubject

PolicyAttachToSubject attaches a policy to a user subject (MVP: users only)

func (*AdminService) PolicyCreate

PolicyCreate creates or updates a policy

func (*AdminService) PolicyDelete

PolicyDelete deletes a policy

func (*AdminService) PolicyDetachFromSubject

PolicyDetachFromSubject detaches a policy from a user subject (MVP: users only)

func (*AdminService) PolicyGet

PolicyGet fetches a policy

func (*AdminService) PolicyList

PolicyList lists policies

func (*AdminService) PolicyUpdate

PolicyUpdate updates a policy

func (*AdminService) RemoveRegistry

func (*AdminService) SetNetworkStatusProvider

func (s *AdminService) SetNetworkStatusProvider(p NetworkStatusProvider)

SetNetworkStatusProvider plugs in the live VIP allocator. Calling NetworkStatus before this is invoked returns codes.Unavailable.

func (*AdminService) TestRegistry

func (*AdminService) TokenList

TokenList lists tokens (admin-only). Does not return secrets.

func (*AdminService) UpdateRegistry

func (*AdminService) UserCreate

UserCreate upserts a user and attaches policies (MVP)

func (*AdminService) UserList

UserList lists users (subjects)

type AuditService

type AuditService struct {
	generated.UnimplementedAuditServiceServer
	// contains filtered or unexported fields
}

AuditService exposes the append-only security audit trail. RBAC is enforced upstream by the standard rbac interceptor — see methodToAction in pkg/api/server/utils.go (resource: "audit").

func NewAuditService

func NewAuditService(coreStore store.Store, logger log.Logger) *AuditService

type AuthService

type AuthService struct {
	generated.UnimplementedAuthServiceServer
	// contains filtered or unexported fields
}

AuthService implements generated.AuthServiceServer

func NewAuthService

func NewAuthService(st store.Store, logger log.Logger) *AuthService

func (*AuthService) CreateToken

func (*AuthService) RevokeToken

func (*AuthService) WhoAmI

AuthService implementation

type ConfigmapService

type ConfigmapService struct {
	generated.UnimplementedConfigmapServiceServer
	// contains filtered or unexported fields
}

func NewConfigmapService

func NewConfigmapService(st store.Store, logger log.Logger) *ConfigmapService

func (*ConfigmapService) CreateConfigmap

func (*ConfigmapService) DeleteConfigmap

func (*ConfigmapService) GetConfigmap

func (*ConfigmapService) ListConfigmaps

func (*ConfigmapService) UpdateConfigmap

type ExecService

type ExecService struct {
	generated.UnimplementedExecServiceServer
	// contains filtered or unexported fields
}

ExecService implements the gRPC ExecService.

func NewExecService

func NewExecService(logger log.Logger, orchestrator orchestrator.Orchestrator) *ExecService

NewExecService creates a new ExecService with the given runners, store, and logger.

func (*ExecService) StreamExec

StreamExec provides bidirectional streaming for exec operations.

type HealthService

type HealthService struct {
	generated.UnimplementedHealthServiceServer
	// contains filtered or unexported fields
}

HealthService implements the gRPC HealthService.

func NewHealthService

func NewHealthService(store store.Store, logger log.Logger) *HealthService

NewHealthService creates a new HealthService with the given store and logger.

func (*HealthService) DetectAndSetCapacity

func (s *HealthService) DetectAndSetCapacity()

DetectAndSetCapacity runs capacity detection and caches the result in the service.

func (*HealthService) GetHealth

GetHealth retrieves health status of platform components.

func (*HealthService) GetServerVersion

GetServerVersion returns build/version metadata for the running server binary. Intentionally cheap and unauthenticated so `rune version` can report it before the user has logged in.

func (*HealthService) SetCapacity

func (s *HealthService) SetCapacity(cpuCores float64, memBytes int64)

SetCapacity allows the API server to inject cached node capacity for reporting.

type InstanceService

type InstanceService struct {
	generated.UnimplementedInstanceServiceServer
	// contains filtered or unexported fields
}

InstanceService implements the gRPC InstanceService.

func NewInstanceService

func NewInstanceService(store store.Store, runnerManager manager.IRunnerManager, logger log.Logger) *InstanceService

NewInstanceService creates a new InstanceService with the given store, runners, and logger.

func (*InstanceService) GetInstance

GetInstance retrieves an instance by ID.

func (*InstanceService) ListInstances

ListInstances lists instances with optional filtering.

func (*InstanceService) ProtoInstanceToInstanceModel

func (s *InstanceService) ProtoInstanceToInstanceModel(protoInstance *generated.Instance) (*types.Instance, error)

ProtoInstanceToInstanceModel converts a protobuf message to a domain model instance.

func (*InstanceService) RestartInstance

RestartInstance restarts an instance.

func (*InstanceService) StartInstance

StartInstance starts an instance.

func (*InstanceService) StopInstance

StopInstance stops an instance.

type LogService

type LogService struct {
	generated.UnimplementedLogServiceServer
	// contains filtered or unexported fields
}

LogService implements the gRPC LogService.

func NewLogService

func NewLogService(store store.Store, logger log.Logger, orchestrator orchestrator.Orchestrator) *LogService

NewLogService creates a new LogService with the given runners, store, and logger.

func (*LogService) StreamLogs

func (s *LogService) StreamLogs(stream generated.LogService_StreamLogsServer) error

StreamLogs provides bidirectional streaming for logs.

type MockExecServiceStream

type MockExecServiceStream struct {
	mock.Mock
	grpc.ServerStream
	// contains filtered or unexported fields
}

MockExecServiceStream is a mock implementation of the generated.ExecService_StreamExecServer interface

func NewMockExecServiceStream

func NewMockExecServiceStream(ctx context.Context) *MockExecServiceStream

NewMockExecServiceStream creates a new MockExecServiceStream with the given context

func (*MockExecServiceStream) Context

func (m *MockExecServiceStream) Context() context.Context

Context returns the context

func (*MockExecServiceStream) Recv

Recv mocks the Recv method

func (*MockExecServiceStream) Send

Send mocks the Send method

type NamespaceService

type NamespaceService struct {
	generated.UnimplementedNamespaceServiceServer
	// contains filtered or unexported fields
}

NamespaceService implements the gRPC NamespaceService.

func NewNamespaceService

func NewNamespaceService(store store.Store, logger log.Logger) *NamespaceService

NewNamespaceService creates a new NamespaceService with the given store and logger.

func (*NamespaceService) CreateNamespace

CreateNamespace creates a new namespace.

func (*NamespaceService) DeleteNamespace

DeleteNamespace removes a namespace.

func (*NamespaceService) GetNamespace

GetNamespace retrieves a namespace by name.

func (*NamespaceService) ListNamespaces

ListNamespaces lists namespaces with optional filtering.

func (*NamespaceService) WatchNamespaces

WatchNamespaces watches namespaces for changes.

type NetworkStatusProvider

type NetworkStatusProvider interface {
	Status() (cn types.ClusterNetwork, pendingReleases int)
}

NetworkStatusProvider is the minimal surface AdminService needs to answer NetworkStatus RPCs. The vip allocator implements it. The indirection keeps AdminService independent of the networking package so existing admin tests don't grow a transitive dep.

type PortForwardService

type PortForwardService struct {
	generated.UnimplementedPortForwardServiceServer
	// contains filtered or unexported fields
}

PortForwardService implements the gRPC PortForwardService (RUNE-122).

One gRPC stream per `rune port-forward` invocation. The client multiplexes any number of accepted local connections over the stream using a per-connection conn_id; the server holds one net.Conn per conn_id, fanning bytes through.

func NewPortForwardService

func NewPortForwardService(logger log.Logger, orch orchestrator.Orchestrator) *PortForwardService

NewPortForwardService constructs a PortForwardService.

func (*PortForwardService) StreamPortForward

StreamPortForward is the single bidi RPC implementing the service.

type ResourceTarget

type ResourceTarget struct {
	Type     types.ResourceType
	Resource interface{}
}

func (ResourceTarget) GetInstance

func (r ResourceTarget) GetInstance() (*types.Instance, error)

func (ResourceTarget) GetService

func (r ResourceTarget) GetService() (*types.Service, error)

type SecretService

type SecretService struct {
	generated.UnimplementedSecretServiceServer
	// contains filtered or unexported fields
}

SecretService implements the gRPC SecretService.

As of dev.33, the read-side surface is split:

  • GetSecret / ListSecrets return metadata only (no plaintext payload). They populate Secret.data_keys instead of data.
  • RevealSecret returns the plaintext payload and requires the secrets:reveal RBAC verb.

Every Create / Update / Delete / Reveal / Get call emits an AuditEvent so that operators have a queryable trail separate from the structured app log.

func NewSecretService

func NewSecretService(coreStore store.Store, logger log.Logger) *SecretService

func (*SecretService) CreateSecret

func (*SecretService) DeleteSecret

func (*SecretService) GetSecret

func (*SecretService) ListSecretVersions

ListSecretVersions returns metadata for every historical version of a secret, newest first. Plaintext data is stripped; data_keys is populated. Use RevealSecretVersion to fetch the payload of a specific version.

func (*SecretService) ListSecrets

func (*SecretService) PatchSecret

PatchSecret applies a key-scoped merge to an existing secret: `set` entries upsert, `unset` keys are removed. Runs under a per-secret lock so concurrent patches don't clobber each other. The response carries metadata only — no plaintext — so callers don't need secrets:reveal to rotate a single key.

Idempotency:

  • If neither set nor unset is provided, returns InvalidArgument.
  • unset keys that don't exist are silently ignored.
  • If the merge produces a map identical to the current head, no new version is written and no audit event is emitted (matches UpdateSecret's unchanged-short-circuit behaviour).

Audit:

  • On success, action="patch" with metadata listing the key names that were set/unset and the resulting keyCount/version. Values are never logged.

func (*SecretService) RevealSecret

RevealSecret returns the plaintext payload of a single secret. It is rate limited identically to GetSecret and emits a `reveal` audit event on every call (success or denial).

func (*SecretService) RevealSecretVersion

RevealSecretVersion returns the plaintext payload of a specific historical version of a secret. Gated by secrets:reveal.

func (*SecretService) RollbackSecret

RollbackSecret rewrites HEAD to the contents of the given prior version, producing a new HEAD version. Old versions are retained in history. Gated by secrets:update; emits a `rollback` audit event whose metadata records fromVersion (previous head), toVersion (rollback target), and newVersion (the freshly written head).

func (*SecretService) UpdateSecret

type ServiceService

type ServiceService struct {
	generated.UnimplementedServiceServiceServer
	// contains filtered or unexported fields
}

ServiceService implements the gRPC ServiceService.

func NewServiceService

func NewServiceService(store store.Store, orchestrator orchestrator.Orchestrator, runnerManager *manager.RunnerManager, logger log.Logger) *ServiceService

NewServiceService creates a new ServiceService with the given orchestrator and logger.

func (*ServiceService) CreateService

CreateService creates a new service.

func (*ServiceService) DeleteService

DeleteService removes a service.

func (*ServiceService) GetDeletionStatus

GetDeletionStatus gets the status of a deletion operation.

func (*ServiceService) GetService

GetService retrieves a service by name.

func (*ServiceService) ListDeletionOperations

ListDeletionOperations lists deletion operations with optional filtering.

func (*ServiceService) ListServices

ListServices lists services with optional filtering.

func (*ServiceService) ScaleService

ScaleService changes the scale of a service.

func (*ServiceService) SetVIPAllocator

func (s *ServiceService) SetVIPAllocator(a VIPAllocator)

SetVIPAllocator wires in the cluster VIP allocator. Calling this is optional; when unset, services are created without a VIP (matching pre-RUNE-040 behavior). runed wires the live allocator in main.go.

func (*ServiceService) UpdateService

UpdateService updates an existing service.

func (*ServiceService) WatchScaling

WatchScaling watches a service for scaling status changes and streams updates to the client.

func (*ServiceService) WatchServices

WatchServices watches services for changes.

type SnapshotService

type SnapshotService struct {
	generated.UnimplementedSnapshotServiceServer
	// contains filtered or unexported fields
}

SnapshotService implements generated.SnapshotServiceServer.

func NewSnapshotService

func NewSnapshotService(st store.Store, logger log.Logger, opts ...SnapshotServiceOption) *SnapshotService

NewSnapshotService constructs a SnapshotService.

func (*SnapshotService) CreateSnapshot

func (*SnapshotService) DeleteSnapshot

func (*SnapshotService) GetSnapshot

func (*SnapshotService) ListSnapshots

func (*SnapshotService) RestoreVolume

RestoreVolume provisions a new Volume from this Snapshot. The new Volume starts in Pending with a Parameters["rune.io/restoreFromSnapshot"] stamp; the VolumeController routes that to Driver.RestoreFromSnapshot instead of Driver.Provision on first reconcile.

type SnapshotServiceOption

type SnapshotServiceOption func(*SnapshotService)

SnapshotServiceOption configures optional SnapshotService behaviour.

func WithSnapshotDriverConfigs

func WithSnapshotDriverConfigs(cfg map[string]map[string]any) SnapshotServiceOption

WithSnapshotDriverConfigs supplies the runefile [storage.drivers] map so the service can perform driver-capability lint at the write path (reject CreateSnapshot when the source volume's driver does not declare Capabilities.Snapshots).

type StorageClassService

type StorageClassService struct {
	generated.UnimplementedStorageClassServiceServer
	// contains filtered or unexported fields
}

StorageClassService implements generated.StorageClassServiceServer. StorageClass is cluster-scoped (no namespace).

The service enforces the at-most-one-Default invariant on the API write path: when a Create or Update lands a class with Default=true, the handler atomically demotes any other class that currently has Default=true (writes go through the repo with EventSourceAPI so the VolumeController's watch-side enforcer treats them as external and skips its own re-demote pass). The orchestrator-side enforcer in pkg/orchestrator/controllers/volume_controller.go remains as belt-and-braces for clusters whose StorageClass rows pre-date this API check.

func NewStorageClassService

func NewStorageClassService(st store.Store, logger log.Logger) *StorageClassService

NewStorageClassService constructs a StorageClassService.

func (*StorageClassService) CreateStorageClass

func (*StorageClassService) DeleteStorageClass

func (*StorageClassService) GetStorageClass

func (*StorageClassService) UpdateStorageClass

type VIPAllocator

type VIPAllocator interface {
	Allocate(ctx context.Context, serviceID string) (net.IP, error)
}

VIPAllocator is the minimal surface ServiceService needs to allocate a stable cluster VIP for each new service. Implemented by pkg/networking/vip.Allocator. The interface keeps service.go free of a dependency on the networking package and lets tests inject a fake.

type VolumeService

type VolumeService struct {
	generated.UnimplementedVolumeServiceServer
	// contains filtered or unexported fields
}

VolumeService implements generated.VolumeServiceServer.

func NewVolumeService

func NewVolumeService(st store.Store, logger log.Logger, opts ...VolumeServiceOption) *VolumeService

NewVolumeService constructs a VolumeService.

func (*VolumeService) CreateVolume

func (*VolumeService) DeleteVolume

func (*VolumeService) DetachVolume

DetachVolume clears bind state on a volume so a replacement instance can attach it. Without force=true the volume must already be Released or have no BoundClaim (i.e. it's safe to clear). With force=true the caller assumes responsibility for any data-loss risk if the previous holder is still alive; bind state is cleared regardless of status and the volume is moved to Available.

func (*VolumeService) GetVolume

func (*VolumeService) ListVolumes

func (*VolumeService) RetryProvisionVolume

RetryProvisionVolume resets a Failed/Stalled volume back to Pending so the controller will attempt provisioning again. Volumes already in any other state are rejected with FailedPrecondition.

func (*VolumeService) UpdateVolume

type VolumeServiceOption

type VolumeServiceOption func(*VolumeService)

VolumeServiceOption configures optional VolumeService behaviour.

func WithDriverConfigs

func WithDriverConfigs(cfg map[string]map[string]any) VolumeServiceOption

WithDriverConfigs supplies the runefile [storage.drivers] map so the service can perform driver-capability lint at the write path (e.g. reject Volumes whose AccessMode is not in the driver's Capabilities.AccessModes, or whose local-host hostPath is outside the runefile allowlist). Optional — when omitted, driver-capability lint is skipped and the controller surfaces capability errors at provision time instead.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL