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
- Variables
- func DoStandaloneCommit(device *dev.DeviceManager, stateExec statescript.Executor) error
- func DoStandaloneInstall(device *dev.DeviceManager, updateURI string, clientConfig client.Config, ...) error
- func DoStandaloneRollback(device *dev.DeviceManager, stateExec statescript.Executor) error
- func Min(a, b int) int
- func NewFatalError(err error) menderError
- func NewTransientError(err error) menderError
- func NewUpdateRollbackState(update *datastore.UpdateInfo) *updateRollbackState
- func NewUpdateState(id datastore.MenderState, t Transition, u *datastore.UpdateInfo) *updateState
- func NewWaitState(id datastore.MenderState, t Transition) *waitState
- func RemoveStateData(store store.Store) error
- func StateStatus(m datastore.MenderState) string
- type AuthManager
- type AuthManagerConfig
- type AuthManagerRequest
- type AuthManagerResponse
- type ControlMapPool
- func (c *ControlMapPool) ClearExpired()
- func (c *ControlMapPool) Delete(ID string, priority int)
- func (c *ControlMapPool) DeleteAllPriorities(ID string)
- func (c *ControlMapPool) Get(ID string) (active []*updatecontrolmap.UpdateControlMap, ...)
- func (c *ControlMapPool) HasControlMap(deploymentID string) bool
- func (c *ControlMapPool) Insert(cm *updatecontrolmap.UpdateControlMap)
- func (c *ControlMapPool) InsertReplaceAllPriorities(cm *updatecontrolmap.UpdateControlMap)
- func (c *ControlMapPool) NextAnyControlMapHalfTime(ID string) (time.Time, error)
- func (c *ControlMapPool) NextIDControlMapHalfTime(ID string) (time.Time, error)
- func (c *ControlMapPool) QueryAndUpdate(state string) (action string)
- func (c *ControlMapPool) SetStore(store store.Store)
- type Controller
- type DeploymentHook
- type DeploymentJSONFormatter
- type DeploymentLogManager
- type FileLogger
- type Mender
- func (m *Mender) Authorize() (client.AuthToken, client.ServerURL, error)
- func (m *Mender) CheckScriptsCompatibility() error
- func (m *Mender) CheckUpdate() (*datastore.UpdateInfo, menderError)
- func (m *Mender) ClearAuthorization()
- func (m *Mender) FetchUpdate(url string) (io.ReadCloser, int64, error)
- func (m *Mender) GetControlMapPool() *ControlMapPool
- func (m *Mender) GetCurrentState() State
- func (m *Mender) GetInventoryPollInterval() time.Duration
- func (m *Mender) GetRetryPollCount() int
- func (m *Mender) GetRetryPollInterval() time.Duration
- func (m *Mender) GetScriptExecutor() statescript.Executor
- func (m *Mender) GetUpdatePollInterval() time.Duration
- func (m *Mender) HandleBootstrapArtifact(s store.Store) error
- func (m *Mender) HandleControlMap(deploymentID string, updateControlMap *updatecontrolmap.UpdateControlMap) error
- func (m *Mender) InventoryRefresh() error
- func (m *Mender) NewStatusReportWrapper(updateId string, stateId datastore.MenderState) *client.StatusReportWrapper
- func (m *Mender) RefreshServerUpdateControlMap(deploymentID string) error
- func (m *Mender) ReportUpdateStatus(update *datastore.UpdateInfo, status string) menderError
- func (m *Mender) SetNextState(s State)
- func (m *Mender) TransitionState(to State, ctx *StateContext) (State, bool)
- func (m *Mender) UploadLog(update *datastore.UpdateInfo, logs []byte) menderError
- type MenderAuthManager
- func (m MenderAuthManager) Bootstrap() menderError
- func (m *MenderAuthManager) EnableDBus(api dbus.DBusAPI)
- func (m MenderAuthManager) ForceBootstrap()
- func (m MenderAuthManager) GenerateKey() error
- func (m *MenderAuthManager) GetBroadcastMessageChan(name string) <-chan AuthManagerResponse
- func (m *MenderAuthManager) GetInMessageChan() chan<- AuthManagerRequest
- func (m MenderAuthManager) HasKey() bool
- func (m MenderAuthManager) MakeAuthRequest() (*client.AuthRequest, error)
- func (m *MenderAuthManager) Start()
- func (m *MenderAuthManager) Stop()
- type MenderDaemon
- type MenderError
- type MenderPieces
- type State
- func NewCheckWaitState() State
- func NewControlMapPauseState(wrappedState UpdateState) State
- func NewControlMapState(wrapsState, pauseState UpdateState) State
- func NewErrorState(err menderError) State
- func NewFetchControlMapState(wrappedState, pauseState UpdateState) State
- func NewFetchRetryControlMapState(wrappedState, pauseState UpdateState) State
- func NewFetchStoreRetryState(from State, update *datastore.UpdateInfo, err error) State
- func NewInventoryUpdateRetryState(from State, err error) State
- func NewInventoryUpdateState() State
- func NewUpdateAfterCommitState(update *datastore.UpdateInfo) State
- func NewUpdateAfterFirstCommitState(update *datastore.UpdateInfo) State
- func NewUpdateAfterRebootState(update *datastore.UpdateInfo) State
- func NewUpdateAfterRollbackRebootState(update *datastore.UpdateInfo) State
- func NewUpdateAfterStoreState(update *datastore.UpdateInfo) State
- func NewUpdateCleanupState(update *datastore.UpdateInfo, status string) State
- func NewUpdateErrorState(err menderError, update *datastore.UpdateInfo) State
- func NewUpdateFetchState(update *datastore.UpdateInfo) State
- func NewUpdatePreCommitStatusReportRetryState(returnToState State, reportTries int) State
- func NewUpdateRollbackRebootState(update *datastore.UpdateInfo) State
- func NewUpdateStatusReportRetryState(reportState State, update *datastore.UpdateInfo, status string, tries int) State
- func NewUpdateStatusReportState(update *datastore.UpdateInfo, status string) State
- func NewUpdateStoreState(in io.ReadCloser, update *datastore.UpdateInfo) State
- func NewUpdateVerifyRebootState(update *datastore.UpdateInfo) State
- func NewUpdateVerifyRollbackRebootState(update *datastore.UpdateInfo) State
- type StateCollection
- type StateContext
- type StateRunner
- type Transition
- func (t Transition) Enter(exec statescript.Executor, report *client.StatusReportWrapper, ...) error
- func (t Transition) Error(exec statescript.Executor, report *client.StatusReportWrapper) error
- func (t Transition) IsToError() bool
- func (t Transition) Leave(exec statescript.Executor, report *client.StatusReportWrapper, ...) error
- func (t Transition) String() string
- type UpdateControlMapWaitState
- func (ws *UpdateControlMapWaitState) Cancel() bool
- func (ws *UpdateControlMapWaitState) MultiplexWait(timerState, wakeupState State, wait time.Duration, wakeup chan bool) (State, bool)
- func (ws *UpdateControlMapWaitState) Wait(next, same State, wait time.Duration, wakeup chan bool) (State, bool)
- func (ws *UpdateControlMapWaitState) Wake() bool
- type UpdateManager
- type UpdateState
- type WaitState
Constants ¶
const ( ActionFetchAuthToken = "FETCH_AUTH_TOKEN" ActionGetAuthToken = "GET_AUTH_TOKEN" )
Constants for auth manager request actions
const ( EventFetchAuthToken = "FETCH_AUTH_TOKEN" EventGetAuthToken = "GET_AUTH_TOKEN" EventAuthTokenStateChange = "AUTH_TOKEN_STATE_CHANGE" )
Constants for auth manager response events
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
const ( UpdateManagerDBusPath = "/io/mender/UpdateManager" UpdateManagerDBusObjectName = "io.mender.UpdateManager" UpdateManagerDBusInterfaceName = "io.mender.Update1" UpdateManagerDBusInterface = `` /* 259-byte string literal not displayed */ )
Variables ¶
var ( ErrLoggerNotInitialized = errors.New("logger not initialized") ErrNotEnoughSpaceForLogs = errors.New("not enough space for storing logs") )
error messages
var (
ErrorManualRebootRequired = errors.New("Manual reboot required")
)
var NoUpdateMapsErr = errors.New("No update control maps exist")
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 client.Config, 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 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 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 (c *ControlMapPool) Get( ID string, ) (active []*updatecontrolmap.UpdateControlMap, expired []*updatecontrolmap.UpdateControlMap)
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 (c *ControlMapPool) Insert(cm *updatecontrolmap.UpdateControlMap)
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) Levels ¶
func (dh DeploymentHook) Levels() []logrus.Level
type DeploymentJSONFormatter ¶
type DeploymentJSONFormatter struct { // TimestampFormat sets the format used for marshaling timestamps. TimestampFormat string }
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
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) CheckScriptsCompatibility ¶
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 (*Mender) GetControlMapPool ¶
func (m *Mender) GetControlMapPool() *ControlMapPool
func (*Mender) GetCurrentState ¶
func (*Mender) GetInventoryPollInterval ¶
func (*Mender) GetRetryPollCount ¶
func (*Mender) GetRetryPollInterval ¶
func (*Mender) GetScriptExecutor ¶
func (m *Mender) GetScriptExecutor() statescript.Executor
func (*Mender) GetUpdatePollInterval ¶
func (*Mender) HandleBootstrapArtifact ¶
func (*Mender) HandleControlMap ¶
func (m *Mender) HandleControlMap( deploymentID string, updateControlMap *updatecontrolmap.UpdateControlMap, ) error
func (*Mender) InventoryRefresh ¶
func (*Mender) NewStatusReportWrapper ¶
func (m *Mender) NewStatusReportWrapper(updateId string, stateId datastore.MenderState) *client.StatusReportWrapper
func (*Mender) RefreshServerUpdateControlMap ¶
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 (*Mender) TransitionState ¶
func (m *Mender) TransitionState(to State, ctx *StateContext) (State, bool)
type MenderAuthManager ¶
type MenderAuthManager struct {
// contains filtered or unexported fields
}
MenderAuthManager is the Mender authorization manager
func NewAuthManager ¶
func NewAuthManager(conf 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 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 NewUpdateRollbackRebootState ¶
func NewUpdateRollbackRebootState(update *datastore.UpdateInfo) 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 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 (t Transition) Error(exec statescript.Executor, report *client.StatusReportWrapper) 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) 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'.
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