Documentation
¶
Overview ¶
Package multicluster holds helpers shared by the cross-cluster fixtures of the rbd, cephfs and rgw packages: ownership of the extra containers and network attachments they create, cluster pair validation, CLI execution and bounded locking. It owns no clusters.
Index ¶
- Constants
- func CephBefore(cluster *ceph.Container, major int) bool
- func EntirelyMissing(err error) bool
- func Exec(ctx context.Context, ctr testcontainers.Container, args ...string) ([]byte, error)
- func IgnoreMissing(err error) error
- func InitialMirrorDaemonName(index int) string
- func InterruptOwnedPeerLink(ctx context.Context, owned *Resources, ctr testcontainers.Container, ...) (*fault.NetworkInterruption, error)
- func LockObservation(ctx context.Context, mutex *sync.Mutex) error
- func NormalizeInitialMirrorDaemonCount(count int, noInitial bool) (int, error)
- func RequireRoleImage(image, role string, clusters ...*ceph.Container) error
- func RetainWaitQueryCause(ctx context.Context, previous, current error) error
- func RunClient(ctx context.Context, image string, cluster *ceph.Container, peerNetwork string, ...) (testcontainers.Container, error)
- func SplitConfig[O testcontainers.ContainerCustomizer](kind, option string, opts []testcontainers.ContainerCustomizer) (O, []testcontainers.ContainerCustomizer, error)
- func TerminateFixture(ctx context.Context, mu *sync.Mutex, closed *bool, owned *Resources, ...) error
- func TerminateOnce(ctx context.Context, mu *sync.Mutex, done *bool, ctr testcontainers.Container, ...) error
- func ValidatePair(ctx context.Context, image string, source, destination *ceph.Container) error
- type Resources
Constants ¶
const ( RoleRBDAux = "rbd-aux" RoleCephFS = "cephfs" RoleRGW = "rgw" )
Image roles that a cross-cluster fixture starts daemons or gateways from.
Variables ¶
This section is empty.
Functions ¶
func CephBefore ¶
CephBefore reports whether cluster's recorded release is older than major. An unknown version keeps the default image's command forms.
func EntirelyMissing ¶
EntirelyMissing reports that every non-nil error in err is a not-found error.
func Exec ¶
Exec runs args in ctr and returns stdout. It classifies failures as the module's own commands do: a nonzero exit is a *ceph.NativeFailure.
func IgnoreMissing ¶
IgnoreMissing treats missing resources as already cleaned up. A joined error is harmless only when every non-nil child is missing: errors.Is alone could hide a real failure alongside a not-found error. Inspect wrappers for joins before classifying the original error, retaining SDK error classifiers carried by wrappers.
func InitialMirrorDaemonName ¶ added in v0.4.0
InitialMirrorDaemonName returns the fixture name of the index-th (zero-based) initial mirror daemon: "a" through "z", then "node-27" and onward. RBD and CephFS publish the same sequence, which their daemon-name validators accept.
func InterruptOwnedPeerLink ¶
func InterruptOwnedPeerLink(ctx context.Context, owned *Resources, ctr testcontainers.Container, network string) (*fault.NetworkInterruption, error)
InterruptOwnedPeerLink disconnects ctr from network and records the restore in owned, so cleanup reconnects it even if the caller does not.
func LockObservation ¶
LockObservation acquires mutex unless ctx ends first. Observation waits include time queued behind a topology mutation or another observer. TryLock preserves the shared mutex without an abandoned lock goroutine.
func NormalizeInitialMirrorDaemonCount ¶
NormalizeInitialMirrorDaemonCount applies the same count admission before runtime access and in normalization. Explicit zero construction does not change DaemonCount=0's legacy default.
func RequireRoleImage ¶ added in v0.4.0
RequireRoleImage refuses an image that a cluster selects for another role than the one the fixture needs, for example the essential image given as the rbd-mirror daemon image of a split-role cluster. It cannot show that an arbitrary image holds the daemon: a custom image that no cluster selects is accepted, and so is an image that also serves the wanted role (an aggregate selection). Only the recorded selection is compared; nothing runs.
func RetainWaitQueryCause ¶
RetainWaitQueryCause handles a caller-context-only failure, which has no new independent native query cause. Retain an earlier exposed cause without changing inner-attempt timeouts, mixed errors, permanent guards, or newer successful observations.
func RunClient ¶
func RunClient(ctx context.Context, image string, cluster *ceph.Container, peerNetwork string, owned *Resources) (testcontainers.Container, error)
RunClient starts an idle CLI client attached to cluster and, on bridge networks, to peerNetwork. owned records it for cleanup.
func SplitConfig ¶ added in v0.4.0
func SplitConfig[O testcontainers.ContainerCustomizer](kind, option string, opts []testcontainers.ContainerCustomizer) (O, []testcontainers.ContainerCustomizer, error)
SplitConfig separates the one configuration carrier of type O that a cross-cluster fixture's Run takes from the customizers of its containers. It refuses a Run without the carrier and one with several, even when they agree. kind names the fixture and option the carrier in the error.
func TerminateFixture ¶ added in v0.4.0
func TerminateFixture(ctx context.Context, mu *sync.Mutex, closed *bool, owned *Resources, forget func(), opts ...testcontainers.TerminateOption) error
TerminateFixture closes a mirror fixture under mu: it marks *closed, runs the owned cleanup actions and, only when they all succeed, calls forget so the caller drops its daemon membership and initial-daemon handle. A cleanup error leaves the membership in place so the call can be retried; *closed stays set either way, so later admission sees a closed fixture. The lock wait is bounded by ctx. The caller keeps the mutex, flag and fields in its own fixture type, so its other observers read the same state under the same lock.
func TerminateOnce ¶ added in v0.4.0
func TerminateOnce(ctx context.Context, mu *sync.Mutex, done *bool, ctr testcontainers.Container, opts ...testcontainers.TerminateOption) error
TerminateOnce removes ctr under mu, remembering success in *done so fixture cleanup does not run container hooks twice. A missing container counts as removed, a nil ctr or an already removed one is a no-op, and a failed removal leaves *done false so it can be retried. The lock wait is bounded by ctx. The caller keeps the mutex and flag in its own daemon type, so its other observers continue to read the same state under the same lock.
Types ¶
type Resources ¶
type Resources struct {
// contains filtered or unexported fields
}
Resources records the containers and cleanup actions a cross-cluster fixture owns. Cleanup runs in reverse construction order. Successful actions are retained as completed so partial failures can be retried without double termination.
func (*Resources) AddCleanup ¶
AddCleanup records a named cleanup action.
func (*Resources) AddContainer ¶
func (r *Resources) AddContainer(ctr testcontainers.Container)
AddContainer records ctr for termination.
func (*Resources) Terminate ¶
func (r *Resources) Terminate(ctx context.Context, opts ...testcontainers.TerminateOption) error
Terminate runs the recorded actions in reverse order. Completed actions are kept so a partial failure can be retried.