servicehook

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package servicehook gives the rbd, cephfs and rgw packages the parts of a ceph.Container that are not public API, such as its mutex and Run-time provisioning. Package ceph registers them in internal/hookreg when it is initialized.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthCommand

func AuthCommand(ctx context.Context, c *ceph.Container, operation string, args ...string) ([]byte, error)

AuthCommand runs a Cephx command with the admin identity and reports a failure by operation without the native output.

func CLI

CLI returns the container that runs Ceph CLI commands, or nil.

func CephBefore

func CephBefore(c *ceph.Container, major int) bool

CephBefore reports whether the recorded Ceph release is older than major.

func ClassifyExec added in v0.2.0

func ClassifyExec(ctx context.Context, err error) error

ClassifyExec classifies a failed Docker exec of a native command as the module's own commands do: matching ctx's error when ctx ended, unclassified for a container that is gone or stopped, since the command may have run, and the engine's failure otherwise.

func ClientCommand added in v0.4.0

func ClientCommand(ctx context.Context, c *ceph.Container, args ...string) ([]byte, error)

ClientCommand executes feature tools in the selected toolkit runtime.

func ClientConfirmed

func ClientConfirmed(client *ceph.ClientConfig, c *ceph.Container) bool

ClientConfirmed reports a client identity that c created and confirmed.

func ClientKeyring

func ClientKeyring(client *ceph.ClientConfig) []byte

ClientKeyring returns the keyring retrieved when the client was created.

func ClientRevoked

func ClientRevoked(client *ceph.ClientConfig) bool

ClientRevoked reports a client identity known to be deleted.

func Closed

func Closed(c *ceph.Container) bool

Closed reports a terminated cluster.

func ClusterIdentity

func ClusterIdentity(ctx context.Context, c *ceph.Container) (string, bool, error)

ClusterIdentity returns the FSID of the bootstrap configuration and whether the configuration and admin keyring were confirmed. The error is only ctx's.

func Command

func Command(ctx context.Context, ctr testcontainers.Container, args ...string) ([]byte, error)

Command runs a CLI command in ctr and returns its standard output.

func DeleteService

func DeleteService(c *ceph.Container, name string)

DeleteService forgets a service container. The caller holds the mutex.

func DiagnosticHandle

func DiagnosticHandle(ctr testcontainers.Container) testcontainers.Container

DiagnosticHandle returns ctr, or nil when it is a typed nil.

func Extension

func Extension(c *ceph.Container, kind string, create func() any) any

Extension returns the per-cluster state a service package keeps under kind, storing the result of create on first use. It takes its own lock, so callers may or may not hold the cluster mutex.

func HostPortAttempts

func HostPortAttempts() int

HostPortAttempts bounds retries after a host port conflict.

func Invalid added in v0.4.0

func Invalid(err error) error

Invalid classifies a refused service request without losing its cause.

func IsPortConflict

func IsPortConflict(ctx context.Context, ctr testcontainers.Container) bool

IsPortConflict reports a container that failed because its port was taken.

func Lock

func Lock(c *ceph.Container)

Lock holds the cluster mutex that serializes fixture mutations.

func LockTopology

func LockTopology(ctx context.Context, c *ceph.Container) error

LockTopology holds the cluster mutex unless ctx ends first.

func MonitorAddresses

func MonitorAddresses(status ceph.QuorumStatus) (string, error)

MonitorAddresses returns the bootstrap addresses of the monitors in quorum.

func NativeFailure added in v0.2.0

func NativeFailure(program string, code int, stdout, stderr []byte) error

NativeFailure describes a command that exited nonzero, as the module's own commands do: a *ceph.NativeFailure read from its error output, or from its standard output when stdout is not nil and it wrote no error output.

func NormalizePool

func NormalizePool(config ceph.PoolConfig) (ceph.PoolConfig, error)

NormalizePool validates a pool configuration and fills its defaults.

func OnlyMissingHostResource

func OnlyMissingHostResource(err error) bool

OnlyMissingHostResource reports an error that only says a container or network is already gone.

func PoolMissing

func PoolMissing(err error) bool

PoolMissing reports a RemovePool error for a name with nothing to remove.

func PoolPlacementDomains

func PoolPlacementDomains(c *ceph.Container, config ceph.PoolConfig) int

PoolPlacementDomains counts the owned OSD placement domains that config can use. The caller holds the cluster mutex.

func PoolPolicyReady

func PoolPolicyReady(c *ceph.Container) error

PoolPolicyReady reports whether the cluster's pool policy accepts changes. The caller holds the cluster mutex.

func PoolStates

func PoolStates(ctx context.Context, c *ceph.Container) ([]ceph.PoolState, error)

PoolStates reads the native pool map. The caller holds the cluster mutex.

func RemovePool

func RemovePool(ctx context.Context, c *ceph.Container, name string, skipForeign bool) error

RemovePool removes a fixture-created pool and its rule and profile. With skipForeign, a pool the fixture did not create is left alone. The caller holds the cluster mutex.

func ReserveHostPorts

func ReserveHostPorts(ctx context.Context, c *ceph.Container, count int) ([]int, func(context.Context) error, error)

ReserveHostPorts reserves count host ports that the cluster tracks until release is called or the cluster terminates.

func ResolvePool

func ResolvePool(c *ceph.Container, config ceph.PoolConfig) ceph.PoolConfig

ResolvePool applies the cluster's pool defaults: CRUSH root, replicas and minimum size.

func RunOwnedShell added in v0.4.0

func RunOwnedShell(ctx context.Context, c *ceph.Container, target testcontainers.Container, label string, limit int, argv ...string) (supervised.ShellReport, error)

RunOwnedShell runs argv in target, a container of c that the caller holds the cluster mutex for, under the shell supervisor with limit seconds (0 for none), and tracks it until it is known to have ended: when ctx ends first the command is stopped before RunOwnedShell returns, and a stop that cannot be confirmed returns a *ceph.NativeCommandUnstoppedError.

func ScriptFile

func ScriptFile(name string) testcontainers.ContainerFile

ScriptFile returns an embedded bootstrap script as a container file.

func Service

func Service(c *ceph.Container, name string) testcontainers.Container

Service returns the named service container the cluster owns, or nil. The caller holds the cluster mutex.

func ServiceImage

func ServiceImage(c *ceph.Container, role string) string

ServiceImage returns the image selected for an image role: rgw or cephfs.

func Services

func Services(c *ceph.Container) map[string]testcontainers.Container

Services returns a copy of the service containers. The caller holds the cluster mutex.

func SetClientRevoked

func SetClientRevoked(client *ceph.ClientConfig, revoked bool)

SetClientRevoked records whether a service deleted the client identity. The caller holds the cluster mutex.

func SetService

func SetService(c *ceph.Container, name string, ctr testcontainers.Container)

SetService records a service container the cluster owns and terminates. The caller holds the cluster mutex.

func SettleClient added in v0.2.0

func SettleClient(ctx context.Context, c *ceph.Container, client *ceph.ClientConfig) error

SettleClient makes sure that no earlier auth command of the module for the client's identity can still change it, and refuses a descriptor whose key was replaced or whose identity has a change that is not resolved. The caller holds the cluster mutex.

func StartService

func StartService(ctx context.Context, c *ceph.Container, name, image string, opts ...testcontainers.ContainerCustomizer) (testcontainers.Container, error)

StartService starts a service container on the cluster's networks and records it for termination. It takes the cluster mutex itself.

func StartupTimeout

func StartupTimeout(c *ceph.Container) time.Duration

StartupTimeout bounds one fixture operation.

func TryLock

func TryLock(c *ceph.Container) bool

TryLock holds the cluster mutex if it is free.

func Unlock

func Unlock(c *ceph.Container)

Unlock releases the cluster mutex.

func WithBootstrap

func WithBootstrap(kind string, fallback bool, build func() (Bootstrap, error)) ceph.Option

WithBootstrap returns the Run option that records the bootstrap build returns. A fallback applies only when no bootstrap of its kind was given.

Types

type Bootstrap

type Bootstrap = interface {
	Kind() string
	Order() int
	InitialPools() []ceph.PoolConfig
	NeedsManagers() bool
	MGRModules() []string
	Prepare(resolve func(ceph.PoolConfig) ceph.PoolConfig, validate func(ceph.PoolConfig) error) error
	Start(ctx context.Context, c *ceph.Container) error
}

Bootstrap is the provisioning a service adds to Run: pools created and validated with the initial pools, validation of its own configuration, and a start step after the initial pools exist. Bootstraps of one Kind replace each other; Order sorts the start steps (RBD pools, filesystems, gateways). resolve applies the cluster's pool defaults and validate checks a pool against the initial layout and the names already in use.

Jump to

Keyboard shortcuts

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