app

package
v0.0.0-...-5969d1b Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 34 Imported by: 2

Documentation

Overview

Copyright 2023 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2023 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2023 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2023 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2023 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2022 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2023 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Index

Constants

View Source
const (
	ActionFetchAuthToken = "FETCH_AUTH_TOKEN"
	ActionGetAuthToken   = "GET_AUTH_TOKEN"
)

Constants for auth manager request actions

View Source
const (
	EventFetchAuthToken       = "FETCH_AUTH_TOKEN"
	EventGetAuthToken         = "GET_AUTH_TOKEN"
	EventAuthTokenStateChange = "AUTH_TOKEN_STATE_CHANGE"
)

Constants for auth manager response events

View Source
const (
	AuthManagerDBusPath                      = "/io/mender/AuthenticationManager"
	AuthManagerDBusObjectName                = "io.mender.AuthenticationManager"
	AuthManagerDBusInterfaceName             = "io.mender.Authentication1"
	AuthManagerDBusSignalJwtTokenStateChange = "JwtTokenStateChange"
	AuthManagerDBusInterface                 = `` /* 430-byte string literal not displayed */

)

Constants for the auth manager DBus interface

View Source
const (
	UpdateManagerDBusPath          = "/io/mender/UpdateManager"
	UpdateManagerDBusObjectName    = "io.mender.UpdateManager"
	UpdateManagerDBusInterfaceName = "io.mender.Update1"
	UpdateManagerDBusInterface     = `` /* 259-byte string literal not displayed */

)

Variables

View Source
var (
	ErrLoggerNotInitialized  = errors.New("logger not initialized")
	ErrNotEnoughSpaceForLogs = errors.New("not enough space for storing logs")
)

error messages

View Source
var (
	ErrorManualRebootRequired = errors.New("Manual reboot required")
)
View Source
var NoUpdateMapsErr = errors.New("No update control maps exist")
View Source
var States = StateCollection{
	CheckWait: NewCheckWaitState().(*checkWaitState),
	Final: &finalState{
		baseState{
			id: datastore.MenderStateDone,
			t:  ToNone,
		},
	},
	Init: &initState{
		baseState{
			id: datastore.MenderStateInit,
			t:  ToNone,
		},
	},
	Idle: &idleState{
		baseState{
			id: datastore.MenderStateIdle,
			t:  ToIdle,
		},
	},
	InventoryUpdate: NewInventoryUpdateState().(*inventoryUpdateState),
	UpdateCheck: &updateCheckState{
		baseState{
			id: datastore.MenderStateUpdateCheck,
			t:  ToSync,
		},
	},
}

Exposed state variables.

Functions

func DoStandaloneCommit

func DoStandaloneCommit(device *dev.DeviceManager, stateExec statescript.Executor) error

func DoStandaloneInstall

func DoStandaloneInstall(device *dev.DeviceManager, updateURI string,
	clientConfig conf.HttpConfig,
	stateExec statescript.Executor, rebootExitCode bool) error

This will be run manually from command line ONLY

func DoStandaloneRollback

func DoStandaloneRollback(device *dev.DeviceManager, stateExec statescript.Executor) error

func Min

func Min(a, b int) int

func NewFatalError

func NewFatalError(err error) menderError

Create a new fatal error. Fatal errors will be reported back to the server.

func NewTransientError

func NewTransientError(err error) menderError

Create a new transient error. Transient errors will normally not be reported back to the server, unless they persist long enough for the client to give up.

func NewUpdateRollbackState

func NewUpdateRollbackState(update *datastore.UpdateInfo) *updateRollbackState

func NewUpdateState

func NewUpdateState(id datastore.MenderState, t Transition, u *datastore.UpdateInfo) *updateState

func NewWaitState

func NewWaitState(id datastore.MenderState, t Transition) *waitState

func RemoveStateData

func RemoveStateData(store store.Store) error

func StateStatus

func StateStatus(m datastore.MenderState) string

Types

type AuthManager

type AuthManager interface {
	Bootstrap() menderError
	ForceBootstrap()
	GetInMessageChan() chan<- AuthManagerRequest
	GetBroadcastMessageChan(name string) <-chan AuthManagerResponse
	Start()
	Stop()
	EnableDBus(api dbus.DBusAPI)

	// check if device key is available
	HasKey() bool
	// generate device key (will overwrite an already existing key)
	GenerateKey() error

	client.AuthDataMessenger
}

AuthManager is the interface of a Mender authorization manager

type AuthManagerConfig

type AuthManagerConfig struct {
	Config         *conf.MenderConfig        // mender config struct
	AuthDataStore  store.Store               // authorization data store
	KeyStore       *store.Keystore           // key storage
	IdentitySource device.IdentityDataGetter // provider of identity data
	TenantToken    []byte                    // tenant token
}

AuthManagerConfig holds the configuration of the auth manager

type AuthManagerRequest

type AuthManagerRequest struct {
	Action          string
	ResponseChannel chan<- AuthManagerResponse
}

AuthManagerRequest stores a request to the Mender authorization manager

type AuthManagerResponse

type AuthManagerResponse struct {
	AuthToken client.AuthToken
	ServerURL client.ServerURL
	Event     string
	Error     error
}

AuthManagerResponse stores a response from the Mender authorization manager

type ControlMapPool

type ControlMapPool struct {
	Pool []*updatecontrolmap.UpdateControlMap

	Updates chan bool // Announces all updates to the maps
	// contains filtered or unexported fields
}

func NewControlMap

func NewControlMap(
	store store.Store,
	loadTimeout, updateControlMapExpirationTimeSeconds int,
) *ControlMapPool

loadTimeout is how far in the future to set the map expiry when loading from the store.

func (*ControlMapPool) ClearExpired

func (c *ControlMapPool) ClearExpired()

func (*ControlMapPool) Delete

func (c *ControlMapPool) Delete(ID string, priority int)

func (*ControlMapPool) DeleteAllPriorities

func (c *ControlMapPool) DeleteAllPriorities(ID string)

func (*ControlMapPool) Get

func (*ControlMapPool) HasControlMap

func (c *ControlMapPool) HasControlMap(deploymentID string) bool

HasControlMap - Returns true in the event that a control map matches the given deploymentID.

func (*ControlMapPool) Insert

func (*ControlMapPool) InsertReplaceAllPriorities

func (c *ControlMapPool) InsertReplaceAllPriorities(cm *updatecontrolmap.UpdateControlMap)

func (*ControlMapPool) NextAnyControlMapHalfTime

func (c *ControlMapPool) NextAnyControlMapHalfTime(ID string) (time.Time, error)

NextAnyControlMapHalfTime returns the minimum HalfWayTime of the active maps

func (*ControlMapPool) NextIDControlMapHalfTime

func (c *ControlMapPool) NextIDControlMapHalfTime(ID string) (time.Time, error)

NextIDControlMapHalfTime returns the minimum HalfWayTime of the active maps matching the given ID (typically, server-side maps)

func (*ControlMapPool) QueryAndUpdate

func (c *ControlMapPool) QueryAndUpdate(state string) (action string)

QueryAndUpdate queries the map pool for the correct action to return

func (*ControlMapPool) SetStore

func (c *ControlMapPool) SetStore(store store.Store)

type Controller

type Controller interface {
	Authorize() (client.AuthToken, client.ServerURL, error)
	ClearAuthorization()

	GetControlMapPool() *ControlMapPool

	GetCurrentArtifactName() (string, error)
	GetUpdatePollInterval() time.Duration
	GetInventoryPollInterval() time.Duration
	GetRetryPollInterval() time.Duration
	GetRetryPollCount() int

	HandleBootstrapArtifact(s store.Store) error

	CheckUpdate() (*datastore.UpdateInfo, menderError)
	FetchUpdate(url string) (io.ReadCloser, int64, error)
	RefreshServerUpdateControlMap(deploymentID string) error

	NewStatusReportWrapper(updateId string,
		stateId datastore.MenderState) *client.StatusReportWrapper
	ReportUpdateStatus(update *datastore.UpdateInfo, status string) menderError
	UploadLog(update *datastore.UpdateInfo, logs []byte) menderError
	InventoryRefresh() error

	CheckScriptsCompatibility() error
	GetScriptExecutor() statescript.Executor

	ReadArtifactHeaders(from io.ReadCloser) (*installer.Installer, error)
	GetInstallers() []installer.PayloadUpdatePerformer

	RestoreInstallersFromTypeList(payloadTypes []string) error

	StateRunner
}

type DeploymentHook

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

func NewDeploymentLogHook

func NewDeploymentLogHook(logManager *DeploymentLogManager) *DeploymentHook

func (DeploymentHook) Fire

func (dh DeploymentHook) Fire(entry *logrus.Entry) error

func (DeploymentHook) Levels

func (dh DeploymentHook) Levels() []logrus.Level

type DeploymentJSONFormatter

type DeploymentJSONFormatter struct {
	// TimestampFormat sets the format used for marshaling timestamps.
	TimestampFormat string
}

func (*DeploymentJSONFormatter) Format

func (f *DeploymentJSONFormatter) Format(entry *logrus.Entry) ([]byte, error)

type DeploymentLogManager

type DeploymentLogManager struct {
	// contains filtered or unexported fields
}
var DeploymentLogger *DeploymentLogManager

Global deploymentlogger

func NewDeploymentLogManager

func NewDeploymentLogManager(logDirLocation string) *DeploymentLogManager

func (*DeploymentLogManager) Disable

func (dlm *DeploymentLogManager) Disable() error

func (*DeploymentLogManager) Enable

func (dlm *DeploymentLogManager) Enable(deploymentID string) error

func (DeploymentLogManager) GetLogs

func (dlm DeploymentLogManager) GetLogs(deploymentID string) ([]byte, error)

GetLogs is returns logs as a JSON []byte string. Function is having the same signature as json.Marshal() ([]byte, error)

func (DeploymentLogManager) Rotate

func (dlm DeploymentLogManager) Rotate()

func (DeploymentLogManager) WriteLog

func (dlm DeploymentLogManager) WriteLog(log []byte) error

type FileLogger

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

func NewFileLogger

func NewFileLogger(name string) *FileLogger

NewFileLogger creates instance of file logger; it is initialized just before logging is started

func (*FileLogger) Deinit

func (fl *FileLogger) Deinit() error

func (*FileLogger) Write

func (fl *FileLogger) Write(log []byte) (int, error)

type Mender

type Mender struct {
	*dev.DeviceManager
	// contains filtered or unexported fields
}

func NewMender

func NewMender(config *conf.MenderConfig, pieces MenderPieces) (*Mender, error)

func (*Mender) Authorize

func (m *Mender) Authorize() (client.AuthToken, client.ServerURL, error)

func (*Mender) CheckScriptsCompatibility

func (m *Mender) CheckScriptsCompatibility() error

func (*Mender) CheckUpdate

func (m *Mender) CheckUpdate() (*datastore.UpdateInfo, menderError)

CheckUpdate Check if new update is available. In case of errors, returns nil and error that occurred. If no update is available *UpdateInfo is nil, otherwise it contains update information.

func (*Mender) ClearAuthorization

func (m *Mender) ClearAuthorization()

func (*Mender) FetchUpdate

func (m *Mender) FetchUpdate(url string) (io.ReadCloser, int64, error)

func (*Mender) GetControlMapPool

func (m *Mender) GetControlMapPool() *ControlMapPool

func (*Mender) GetCurrentState

func (m *Mender) GetCurrentState() State

func (*Mender) GetInventoryPollInterval

func (m *Mender) GetInventoryPollInterval() time.Duration

func (*Mender) GetRetryPollCount

func (m *Mender) GetRetryPollCount() int

func (*Mender) GetRetryPollInterval

func (m *Mender) GetRetryPollInterval() time.Duration

func (*Mender) GetScriptExecutor

func (m *Mender) GetScriptExecutor() statescript.Executor

func (*Mender) GetUpdatePollInterval

func (m *Mender) GetUpdatePollInterval() time.Duration

func (*Mender) HandleBootstrapArtifact

func (m *Mender) HandleBootstrapArtifact(s store.Store) error

func (*Mender) HandleControlMap

func (m *Mender) HandleControlMap(
	deploymentID string,
	updateControlMap *updatecontrolmap.UpdateControlMap,
) error

func (*Mender) InventoryRefresh

func (m *Mender) InventoryRefresh() error

func (*Mender) NewStatusReportWrapper

func (m *Mender) NewStatusReportWrapper(updateId string,
	stateId datastore.MenderState) *client.StatusReportWrapper

func (*Mender) RefreshServerUpdateControlMap

func (m *Mender) RefreshServerUpdateControlMap(deploymentID string) error

RefreshServerUpdateControlMap updates the control maps from the server during a deployment.

func (*Mender) ReportUpdateStatus

func (m *Mender) ReportUpdateStatus(update *datastore.UpdateInfo, status string) menderError

func (*Mender) SetNextState

func (m *Mender) SetNextState(s State)

func (*Mender) TransitionState

func (m *Mender) TransitionState(to State, ctx *StateContext) (State, bool)

func (*Mender) UploadLog

func (m *Mender) UploadLog(update *datastore.UpdateInfo, logs []byte) menderError

type MenderAuthManager

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

MenderAuthManager is the Mender authorization manager

func NewAuthManager

func NewAuthManager(config AuthManagerConfig) *MenderAuthManager

NewAuthManager returns a new Mender authorization manager instance

func (MenderAuthManager) Bootstrap

func (m MenderAuthManager) Bootstrap() menderError

Bootstrap performs the bootstrap, if needed or forced

func (*MenderAuthManager) EnableDBus

func (m *MenderAuthManager) EnableDBus(api dbus.DBusAPI)

func (MenderAuthManager) ForceBootstrap

func (m MenderAuthManager) ForceBootstrap()

ForceBootstrap forces the bootstrap

func (MenderAuthManager) GenerateKey

func (m MenderAuthManager) GenerateKey() error

GenerateKey generate device key (will overwrite an already existing key)

func (*MenderAuthManager) GetBroadcastMessageChan

func (m *MenderAuthManager) GetBroadcastMessageChan(name string) <-chan AuthManagerResponse

GetBroadcastMessageChan returns the channel to get responses from the auth manager

func (*MenderAuthManager) GetInMessageChan

func (m *MenderAuthManager) GetInMessageChan() chan<- AuthManagerRequest

GetInMessageChan returns the channel to send requests to the auth manager

func (MenderAuthManager) HasKey

func (m MenderAuthManager) HasKey() bool

HasKey check if device key is available

func (MenderAuthManager) MakeAuthRequest

func (m MenderAuthManager) MakeAuthRequest() (*client.AuthRequest, error)

MakeAuthRequest makes an auth request

func (*MenderAuthManager) Start

func (m *MenderAuthManager) Start()

This is idempotent, the service will only start once.

func (*MenderAuthManager) Stop

func (m *MenderAuthManager) Stop()

Stop the running MenderAuthManager. Must not be called in the same go routine as run(). This is idempotent, it is safe to call on a stopped service.

type MenderDaemon

type MenderDaemon struct {
	AuthManager          AuthManager
	UpdateControlManager *UpdateManager
	Mender               Controller
	Sctx                 StateContext
	Store                store.Store
	ForceToState         chan State
	// contains filtered or unexported fields
}

func NewDaemon

func NewDaemon(
	config *conf.MenderConfig,
	mender Controller,
	store store.Store,
	authManager AuthManager) (*MenderDaemon, error)

func (*MenderDaemon) Cleanup

func (d *MenderDaemon) Cleanup()

func (*MenderDaemon) Run

func (d *MenderDaemon) Run() error

func (*MenderDaemon) StopDaemon

func (d *MenderDaemon) StopDaemon()

type MenderError

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

func (*MenderError) Cause

func (m *MenderError) Cause() error

func (*MenderError) Error

func (m *MenderError) Error() string

func (*MenderError) IsFatal

func (m *MenderError) IsFatal() bool

func (*MenderError) Unwrap

func (m *MenderError) Unwrap() error

type MenderPieces

type MenderPieces struct {
	DualRootfsDevice installer.DualRootfsDevice
	Store            store.Store
	AuthManager      AuthManager
}

type State

type State interface {
	// Perform state action, returns next state and boolean flag indicating if
	// execution was cancelled or not
	Handle(ctx *StateContext, c Controller) (State, bool)
	HandleError(ctx *StateContext, c Controller, err menderError) (State, bool)
	// Cancel state action, returns true if action was cancelled
	Cancel() bool
	// Return numeric state ID
	Id() datastore.MenderState
	// Return transition
	Transition() Transition
	SetTransition(t Transition)
}

func NewCheckWaitState

func NewCheckWaitState() State

func NewControlMapPauseState

func NewControlMapPauseState(wrappedState UpdateState) State

func NewControlMapState

func NewControlMapState(wrapsState, pauseState UpdateState) State

func NewErrorState

func NewErrorState(err menderError) State

func NewFetchControlMapState

func NewFetchControlMapState(wrappedState, pauseState UpdateState) State

func NewFetchRetryControlMapState

func NewFetchRetryControlMapState(wrappedState, pauseState UpdateState) State

func NewFetchStoreRetryState

func NewFetchStoreRetryState(from State, update *datastore.UpdateInfo,
	err error) State

func NewInventoryUpdateRetryState

func NewInventoryUpdateRetryState(from State,
	err error) State

func NewInventoryUpdateState

func NewInventoryUpdateState() State

func NewUpdateAfterCommitState

func NewUpdateAfterCommitState(update *datastore.UpdateInfo) State

func NewUpdateAfterFirstCommitState

func NewUpdateAfterFirstCommitState(update *datastore.UpdateInfo) State

func NewUpdateAfterRebootState

func NewUpdateAfterRebootState(update *datastore.UpdateInfo) State

func NewUpdateAfterRollbackRebootState

func NewUpdateAfterRollbackRebootState(update *datastore.UpdateInfo) State

func NewUpdateAfterStoreState

func NewUpdateAfterStoreState(update *datastore.UpdateInfo) State

func NewUpdateCleanupState

func NewUpdateCleanupState(update *datastore.UpdateInfo, status string) State

func NewUpdateErrorState

func NewUpdateErrorState(err menderError, update *datastore.UpdateInfo) State

func NewUpdateFetchState

func NewUpdateFetchState(update *datastore.UpdateInfo) State

func NewUpdatePreCommitStatusReportRetryState

func NewUpdatePreCommitStatusReportRetryState(returnToState State, reportTries int) State

func NewUpdateRollbackRebootState

func NewUpdateRollbackRebootState(update *datastore.UpdateInfo) State

func NewUpdateStatusReportRetryState

func NewUpdateStatusReportRetryState(reportState State,
	update *datastore.UpdateInfo, status string, tries int) State

func NewUpdateStatusReportState

func NewUpdateStatusReportState(update *datastore.UpdateInfo, status string) State

func NewUpdateStoreState

func NewUpdateStoreState(in io.ReadCloser, update *datastore.UpdateInfo) State

func NewUpdateVerifyRebootState

func NewUpdateVerifyRebootState(update *datastore.UpdateInfo) State

func NewUpdateVerifyRollbackRebootState

func NewUpdateVerifyRollbackRebootState(update *datastore.UpdateInfo) State

type StateCollection

type StateCollection struct {
	CheckWait       *checkWaitState
	Final           *finalState
	Idle            *idleState
	Init            *initState
	InventoryUpdate *inventoryUpdateState
	UpdateCheck     *updateCheckState
}

type StateContext

type StateContext struct {
	// data store access
	Rebooter   installer.Rebooter
	Store      store.Store
	WakeupChan chan bool
	// contains filtered or unexported fields
}

StateContext carrying over data that may be used by all state handlers

type StateRunner

type StateRunner interface {
	// Set runner's state to 's'
	SetNextState(s State)
	// Obtain runner's state
	GetCurrentState() State
	// Run the currently set state with this context
	TransitionState(next State, ctx *StateContext) (State, bool)
}

type Transition

type Transition int
const (
	// no transition is happening
	ToNone Transition = iota
	// initial transition
	ToIdle
	ToSync
	ToError
	ToDownload_Enter
	ToDownload_Leave
	ToArtifactInstall
	// should have Enter and Error actions
	ToArtifactReboot_Enter
	// should have Leave action only
	ToArtifactReboot_Leave
	ToArtifactCommit_Enter
	ToArtifactCommit_Leave
	ToArtifactRollback
	// should have Enter and Error actions
	ToArtifactRollbackReboot_Enter
	// should have Leave action only
	ToArtifactRollbackReboot_Leave
	ToArtifactFailure
)

Transition in and out of state script states. Note in particular that update module specific states are not included here.

func (Transition) Enter

func (t Transition) Enter(
	exec statescript.Executor,
	report *client.StatusReportWrapper,
	store store.Store,
) error

Transition implements statescript.Launcher interface

func (Transition) Error

func (Transition) IsToError

func (t Transition) IsToError() bool

func (Transition) Leave

func (t Transition) Leave(
	exec statescript.Executor,
	report *client.StatusReportWrapper,
	store store.Store,
) error

func (Transition) String

func (t Transition) String() string

type UpdateControlMapWaitState

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

func NewUpdateControlMapWaitState

func NewUpdateControlMapWaitState(
	id datastore.MenderState,
	t Transition,
) *UpdateControlMapWaitState

func (*UpdateControlMapWaitState) Cancel

func (ws *UpdateControlMapWaitState) Cancel() bool

func (*UpdateControlMapWaitState) MultiplexWait

func (ws *UpdateControlMapWaitState) MultiplexWait(
	timerState, wakeupState State,
	wait time.Duration,
	wakeup chan bool) (State, bool)

MultiplexWait multiplexes the next state depending on the action which occurs first. If the timer expires, it goes to 'timerState', and if a 'wakeup' is received, it goes to the 'wakeupState'.

func (*UpdateControlMapWaitState) Wait

func (ws *UpdateControlMapWaitState) Wait(next, same State,
	wait time.Duration, wakeup chan bool) (State, bool)

Wait performs wait for time `wait` and return state (`next`, false) after the wait has completed. If wait was interrupted returns (`same`, true)

func (*UpdateControlMapWaitState) Wake

func (ws *UpdateControlMapWaitState) Wake() bool

type UpdateManager

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

func NewUpdateManager

func NewUpdateManager(
	controlMapPool *ControlMapPool,
	updateControlTimeoutSeconds int,
) *UpdateManager

func (*UpdateManager) EnableDBus

func (u *UpdateManager) EnableDBus(api dbus.DBusAPI)

func (*UpdateManager) Start

func (u *UpdateManager) Start() (context.CancelFunc, error)

type UpdateState

type UpdateState interface {
	State
	Update() *datastore.UpdateInfo
	// Signals whether this state is allowed to loop indefinitely. This is
	// used to track state transitions (see StateDataStoreCount in
	// datastore.go). States that can loop indefinitely are assumed to have
	// other means to break out of loops (such as server control), and are
	// not counted when updating the state count.
	PermitLooping() bool
}

func NewUpdateCommitState

func NewUpdateCommitState(update *datastore.UpdateInfo) UpdateState

func NewUpdateInstallState

func NewUpdateInstallState(update *datastore.UpdateInfo) UpdateState

func NewUpdateRebootPauseRequestedState

func NewUpdateRebootPauseRequestedState(update *datastore.UpdateInfo) UpdateState

This state solves a tricky issue. When checking Update Control Maps before the reboot state, we want a few things to happen: If a pause is requested, we want a spontaneous reboot to act as if the update resumed after a normal reboot. This requires that we store datastore.MenderStateReboot in the database, so that the recovery logic will work. However, we can not store this *before* checking the Update Control Maps, because the action may resolve to "fail", and then it would be very bad to resume the update. So the maps need to be checked, and then, *only if* there is a pause, we enter the state below to store the datastore.MenderStateReboot in the database. Then we go back to pausing.

func NewUpdateRebootState

func NewUpdateRebootState(update *datastore.UpdateInfo) UpdateState

type WaitState

type WaitState interface {
	Cancel() bool
	Wake() bool
	Wait(next, same State, wait time.Duration, wakeup chan bool) (State, bool)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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