Help us shape the future of Go! Take the 2026 Go Developer Survey

device

package
v1.20.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DesiredDeviceIndex = statedb.Index[*DesiredDevice, DesiredDeviceKey]{
		Name: "id",
		FromObject: func(obj *DesiredDevice) index.KeySet {
			return index.NewKeySet(obj.GetKey().Key())
		},
		FromKey:    DesiredDeviceKey.Key,
		FromString: index.FromString,
		Unique:     true,
	}
	DesiredDeviceNameIndex = statedb.Index[*DesiredDevice, string]{
		Name: "name",
		FromObject: func(obj *DesiredDevice) index.KeySet {
			return index.NewKeySet(index.String(obj.Name))
		},
		FromKey:    index.String,
		FromString: index.FromString,
		Unique:     true,
	}
)
View Source
var Cell = cell.Module(
	"device-reconciler",
	"Reconciles desired devices to the Linux kernel links",
	TableCell,
	cell.Provide(newDeviceManager),
	cell.Invoke(registerReconciler),
)
View Source
var (
	ErrOwnerDoesNotExist = errors.New("owner does not exist")
)
View Source
var TableCell = cell.Group(
	cell.ProvidePrivate(newDesiredDeviceTable),
	cell.Provide(statedb.RWTable[*DesiredDevice].ToTable),
)

Functions

This section is empty.

Types

type DesiredDevice

type DesiredDevice struct {
	Owner      DeviceOwner       `json:"owner" yaml:"owner"`
	Name       string            `json:"name" yaml:"name"`
	DeviceSpec DesiredDeviceSpec `json:"spec" yaml:"spec"`
	// contains filtered or unexported fields
}

func (*DesiredDevice) Clone

func (dd *DesiredDevice) Clone() *DesiredDevice

func (*DesiredDevice) GetKey

func (dd *DesiredDevice) GetKey() DesiredDeviceKey

func (*DesiredDevice) GetStatus

func (dd *DesiredDevice) GetStatus() reconciler.Status

func (*DesiredDevice) SetStatus

func (dd *DesiredDevice) SetStatus(s reconciler.Status) *DesiredDevice

func (*DesiredDevice) TableHeader

func (dd *DesiredDevice) TableHeader() []string

func (*DesiredDevice) TableRow

func (dd *DesiredDevice) TableRow() []string

func (*DesiredDevice) Validate

func (dd *DesiredDevice) Validate() error

type DesiredDeviceKey

type DesiredDeviceKey struct {
	Owner DeviceOwner
	Name  string
}

func (DesiredDeviceKey) Key

func (k DesiredDeviceKey) Key() index.Key

func (*DesiredDeviceKey) MarshalBinary

func (k *DesiredDeviceKey) MarshalBinary() ([]byte, error)

func (DesiredDeviceKey) String

func (k DesiredDeviceKey) String() string

func (*DesiredDeviceKey) UnmarshalBinary

func (k *DesiredDeviceKey) UnmarshalBinary(data []byte) error

type DesiredDeviceSpec

type DesiredDeviceSpec interface {
	ToNetlink() (netlink.Link, error)
	Properties() string
	MarshalJSON() ([]byte, error)
	MarshalYAML() (any, error)
	// NeedsRecreate reports whether the existing kernel device must be deleted
	// and re-added rather than modified in-place. It is only called when a
	// device with this name already exists.
	//
	// It must return true ONLY when an immutable kernel attribute (e.g. VRF
	// table ID, VLAN ID) actually differs between the desired spec and the
	// existing device. Returning true unconditionally causes a destructive
	// delete+add on every reconcile (including periodic refresh).
	NeedsRecreate(existing netlink.Link) bool
}

type DesiredVLANDeviceSpec

type DesiredVLANDeviceSpec struct {
	Name        string `json:"name" yaml:"name"`
	VLANID      int    `json:"vlanID" yaml:"vlanID"`
	MTU         int    `json:"mtu" yaml:"mtu"`
	ParentName  string `json:"parentName" yaml:"parentName"`
	ParentIndex int    `json:"parentIndex" yaml:"parentIndex"`
}

func (*DesiredVLANDeviceSpec) MarshalJSON

func (d *DesiredVLANDeviceSpec) MarshalJSON() ([]byte, error)

func (*DesiredVLANDeviceSpec) MarshalYAML

func (d *DesiredVLANDeviceSpec) MarshalYAML() (any, error)

func (*DesiredVLANDeviceSpec) NeedsRecreate

func (d *DesiredVLANDeviceSpec) NeedsRecreate(existing netlink.Link) bool

NeedsRecreate reports whether the existing VLAN device must be recreated. The VLAN ID and parent interface are immutable, so a recreate is only needed when one of those differs from the desired spec. Mutable attributes (e.g. MTU) are handled in-place via LinkModify.

func (*DesiredVLANDeviceSpec) Properties

func (d *DesiredVLANDeviceSpec) Properties() string
func (d *DesiredVLANDeviceSpec) ToNetlink() (netlink.Link, error)

type DeviceOwner

type DeviceOwner struct {
	Name string `json:"name" yaml:"name"`
}

type Initializer

type Initializer struct {
	// contains filtered or unexported fields
}

type ManagerOperations

type ManagerOperations interface {
	// UpsertDevice upserts a desired device into the desired device table.
	UpsertDevice(device DesiredDevice) error
	// UpsertDeviceWait upserts a desired device into the desired device table
	// and waits for the device to be reconciled.
	UpsertDeviceWait(device DesiredDevice, timeout time.Duration) error
	// DeleteDevice deletes a desired device from the desired device table.
	DeleteDevice(device DesiredDevice) error
	// GetOrRegisterOwner gets or registers an owner with the given name.
	GetOrRegisterOwner(name string) DeviceOwner
	// RemoveOwner removes an owner and associated devices with the given owner.
	RemoveOwner(owner DeviceOwner) error
	// RegisterInitializer registers an initializer with the given name and returns
	// the initializer to the caller.
	RegisterInitializer(name string) Initializer
	// FinalizeInitializer should be called by the caller with registered initializer
	// once callers initial sync is completed. Once all initializers are finalized,
	// the reconciler will start initial pruning.
	FinalizeInitializer(initializer Initializer)
}

ManagerOperations is the interface for the desired device reconciler manager

Jump to

Keyboard shortcuts

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