resdiskdrbd

package
v3.0.0-rc49 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxNodes = 32
)

Functions

func New

func New() resource.Driver

Types

type DRBDDriver

type DRBDDriver interface {
	Adjust(context.Context) error
	Attach(context.Context) error
	ConfigurePeerMultiPrimary(ctx context.Context, peer string, enabled bool) error
	Connect(context.Context, string) error
	ConnStates(context.Context) (drbd.CStateM, error)
	ConnState(context.Context, string) (string, error)
	CreateMD(context.Context, int) error
	DetachForce(context.Context) error
	Disconnect(context.Context) error
	DiskStates(context.Context) ([]string, error)
	Down(context.Context) error
	HasMD(context.Context) (bool, error)
	IsDefined(context.Context) (bool, error)
	Primary(context.Context) error
	PrimaryForce(context.Context) error
	Role(context.Context) (string, error)
	Secondary(context.Context) error
	Up(context.Context) error
	WipeMD(context.Context) error
	WaitIsDefined(ctx context.Context, timeout time.Duration, target bool) error
	WaitCState(ctx context.Context, nodeID string, timeout time.Duration, candidates ...string) (string, error)
	WaitConnectingOrConnected(ctx context.Context, nodeID string) (string, error)
	StartConnections(context.Context, ...string) error
	Show(ctx context.Context) (drbd.DrbdShow, error)
}

type DRBDDriverResizer

type DRBDDriverResizer interface {
	Resize(context.Context) error
}

type NodeTemplateData

type NodeTemplateData struct {
	Name   string
	Addr   string
	Device string
	Disk   string
	NodeId int
}

NodeTemplateData represents a structure to hold template data for individual nodes, including their name, address, device, and disk information. It is exported (public) to help template designers to use it.

type ResTemplateData

type ResTemplateData struct {
	Name  string
	Nodes []NodeTemplateData
}

ResTemplateData represents template data for a resource configuration, it is exported (public) to help template designers to use it.

It defines the available fields that template designers can use. Example usage in a template:

 resource {{.Name}} {
    {{range $node := .Nodes}}
    on {{$node.Name}} {
        device    {{$node.Device}};
        disk      {{$node.Disk}};
        meta-disk internal;
        address   {{$node.Addr}};
        node-id   {{$node.NodeId}};
    }
    {{end}}
    connection-mesh {
        hosts{{range $node := .Nodes}} {{$node.Name}}{{end}};
    }
    net {
        rr-conflict retry-connect;
    }
}

type T

type T struct {
	resdisk.T
	Path     naming.Path `json:"path"`
	Nodes    []string    `json:"nodes"`
	Res      string      `json:"res"`
	Disk     string      `json:"disk"`
	MaxPeers int         `json:"max_peers"`
	Addr     string      `json:"addr"`
	Port     int         `json:"port"`
	Network  string      `json:"network"`
	Template string      `json:"template"`
}

func (*T) ClaimedDevices

func (t *T) ClaimedDevices(ctx context.Context) device.L

func (*T) Connect

func (t *T) Connect(ctx context.Context, nodeID string) error

func (*T) CreateMD

func (t *T) CreateMD(ctx context.Context) error

func (*T) CurrentSize

func (t *T) CurrentSize(ctx context.Context) (int64, error)

CurrentSize implements resource.Sizer.

It is the size of the replicated device, which is less than the device behind it: drbd keeps its metadata there.

func (*T) Down

func (t *T) Down(ctx context.Context) error

func (*T) DownForce

func (t *T) DownForce(ctx context.Context) error

DownForce is called by the unprovisioner. Dataloss is not an issue there, so forced detach can be tried.

func (*T) DriverID

func (t *T) DriverID() driver.ID

func (*T) ExposedDevices

func (t *T) ExposedDevices(ctx context.Context) device.L

func (*T) GoSecondary

func (t *T) GoSecondary(ctx context.Context) error

func (*T) Info

func (t *T) Info(_ context.Context) (resource.InfoKeys, error)

func (*T) Label

func (t *T) Label(_ context.Context) string

Label implements Label from resource.Driver interface, it returns a formatted short description of the Resource

func (*T) Manifest

func (t *T) Manifest() *manifest.T

Manifest exposes to the core the input expected by the driver.

func (*T) Name

func (t *T) Name() string

func (*T) PostMove

func (t *T) PostMove(ctx context.Context, peer string) error

PostMove moves the local res to secondary and disables the multiple primaries on the peer connection name.

func (*T) PreMove

func (t *T) PreMove(ctx context.Context, peer string) error

PreMove prepares the peer connection and promotes it to primary for multi-primary mode during resource operations.

func (*T) PreMoveRollback

func (t *T) PreMoveRollback(ctx context.Context, peer string) error

PreMoveRollback ensures a rollback of a pre-move operation, promoting peer as secondary and disabling multi-primary mode to the peer connection.

func (*T) ProvisionAsFollower

func (t *T) ProvisionAsFollower(ctx context.Context) error

func (*T) ProvisionAsLeader

func (t *T) ProvisionAsLeader(ctx context.Context) error

func (*T) ProvisionStart

func (t *T) ProvisionStart(_ context.Context) error

ProvisionStart is a noop to avoid calling the normal Start after provision

func (*T) Provisioned

func (t *T) Provisioned(ctx context.Context) (provisioned.T, error)

func (*T) ReservableDevices

func (t *T) ReservableDevices(ctx context.Context) device.L

func (*T) Resize

func (t *T) Resize(ctx context.Context, _ int64) error

Resize implements resource.Resizer.

The device behind drbd has to have been grown on every node first: a replica can only offer what the smallest of them holds.

func (*T) ResizeIsReplicated

func (t *T) ResizeIsReplicated() bool

ResizeIsReplicated implements resource.ResizeIsReplicated.

A drbd resource offers what its smallest replica holds, so it can only be grown once every node has grown the device behind it.

func (*T) ResizePlan

func (t *T) ResizePlan(ctx context.Context, to int64) (int64, error)

ResizePlan implements resource.Resizer.

What drbd asks of the device below is the size wanted plus room for its metadata: a dirty bitmap holding one bit per 4k of data for each peer it was given room for, and a superblock and an activity log on top of that.

It is computed from the size asked for rather than measured as the gap between the device below and the replicated device. That gap is not the metadata while a resize is in flight: every node grows the device below first, and only then is the replicated device grown to match, so measuring then reads the growth itself as metadata and asks for it a second time. Asking for a little too much costs nothing. Asking for too little leaves the filesystem above short of what it was promised.

func (*T) ResizeSpansBelow

func (t *T) ResizeSpansBelow() bool

ResizeSpansBelow implements resource.ResizeSpansBelow.

A drbd resource takes up the device it was given, keeping a cut of it for its metadata: it is not told a size, it is told to look again.

func (*T) Shutdown

func (t *T) Shutdown(ctx context.Context) error

func (*T) Start

func (t *T) Start(ctx context.Context) error

func (*T) StartStandby

func (t *T) StartStandby(ctx context.Context) error

func (*T) Status

func (t *T) Status(ctx context.Context) status.T

func (*T) StatusDependsOnPeers

func (t *T) StatusDependsOnPeers() bool

StatusDependsOnPeers says the status of a drbd resource reads the disk states of its peers, which change when a peer instance takes its drbd resource down or up, as a shutdown and a start of the standby resources do.

func (*T) StatusInfo

func (t *T) StatusInfo(context.Context) map[string]any

func (*T) Stop

func (t *T) Stop(ctx context.Context) error

func (*T) StopStandby

func (t *T) StopStandby(ctx context.Context) error

func (*T) SubDevices

func (t *T) SubDevices(ctx context.Context) device.L

func (*T) UnprovisionAsFollower

func (t *T) UnprovisionAsFollower(ctx context.Context) error

func (*T) UnprovisionAsLeader

func (t *T) UnprovisionAsLeader(ctx context.Context) error

func (*T) UnprovisionStop

func (t *T) UnprovisionStop(ctx context.Context, leader bool) error

UnprovisionStop is a noop to avoid calling the normal Stop before unprovision

func (*T) Up

func (t *T) Up(ctx context.Context) error

Up function brings up the DRBD device and waits until its state is stable and not in a diskless configuration.

func (*T) WipeMD

func (t *T) WipeMD(ctx context.Context) error

Jump to

Keyboard shortcuts

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