Documentation
¶
Index ¶
- Constants
- Variables
- func Dump() ([]byte, error)
- func IsCapable(ctx context.Context) bool
- func ResConfigFile(res string) string
- func Version(ctx context.Context) (string, error)
- func WithLogger(log *plog.Logger) funcopt.O
- type CStateM
- type Config
- type ConfigAddress
- type ConfigCommon
- type ConfigConnection
- type ConfigConnectionHost
- type ConfigDevice
- type ConfigHost
- type ConfigResource
- type ConfigVolume
- type Digest
- type DrbdShow
- type Status
- type StatusConnPeerDevice
- type StatusConnection
- type StatusDevice
- type T
- func (t *T) Adjust(ctx context.Context) error
- func (t *T) Attach(ctx context.Context) error
- func (t *T) ConfigurePeerMultiPrimary(ctx context.Context, peer string, enabled bool) error
- func (t *T) ConnState(ctx context.Context, nodeID string) (string, error)
- func (t *T) ConnStates(ctx context.Context) (CStateM, error)
- func (t *T) Connect(ctx context.Context, nodeID string) error
- func (t *T) ConnectAndWaitConnectingOrConnected(ctx context.Context, nodeID string) (string, error)
- func (t *T) Create(disk string, addr string, port int) error
- func (t *T) CreateMD(ctx context.Context, maxPeers int) error
- func (t *T) DetachForce(ctx context.Context) error
- func (t *T) Disconnect(ctx context.Context) error
- func (t *T) DiskStates(ctx context.Context) ([]string, error)
- func (t *T) Down(ctx context.Context) error
- func (t *T) HasMD(ctx context.Context) (bool, error)
- func (t *T) IsDefined(ctx context.Context) (bool, error)
- func (t *T) IsUp() (bool, string, error)
- func (t *T) ModProbe(ctx context.Context) error
- func (t *T) Primary(ctx context.Context) error
- func (t *T) PrimaryForce(ctx context.Context) error
- func (t *T) Remove() error
- func (t *T) Resize(ctx context.Context) error
- func (t *T) Role(ctx context.Context) (string, error)
- func (t *T) Secondary(ctx context.Context) error
- func (t *T) Show(ctx context.Context) (DrbdShow, error)
- func (t *T) StartConnection(ctx context.Context, nodeID string) error
- func (t *T) StartConnections(ctx context.Context, peers ...string) error
- func (t *T) Status(ctx context.Context) (Status, error)
- func (t *T) TryStartConnection(ctx context.Context, nodeID string) error
- func (t *T) Up(ctx context.Context) error
- func (t *T) WaitCState(ctx context.Context, nodeID string, timeout time.Duration, ...) (string, error)
- func (t *T) WaitConnectingOrConnected(ctx context.Context, nodeID string) (string, error)
- func (t *T) WaitIsDefined(ctx context.Context, timeout time.Duration, target bool) error
- func (t *T) WipeMD(ctx context.Context) error
Constants ¶
const ( ConnStateStandAlone = "StandAlone" ConnStateDisconnecting = "Disconnecting" ConnStateUnconnected = "Unconnected" ConnStateTimeout = "Timeout" ConnStateBrokenPipe = "BrokenPipe" ConnStateNetworkFailure = "NetworkFailure" ConnStateProtocolError = "ProtocolError" ConnStateTearDow = "TearDown" ConnStateConnecting = "Connecting" ConnStateConnected = "Connected" ConnStateLegacycConnecting = "WFConnection" )
const ( // DiskStateUpToDate is the disk state of a replica holding the latest // data, the only one a promotion accepts. DiskStateUpToDate = "UpToDate" )
Variables ¶
var ( KeyResource = "resource " KeyConnectionMesh = "connection-mesh " KeyHosts = "hosts " KeyOn = "on " KeyNodeID = "node-id " KeyDevice = "device " KeyDisk = "disk " KeyMetaDisk = "meta-disk " KeyAddress = "address " KeyVolume = "volume " KeyResourceLen = len(KeyResource) KeyConnectionMeshLen = len(KeyConnectionMesh) KeyHostsLen = len(KeyHosts) KeyOnLen = len(KeyOn) KeyNodeIDLen = len(KeyNodeID) KeyDeviceLen = len(KeyDevice) KeyDiskLen = len(KeyDisk) KeyMetaDiskLen = len(KeyMetaDisk) KeyAddressLen = len(KeyAddress) KeyVolumeLen = len(KeyVolume) RetryDelay = time.Second * 1 RetryTimeout = time.Second * 10 ExitCodeDeviceInUse = 11 // MaxDRBD defines the maximum number of allowable DRBD resources within the system. MaxDRBD = 512 // MinPort defines the minimum port number used for a drbd resource MinPort = 7289 // MaxPort defines the maximum port number used for a drbd resource // It is calculated as MinPort + 2 * MaxDRBD to allow other applications to use // the ports between MinPort and MaxPort. MaxPort = min(65535, MinPort+2*MaxDRBD) )
Functions ¶
func ResConfigFile ¶
Types ¶
type Config ¶
type Config struct {
XMLName xml.Name `xml:"config"`
File string `xml:"config,attr"`
Common ConfigCommon `xml:"common"`
Resources []ConfigResource `xml:"resource"`
}
func ParseConfig ¶
func (Config) GetResource ¶
func (t Config) GetResource(name string) (ConfigResource, bool)
type ConfigAddress ¶
type ConfigCommon ¶
type ConfigConnection ¶
type ConfigConnection struct {
XMLName xml.Name `xml:"connection"`
Hosts []ConfigConnectionHost `xml:"host"`
}
type ConfigConnectionHost ¶
type ConfigConnectionHost struct {
XMLName xml.Name `xml:"host"`
Name string `xml:"name,attr"`
Address ConfigAddress `xml:"address"`
}
type ConfigDevice ¶
type ConfigHost ¶
type ConfigHost struct {
Name string `xml:"name,attr"`
Volumes []ConfigVolume `xml:"volume"`
Address ConfigAddress `xml:"address"`
}
func (ConfigHost) GetVolume ¶
func (t ConfigHost) GetVolume(name string) (ConfigVolume, bool)
type ConfigResource ¶
type ConfigResource struct {
XMLName xml.Name `xml:"resource"`
Name string `xml:"name,attr"`
FileLine string `xml:"conf-file-line"`
Hosts []ConfigHost `xml:"host"`
Connection ConfigConnection `xml:"connection"`
}
func (ConfigResource) GetHost ¶
func (t ConfigResource) GetHost(name string) (ConfigHost, bool)
type ConfigVolume ¶
type ConfigVolume struct {
Name string `xml:"vnr,attr"`
Device ConfigDevice `xml:"device"`
Disk string `xml:"disk"`
MetaDisk string `xml:"meta-disk"`
}
type Digest ¶
func ParseDigest ¶
type DrbdShow ¶
type DrbdShow struct {
Resource string `json:"resource"`
ThisHost struct {
NodeID int `json:"node-id"`
Volumes []struct {
VolumeNr int `json:"volume_nr"`
DeviceMinor int `json:"device_minor"`
BackingDisk string `json:"backing-disk"`
MetaDisk string `json:"meta-disk"`
} `json:"volumes"`
} `json:"_this_host"`
Connections []struct {
Paths []struct {
ThisHost struct {
Address string `json:"address"`
Port int `json:"port"`
Family string `json:"family"`
} `json:"this_host"`
RemoteHost struct {
Address string `json:"address"`
Port int `json:"port"`
Family string `json:"family"`
} `json:"remote_host"`
} `json:"paths"`
Cstate string `json:"_cstate"`
Net struct {
Name string `json:"_name"`
} `json:"net"`
Volumes []struct {
VolumeNr int `json:"volume_nr"`
Disk struct {
ResyncWithoutReplication bool `json:"resync-without-replication"`
} `json:"disk"`
} `json:"volumes"`
PeerNodeID int `json:"_peer_node_id"`
} `json:"connections"`
}
type Status ¶
type Status struct {
Name string `json:"name"`
Role string `json:"role"`
Devices []StatusDevice `json:"devices"`
Connections []StatusConnection `json:"connections"`
}
Status is the state of a resource as drbdsetup status reports it, the part a start reads: the disk of each local volume, and for each peer the connection and how far behind its resync is.
func ParseStatus ¶
ParseStatus reads the output of drbdsetup status --json --statistics for a resource.
func (Status) DiskStates ¶
DiskStates returns the disk states of the local volumes, joined.
func (Status) HasConnected ¶
HasConnected says whether a peer is connected, which a resync needs.
func (Status) HasUpToDatePeer ¶
HasUpToDatePeer says whether a connected peer holds the latest data, the source a resync of the local disk needs.
func (Status) IsUpToDate ¶
IsUpToDate says whether every local volume holds the latest data, which a promotion needs.
type StatusConnPeerDevice ¶
type StatusConnection ¶
type StatusConnection struct {
PeerNodeID int `json:"peer-node-id"`
Name string `json:"name"`
ConnectionState string `json:"connection-state"`
PeerDevices []StatusConnPeerDevice `json:"peer_devices"`
}
type StatusDevice ¶
type T ¶
type T struct {
// contains filtered or unexported fields
}
func (*T) ConfigurePeerMultiPrimary ¶
ConfigurePeerMultiPrimary sets the allow-two-primaries net-option on the specified resource connection (res:peer).
func (*T) ConnectAndWaitConnectingOrConnected ¶
func (*T) Resize ¶
Resize makes the drbd resource use the current size of the device behind it, on every node holding a replica.
The backing device has to have been grown on every node first: drbd can only offer what the smallest replica holds.
func (*T) StartConnection ¶
startConnection establishes a connection for the DRBD resource, managing its state transitions as needed. It returns an error if the connection process fails.
func (*T) StartConnections ¶
startConnections establishes a connection for the DRBD resource, managing its state transitions as needed. It returns an error if the connection process fails.
func (*T) Status ¶
Status returns the state of the resource, its disks, its connections and their resync.
func (*T) TryStartConnection ¶
func (*T) WaitCState ¶
func (*T) WaitConnectingOrConnected ¶
func (*T) WaitIsDefined ¶
func (*T) WipeMD ¶
WipeMD executes the `wipe-md` drbd command.
Ignore the exit code `20`:
Returned when the sub dev is not found. No need to fail, as the sub dev is surely flagged for unprovision too, which will wipe metadata. This situation happens on unprovision on a stopped instance, when drbd is stacked over another (stopped) disk resource.