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 ¶
- func AuthCommand(ctx context.Context, c *ceph.Container, operation string, args ...string) ([]byte, error)
- func CLI(c *ceph.Container) testcontainers.Container
- func CephBefore(c *ceph.Container, major int) bool
- func ClassifyExec(ctx context.Context, err error) error
- func ClientCommand(ctx context.Context, c *ceph.Container, args ...string) ([]byte, error)
- func ClientConfirmed(client *ceph.ClientConfig, c *ceph.Container) bool
- func ClientKeyring(client *ceph.ClientConfig) []byte
- func ClientRevoked(client *ceph.ClientConfig) bool
- func Closed(c *ceph.Container) bool
- func ClusterIdentity(ctx context.Context, c *ceph.Container) (string, bool, error)
- func Command(ctx context.Context, ctr testcontainers.Container, args ...string) ([]byte, error)
- func DeleteService(c *ceph.Container, name string)
- func DiagnosticHandle(ctr testcontainers.Container) testcontainers.Container
- func Extension(c *ceph.Container, kind string, create func() any) any
- func HostPortAttempts() int
- func Invalid(err error) error
- func IsPortConflict(ctx context.Context, ctr testcontainers.Container) bool
- func Lock(c *ceph.Container)
- func LockTopology(ctx context.Context, c *ceph.Container) error
- func MonitorAddresses(status ceph.QuorumStatus) (string, error)
- func NativeFailure(program string, code int, stdout, stderr []byte) error
- func NormalizePool(config ceph.PoolConfig) (ceph.PoolConfig, error)
- func OnlyMissingHostResource(err error) bool
- func PoolMissing(err error) bool
- func PoolPlacementDomains(c *ceph.Container, config ceph.PoolConfig) int
- func PoolPolicyReady(c *ceph.Container) error
- func PoolStates(ctx context.Context, c *ceph.Container) ([]ceph.PoolState, error)
- func RemovePool(ctx context.Context, c *ceph.Container, name string, skipForeign bool) error
- func ReserveHostPorts(ctx context.Context, c *ceph.Container, count int) ([]int, func(context.Context) error, error)
- func ResolvePool(c *ceph.Container, config ceph.PoolConfig) ceph.PoolConfig
- func RunOwnedShell(ctx context.Context, c *ceph.Container, target testcontainers.Container, ...) (supervised.ShellReport, error)
- func ScriptFile(name string) testcontainers.ContainerFile
- func Service(c *ceph.Container, name string) testcontainers.Container
- func ServiceImage(c *ceph.Container, role string) string
- func Services(c *ceph.Container) map[string]testcontainers.Container
- func SetClientRevoked(client *ceph.ClientConfig, revoked bool)
- func SetService(c *ceph.Container, name string, ctr testcontainers.Container)
- func SettleClient(ctx context.Context, c *ceph.Container, client *ceph.ClientConfig) error
- func StartService(ctx context.Context, c *ceph.Container, name, image string, ...) (testcontainers.Container, error)
- func StartupTimeout(c *ceph.Container) time.Duration
- func TryLock(c *ceph.Container) bool
- func Unlock(c *ceph.Container)
- func WithBootstrap(kind string, fallback bool, build func() (Bootstrap, error)) ceph.Option
- type Bootstrap
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 ¶
func CLI(c *ceph.Container) testcontainers.Container
CLI returns the container that runs Ceph CLI commands, or nil.
func CephBefore ¶
CephBefore reports whether the recorded Ceph release is older than major.
func ClassifyExec ¶ added in v0.2.0
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
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 ClusterIdentity ¶
ClusterIdentity returns the FSID of the bootstrap configuration and whether the configuration and admin keyring were confirmed. The error is only ctx's.
func DeleteService ¶
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 ¶
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
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 LockTopology ¶
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
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 ¶
OnlyMissingHostResource reports an error that only says a container or network is already gone.
func PoolMissing ¶
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 ¶
PoolPolicyReady reports whether the cluster's pool policy accepts changes. The caller holds the cluster mutex.
func PoolStates ¶
PoolStates reads the native pool map. The caller holds the cluster mutex.
func RemovePool ¶
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 ¶
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
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 ¶
StartupTimeout bounds one fixture operation.
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.