Documentation
¶
Overview ¶
Package spec is a generated GoMock package.
Index ¶
- func IsRollback(current *v1beta1.Device, desired *v1beta1.Device) bool
- func IsUpgrading(current *v1beta1.Device, desired *v1beta1.Device) bool
- func NewManager(deviceName string, dataDir string, policyManager policy.Manager, ...) *manager
- type Item
- type ItemHeap
- type LastStatusInvalidator
- type Manager
- type MockManager
- func (m *MockManager) CheckOsReconciliation(ctx context.Context) (string, bool, error)
- func (m *MockManager) CheckPolicy(ctx context.Context, policyType policy.Type, version string) error
- func (m *MockManager) ClearRollback() error
- func (m *MockManager) CreateRollback(ctx context.Context) error
- func (m *MockManager) EXPECT() *MockManagerMockRecorder
- func (m *MockManager) Ensure() error
- func (m *MockManager) GetDesired(ctx context.Context) (*v1beta1.Device, bool, error)
- func (m *MockManager) GetRollbackInfo() (RollbackInfo, error)
- func (m *MockManager) Initialize(ctx context.Context) error
- func (m *MockManager) IsRollingBack(ctx context.Context) (bool, error)
- func (m *MockManager) IsUpgrading() bool
- func (m *MockManager) OSVersion(specType Type) string
- func (m *MockManager) Read(specType Type) (*v1beta1.Device, error)
- func (m *MockManager) RecordRollbackError(ctx context.Context, message string) error
- func (m *MockManager) RenderedVersion(specType Type) string
- func (m *MockManager) Rollback(ctx context.Context, opts ...RollbackOption) error
- func (m *MockManager) SetClient(client client.Management)
- func (m *MockManager) SetUpgradeFailed(version, specHash string) error
- func (m *MockManager) ShouldApplyOSImageUpdate() bool
- func (m *MockManager) ShouldApplyOSImageUpdatePending(ctx context.Context) (bool, error)
- func (m *MockManager) Status(arg0 context.Context, arg1 *v1beta1.DeviceStatus, arg2 ...status.CollectorOpt) error
- func (m *MockManager) Upgrade(ctx context.Context) error
- type MockManagerMockRecorder
- func (mr *MockManagerMockRecorder) CheckOsReconciliation(ctx any) *gomock.Call
- func (mr *MockManagerMockRecorder) CheckPolicy(ctx, policyType, version any) *gomock.Call
- func (mr *MockManagerMockRecorder) ClearRollback() *gomock.Call
- func (mr *MockManagerMockRecorder) CreateRollback(ctx any) *gomock.Call
- func (mr *MockManagerMockRecorder) Ensure() *gomock.Call
- func (mr *MockManagerMockRecorder) GetDesired(ctx any) *gomock.Call
- func (mr *MockManagerMockRecorder) GetRollbackInfo() *gomock.Call
- func (mr *MockManagerMockRecorder) Initialize(ctx any) *gomock.Call
- func (mr *MockManagerMockRecorder) IsRollingBack(ctx any) *gomock.Call
- func (mr *MockManagerMockRecorder) IsUpgrading() *gomock.Call
- func (mr *MockManagerMockRecorder) OSVersion(specType any) *gomock.Call
- func (mr *MockManagerMockRecorder) Read(specType any) *gomock.Call
- func (mr *MockManagerMockRecorder) RecordRollbackError(ctx, message any) *gomock.Call
- func (mr *MockManagerMockRecorder) RenderedVersion(specType any) *gomock.Call
- func (mr *MockManagerMockRecorder) Rollback(ctx any, opts ...any) *gomock.Call
- func (mr *MockManagerMockRecorder) SetClient(client any) *gomock.Call
- func (mr *MockManagerMockRecorder) SetUpgradeFailed(version, specHash any) *gomock.Call
- func (mr *MockManagerMockRecorder) ShouldApplyOSImageUpdate() *gomock.Call
- func (mr *MockManagerMockRecorder) ShouldApplyOSImageUpdatePending(ctx any) *gomock.Call
- func (mr *MockManagerMockRecorder) Status(arg0, arg1 any, arg2 ...any) *gomock.Call
- func (mr *MockManagerMockRecorder) Upgrade(ctx any) *gomock.Call
- type MockPriorityQueue
- func (m *MockPriorityQueue) Add(ctx context.Context, spec *v1beta1.Device)
- func (m *MockPriorityQueue) CheckPolicy(ctx context.Context, policyType policy.Type, version string) error
- func (m *MockPriorityQueue) EXPECT() *MockPriorityQueueMockRecorder
- func (m *MockPriorityQueue) IsFailed(version int64, specHash string) bool
- func (m *MockPriorityQueue) Next(ctx context.Context) (*v1beta1.Device, bool)
- func (m *MockPriorityQueue) Remove(version int64)
- func (m *MockPriorityQueue) SetFailed(version int64, specHash string)
- type MockPriorityQueueMockRecorder
- func (mr *MockPriorityQueueMockRecorder) Add(ctx, spec any) *gomock.Call
- func (mr *MockPriorityQueueMockRecorder) CheckPolicy(ctx, policyType, version any) *gomock.Call
- func (mr *MockPriorityQueueMockRecorder) IsFailed(version, specHash any) *gomock.Call
- func (mr *MockPriorityQueueMockRecorder) Next(ctx any) *gomock.Call
- func (mr *MockPriorityQueueMockRecorder) Remove(version any) *gomock.Call
- func (mr *MockPriorityQueueMockRecorder) SetFailed(version, specHash any) *gomock.Call
- type MockWatcher
- type MockWatcherMockRecorder
- type PriorityQueue
- type Publisher
- type RollbackInfo
- type RollbackOption
- type Type
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRollback ¶ added in v0.8.1
IsRollback returns true if the version of the current spec is greater than the desired.
func IsUpgrading ¶ added in v0.3.0
func NewManager ¶
func NewManager( deviceName string, dataDir string, policyManager policy.Manager, deviceReadWriter fileio.ReadWriter, osClient os.Client, caps os.Capabilities, pollConfig poll.Config, errorBackoff poll.Config, deviceNotFoundHandler func() error, auditLogger audit.Logger, log *log.PrefixLogger, ) *manager
NewManager creates a new device spec manager.
Note: This manager is designed for sequential operations only and is not thread-safe.
Types ¶
type ItemHeap ¶ added in v0.3.0
type ItemHeap []*Item
ItemHeap is a priority queue that orders items by version.
type LastStatusInvalidator ¶ added in v1.2.0
type LastStatusInvalidator interface {
InvalidateLastStatus()
}
LastStatusInvalidator is called when the server returns ConflictPaused so the next status sync pushes device details. Implemented by status.Manager.
type Manager ¶
type Manager interface {
// Initialize initializes the current, desired and rollback device files on
// disk. If the files already exist, they are overwritten.
Initialize(ctx context.Context) error
// Ensure ensures that spec files exist on disk and re initializes them if they do not.
Ensure() error
// RenderedVersion returns the rendered version of the specified spec type.
RenderedVersion(specType Type) string
// OSVersion returns the OS version of the specified spec type.
OSVersion(specType Type) string
// Read returns the rendered device of the specified type from disk.
Read(specType Type) (*v1beta1.Device, error)
// Upgrade updates the current rendered spec to the desired rendered spec
// and resets the rollback spec.
Upgrade(ctx context.Context) error
// SetUpgradeFailed marks the desired rendered spec as failed.
// The specHash parameter allows tracking failed specs by content hash,
// enabling detection of console-only changes on failed specs.
SetUpgradeFailed(version string, specHash string) error
// IsUpdating returns true if the device is in the process of reconciling the desired spec.
IsUpgrading() bool
// ShouldApplyOSImageUpdate returns true if the agent should run the OS
// image update path (desired OS image differs from current). Always false
// on package-mode, which has no image manager.
ShouldApplyOSImageUpdate() bool
// ShouldApplyOSImageUpdatePending returns true if an OS image update is
// specified but the device has not yet booted into the new image.
ShouldApplyOSImageUpdatePending(ctx context.Context) (bool, error)
// CheckOsReconciliation checks if the booted OS image matches the desired OS image.
CheckOsReconciliation(ctx context.Context) (string, bool, error)
// IsRollingBack returns true if the device is in a rollback state.
IsRollingBack(ctx context.Context) (bool, error)
// CreateRollback creates a rollback version of the current rendered spec.
CreateRollback(ctx context.Context) error
// ClearRollback clears the rollback rendered spec.
ClearRollback() error
// GetRollbackInfo returns the desired version, spec hash, and persisted
// sync error stored in rollback.json. These identify the spec we were
// upgrading to when the rollback was created.
GetRollbackInfo() (RollbackInfo, error)
// RecordRollbackError stores the sync error that caused a rollback in
// rollback.json so the message survives the rollback reboot.
RecordRollbackError(ctx context.Context, message string) error
// Rollback reverts the device to the state of the rollback rendered spec.
Rollback(ctx context.Context, opts ...RollbackOption) error
// GetDesired returns the desired rendered device from the management API.
GetDesired(ctx context.Context) (*v1beta1.Device, bool, error)
// CheckPolicy validates the update policy is ready to process.
CheckPolicy(ctx context.Context, policyType policy.Type, version string) error
// SetClient sets the management client for fetching specs.
SetClient(client client.Management)
status.Exporter
}
Manager provides the public API for managing device specifications. This interface is used by the device agent for normal operations.
type MockManager ¶
type MockManager struct {
// contains filtered or unexported fields
}
MockManager is a mock of Manager interface.
func NewMockManager ¶
func NewMockManager(ctrl *gomock.Controller) *MockManager
NewMockManager creates a new mock instance.
func (*MockManager) CheckOsReconciliation ¶
CheckOsReconciliation mocks base method.
func (*MockManager) CheckPolicy ¶ added in v0.4.0
func (m *MockManager) CheckPolicy(ctx context.Context, policyType policy.Type, version string) error
CheckPolicy mocks base method.
func (*MockManager) ClearRollback ¶ added in v0.4.0
func (m *MockManager) ClearRollback() error
ClearRollback mocks base method.
func (*MockManager) CreateRollback ¶ added in v0.4.0
func (m *MockManager) CreateRollback(ctx context.Context) error
CreateRollback mocks base method.
func (*MockManager) EXPECT ¶
func (m *MockManager) EXPECT() *MockManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockManager) GetDesired ¶
GetDesired mocks base method.
func (*MockManager) GetRollbackInfo ¶ added in v1.2.0
func (m *MockManager) GetRollbackInfo() (RollbackInfo, error)
GetRollbackInfo mocks base method.
func (*MockManager) Initialize ¶
func (m *MockManager) Initialize(ctx context.Context) error
Initialize mocks base method.
func (*MockManager) IsRollingBack ¶
func (m *MockManager) IsRollingBack(ctx context.Context) (bool, error)
IsRollingBack mocks base method.
func (*MockManager) IsUpgrading ¶ added in v0.3.0
func (m *MockManager) IsUpgrading() bool
IsUpgrading mocks base method.
func (*MockManager) OSVersion ¶ added in v0.4.0
func (m *MockManager) OSVersion(specType Type) string
OSVersion mocks base method.
func (*MockManager) Read ¶
func (m *MockManager) Read(specType Type) (*v1beta1.Device, error)
Read mocks base method.
func (*MockManager) RecordRollbackError ¶ added in v1.4.0
func (m *MockManager) RecordRollbackError(ctx context.Context, message string) error
RecordRollbackError mocks base method.
func (*MockManager) RenderedVersion ¶ added in v0.4.0
func (m *MockManager) RenderedVersion(specType Type) string
RenderedVersion mocks base method.
func (*MockManager) Rollback ¶
func (m *MockManager) Rollback(ctx context.Context, opts ...RollbackOption) error
Rollback mocks base method.
func (*MockManager) SetClient ¶
func (m *MockManager) SetClient(client client.Management)
SetClient mocks base method.
func (*MockManager) SetUpgradeFailed ¶ added in v0.3.0
func (m *MockManager) SetUpgradeFailed(version, specHash string) error
SetUpgradeFailed mocks base method.
func (*MockManager) ShouldApplyOSImageUpdate ¶ added in v1.3.0
func (m *MockManager) ShouldApplyOSImageUpdate() bool
ShouldApplyOSImageUpdate mocks base method.
func (*MockManager) ShouldApplyOSImageUpdatePending ¶ added in v1.3.0
func (m *MockManager) ShouldApplyOSImageUpdatePending(ctx context.Context) (bool, error)
ShouldApplyOSImageUpdatePending mocks base method.
func (*MockManager) Status ¶ added in v0.4.0
func (m *MockManager) Status(arg0 context.Context, arg1 *v1beta1.DeviceStatus, arg2 ...status.CollectorOpt) error
Status mocks base method.
type MockManagerMockRecorder ¶
type MockManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockManagerMockRecorder is the mock recorder for MockManager.
func (*MockManagerMockRecorder) CheckOsReconciliation ¶
func (mr *MockManagerMockRecorder) CheckOsReconciliation(ctx any) *gomock.Call
CheckOsReconciliation indicates an expected call of CheckOsReconciliation.
func (*MockManagerMockRecorder) CheckPolicy ¶ added in v0.4.0
func (mr *MockManagerMockRecorder) CheckPolicy(ctx, policyType, version any) *gomock.Call
CheckPolicy indicates an expected call of CheckPolicy.
func (*MockManagerMockRecorder) ClearRollback ¶ added in v0.4.0
func (mr *MockManagerMockRecorder) ClearRollback() *gomock.Call
ClearRollback indicates an expected call of ClearRollback.
func (*MockManagerMockRecorder) CreateRollback ¶ added in v0.4.0
func (mr *MockManagerMockRecorder) CreateRollback(ctx any) *gomock.Call
CreateRollback indicates an expected call of CreateRollback.
func (*MockManagerMockRecorder) Ensure ¶
func (mr *MockManagerMockRecorder) Ensure() *gomock.Call
Ensure indicates an expected call of Ensure.
func (*MockManagerMockRecorder) GetDesired ¶
func (mr *MockManagerMockRecorder) GetDesired(ctx any) *gomock.Call
GetDesired indicates an expected call of GetDesired.
func (*MockManagerMockRecorder) GetRollbackInfo ¶ added in v1.2.0
func (mr *MockManagerMockRecorder) GetRollbackInfo() *gomock.Call
GetRollbackInfo indicates an expected call of GetRollbackInfo.
func (*MockManagerMockRecorder) Initialize ¶
func (mr *MockManagerMockRecorder) Initialize(ctx any) *gomock.Call
Initialize indicates an expected call of Initialize.
func (*MockManagerMockRecorder) IsRollingBack ¶
func (mr *MockManagerMockRecorder) IsRollingBack(ctx any) *gomock.Call
IsRollingBack indicates an expected call of IsRollingBack.
func (*MockManagerMockRecorder) IsUpgrading ¶ added in v0.3.0
func (mr *MockManagerMockRecorder) IsUpgrading() *gomock.Call
IsUpgrading indicates an expected call of IsUpgrading.
func (*MockManagerMockRecorder) OSVersion ¶ added in v0.4.0
func (mr *MockManagerMockRecorder) OSVersion(specType any) *gomock.Call
OSVersion indicates an expected call of OSVersion.
func (*MockManagerMockRecorder) Read ¶
func (mr *MockManagerMockRecorder) Read(specType any) *gomock.Call
Read indicates an expected call of Read.
func (*MockManagerMockRecorder) RecordRollbackError ¶ added in v1.4.0
func (mr *MockManagerMockRecorder) RecordRollbackError(ctx, message any) *gomock.Call
RecordRollbackError indicates an expected call of RecordRollbackError.
func (*MockManagerMockRecorder) RenderedVersion ¶ added in v0.4.0
func (mr *MockManagerMockRecorder) RenderedVersion(specType any) *gomock.Call
RenderedVersion indicates an expected call of RenderedVersion.
func (*MockManagerMockRecorder) Rollback ¶
func (mr *MockManagerMockRecorder) Rollback(ctx any, opts ...any) *gomock.Call
Rollback indicates an expected call of Rollback.
func (*MockManagerMockRecorder) SetClient ¶
func (mr *MockManagerMockRecorder) SetClient(client any) *gomock.Call
SetClient indicates an expected call of SetClient.
func (*MockManagerMockRecorder) SetUpgradeFailed ¶ added in v0.3.0
func (mr *MockManagerMockRecorder) SetUpgradeFailed(version, specHash any) *gomock.Call
SetUpgradeFailed indicates an expected call of SetUpgradeFailed.
func (*MockManagerMockRecorder) ShouldApplyOSImageUpdate ¶ added in v1.3.0
func (mr *MockManagerMockRecorder) ShouldApplyOSImageUpdate() *gomock.Call
ShouldApplyOSImageUpdate indicates an expected call of ShouldApplyOSImageUpdate.
func (*MockManagerMockRecorder) ShouldApplyOSImageUpdatePending ¶ added in v1.3.0
func (mr *MockManagerMockRecorder) ShouldApplyOSImageUpdatePending(ctx any) *gomock.Call
ShouldApplyOSImageUpdatePending indicates an expected call of ShouldApplyOSImageUpdatePending.
type MockPriorityQueue ¶ added in v0.3.0
type MockPriorityQueue struct {
// contains filtered or unexported fields
}
MockPriorityQueue is a mock of PriorityQueue interface.
func NewMockPriorityQueue ¶ added in v0.3.0
func NewMockPriorityQueue(ctrl *gomock.Controller) *MockPriorityQueue
NewMockPriorityQueue creates a new mock instance.
func (*MockPriorityQueue) Add ¶ added in v0.3.0
func (m *MockPriorityQueue) Add(ctx context.Context, spec *v1beta1.Device)
Add mocks base method.
func (*MockPriorityQueue) CheckPolicy ¶ added in v0.4.0
func (m *MockPriorityQueue) CheckPolicy(ctx context.Context, policyType policy.Type, version string) error
CheckPolicy mocks base method.
func (*MockPriorityQueue) EXPECT ¶ added in v0.3.0
func (m *MockPriorityQueue) EXPECT() *MockPriorityQueueMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPriorityQueue) IsFailed ¶ added in v0.4.0
func (m *MockPriorityQueue) IsFailed(version int64, specHash string) bool
IsFailed mocks base method.
func (*MockPriorityQueue) Remove ¶ added in v0.3.0
func (m *MockPriorityQueue) Remove(version int64)
Remove mocks base method.
func (*MockPriorityQueue) SetFailed ¶ added in v0.4.0
func (m *MockPriorityQueue) SetFailed(version int64, specHash string)
SetFailed mocks base method.
type MockPriorityQueueMockRecorder ¶ added in v0.3.0
type MockPriorityQueueMockRecorder struct {
// contains filtered or unexported fields
}
MockPriorityQueueMockRecorder is the mock recorder for MockPriorityQueue.
func (*MockPriorityQueueMockRecorder) Add ¶ added in v0.3.0
func (mr *MockPriorityQueueMockRecorder) Add(ctx, spec any) *gomock.Call
Add indicates an expected call of Add.
func (*MockPriorityQueueMockRecorder) CheckPolicy ¶ added in v0.4.0
func (mr *MockPriorityQueueMockRecorder) CheckPolicy(ctx, policyType, version any) *gomock.Call
CheckPolicy indicates an expected call of CheckPolicy.
func (*MockPriorityQueueMockRecorder) IsFailed ¶ added in v0.4.0
func (mr *MockPriorityQueueMockRecorder) IsFailed(version, specHash any) *gomock.Call
IsFailed indicates an expected call of IsFailed.
func (*MockPriorityQueueMockRecorder) Next ¶ added in v0.3.0
func (mr *MockPriorityQueueMockRecorder) Next(ctx any) *gomock.Call
Next indicates an expected call of Next.
type MockWatcher ¶ added in v0.10.0
type MockWatcher struct {
// contains filtered or unexported fields
}
MockWatcher is a mock of Watcher interface.
func NewMockWatcher ¶ added in v0.10.0
func NewMockWatcher(ctrl *gomock.Controller) *MockWatcher
NewMockWatcher creates a new mock instance.
func (*MockWatcher) EXPECT ¶ added in v0.10.0
func (m *MockWatcher) EXPECT() *MockWatcherMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockWatcherMockRecorder ¶ added in v0.10.0
type MockWatcherMockRecorder struct {
// contains filtered or unexported fields
}
MockWatcherMockRecorder is the mock recorder for MockWatcher.
func (*MockWatcherMockRecorder) Pop ¶ added in v0.10.0
func (mr *MockWatcherMockRecorder) Pop() *gomock.Call
Pop indicates an expected call of Pop.
func (*MockWatcherMockRecorder) TryPop ¶ added in v0.10.0
func (mr *MockWatcherMockRecorder) TryPop() *gomock.Call
TryPop indicates an expected call of TryPop.
type PriorityQueue ¶ added in v0.3.0
type PriorityQueue interface {
// Add adds a new spec to the scheduler
Add(ctx context.Context, spec *v1beta1.Device)
// Next returns the next spec to process
Next(ctx context.Context) (*v1beta1.Device, bool)
// Remove removes a spec from the scheduler
Remove(version int64)
// SetFailed marks a rendered spec version and/or spec hash as failed.
SetFailed(version int64, specHash string)
// IsFailed returns true if the version or spec hash is marked as failed.
IsFailed(version int64, specHash string) bool
// CheckPolicy validates the update policy is ready to process.
CheckPolicy(ctx context.Context, policyType policy.Type, version string) error
}
type Publisher ¶ added in v0.10.0
type Publisher interface {
Run(ctx context.Context)
Watch() Watcher
SetClient(client.Management)
SetOnConflictPausedInvalidator(LastStatusInvalidator)
ResetVersion(version string)
}
type RollbackInfo ¶ added in v1.2.0
RollbackInfo contains the desired version, spec hash, and optional sync error from the rollback spec. These identify the spec we were upgrading to when the rollback was created and, when present, the reason the update failed.
type RollbackOption ¶ added in v0.5.0
type RollbackOption func(*rollbackConfig)
func WithSetFailed ¶ added in v0.5.0
func WithSetFailed() RollbackOption
WithSetFailed enables setting the desired spec as failed.
type Watcher ¶ added in v0.10.0
type Watcher interface {
// Pop blocks until a device is available or returns error if closed
Pop() (*v1beta1.Device, error)
// TryPop attempts to get a device without blocking
TryPop() (*v1beta1.Device, bool, error)
}
Watcher provides a way to watch for device spec updates.