devicemanager

package
v1.1.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Instance          *ec2.Instance
	Path              string
	VolumeID          string
	IsAlreadyAssigned bool
	// contains filtered or unexported fields
}

func (*Device) Release

func (d *Device) Release(force bool)

func (*Device) Taint

func (d *Device) Taint()

Taint marks the device as no longer reusable

type DeviceManager

type DeviceManager interface {
	// NewDevice retrieves the device if the device is already assigned.
	// Otherwise it creates a new device with next available device name
	// and mark it as unassigned device.
	NewDevice(instance *ec2.Instance, volumeID string) (device *Device, err error)

	// GetDevice returns the device already assigned to the volume.
	GetDevice(instance *ec2.Instance, volumeID string) (device *Device, err error)
}

func NewDeviceManager

func NewDeviceManager() DeviceManager

type ExistingNames

type ExistingNames map[string]string

ExistingNames is a map of assigned device names. Presence of a key with a device name in the map means that the device is allocated. Value is irrelevant and can be used for anything that NameAllocator user wants. Only the relevant part of device name should be in the map, e.g. "ba" for "/dev/xvdba".

type NameAllocator

type NameAllocator interface {
	// GetNext returns a free device name or error when there is no free device
	// name. Only the device name is returned, e.g. "ba" for "/dev/xvdba".
	// It's up to the called to add appropriate "/dev/sd" or "/dev/xvd" prefix.
	GetNext(existingNames ExistingNames) (name string, err error)
}

On AWS, we should assign new (not yet used) device names to attached volumes. If we reuse a previously used name, we may get the volume "attaching" forever, see https://aws.amazon.com/premiumsupport/knowledge-center/ebs-stuck-attaching/. NameAllocator finds available device name, taking into account already assigned device names from ExistingNames map. It tries to find the next device name to the previously assigned one (from previous NameAllocator call), so all available device names are used eventually and it minimizes device name reuse.

Jump to

Keyboard shortcuts

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