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.
Index ¶
- Constants
- Variables
- func CommitArtifactData(txn store.Transaction, artifactName, artifactGroup string, ...) error
- func LoadProvides(dbStore store.Store) (map[string]string, error)
- func StoreStateData(dbStore store.Store, sd StateData, incStoreCount bool) error
- func StoreStateDataAndTransaction(dbStore store.Store, sd StateData, incStoreCount bool, ...) error
- type Artifact
- type MenderState
- type RebootRequestedType
- type RebootType
- type StandaloneStateData
- type StateData
- type SupportsRollbackType
- type UpdateInfo
- func (ur *UpdateInfo) ArtifactClearsProvides() []string
- func (ur *UpdateInfo) ArtifactGroup() string
- func (ur *UpdateInfo) ArtifactName() string
- func (ur *UpdateInfo) ArtifactTypeInfoProvides() map[string]string
- func (ur *UpdateInfo) CompatibleDevices() []string
- func (ur *UpdateInfo) URI() string
- func (ur *UpdateInfo) Validate() error
Constants ¶
View Source
const ( // Name of artifact currently installed. Introduced in Mender 2.0.0. ArtifactNameKey = "artifact-name" // Name of the group the currently installed artifact belongs to. For // artifact version >= 3, this is held in the header-info artifact- // provides field ArtifactGroupKey = "artifact-group" // Holds the current artifact provides from the type-info header of // artifact version >= 3. // NOTE: These provides are held in a separate key due to the header- // info provides overlap with previous versions of mender artifact. ArtifactTypeInfoProvidesKey = "artifact-provides" // The key used by the standalone installer to track artifacts that have // been started, but not committed. We don't want to use the // StateDataKey for this, because it contains a lot less information. StandaloneStateKey = "standalone-state" // Name of key that state data is stored under across reboots. Uses the // StateData structure, marshalled to JSON. StateDataKey = "state" // Added together with update modules in v2.0.0. This key is invoked if, // and only if, a client loads data using the StateDataKey, and // discovers that it is a different version than what it currently // supports. In that case it switches to using the // StateDataKeyUncommitted until the commit stage, where it switches // back to StateDataKey. This is intended to ensure that upgrading the // client to a new database schema doesn't overwrite the existing // schema, in case it is rolled back and the old client needs the // original schema again. StateDataKeyUncommitted = "state-uncommitted" // Added in Mender v2.7.0. Updated every time a control map is updated // in memory. UpdateControlMaps = "update-control-maps" // Key used to store the auth token. AuthTokenName = "authtoken" AuthTokenCacheInvalidatorName = "auth-token-cache-invalidator" )
View Source
const ( RollbackSupportUnknown = "" RollbackNotSupported = "rollback-not-supported" RollbackSupported = "rollback-supported" )
View Source
const ( RebootTypeNone = "" RebootTypeCustom = "reboot-type-custom" RebootTypeAutomatic = "reboot-type-automatic" )
View Source
const ( // This number should be kept quite a lot higher than the number of // expected state storage operations, which is usually roughly // equivalent to the number of state transitions. MaximumStateDataStoreCount = 30 )
View Source
const StandaloneStateDataVersion = 1
View Source
const StateDataVersion = 2
current version of the format of StateData; increase the version number once the format of StateData is changed StateDataVersion = 2 was introduced in Mender 2.0.0.
Variables ¶
View Source
var ( // Special kind of error: When this error is returned by LoadStateData, // the StateData will also be valid, and can be used to handle the error. MaximumStateDataStoreCountExceeded error = errors.New( "State data stored and retrieved maximum number of times") )
Functions ¶
func CommitArtifactData ¶
func LoadProvides ¶
Loads artifact-provides (including artifact name) needed for dependency checking before proceeding with installation of an artifact (version >= 3).
func StoreStateData ¶
func StoreStateDataAndTransaction ¶
func StoreStateDataAndTransaction(dbStore store.Store, sd StateData, incStoreCount bool, txnFunc func(txn store.Transaction) error) error
Execute storing the state and a custom transaction function atomically.
Types ¶
type Artifact ¶
type Artifact struct { Source struct { URI string Expire string } // Compatible devices for dependency checking. CompatibleDevices []string `json:"device_types_compatible"` // What kind of payloads are embedded in the artifact // (e.g. rootfs-image). PayloadTypes []string // The following two properties implements ArtifactProvides header-info // field of artifact version >= 3. The Attributes are moved to the root // of the Artifact structure for backwards compatibility. ArtifactName string `json:"artifact_name"` ArtifactGroup string `json:"artifact_group"` // Holds optional provides fields in the type-info header TypeInfoProvides map[string]string `json:"artifact_provides,omitempty"` // Holds options clears_artifact_provides fields from the type-info header. // Added in Mender client 2.5. ClearsArtifactProvides []string `json:"clears_artifact_provides,omitempty"` }
type MenderState ¶
type MenderState int
const ( // initial state MenderStateInit MenderState = iota // idle state; waiting for transition to the new state MenderStateIdle // --- NOT USED ANYMORE // client is bootstrapped, i.e. ready to go MenderStateAuthorize // wait before authorization attempt MenderStateAuthorizeWait // inventory update MenderStateInventoryUpdate // wait before retrying update inventory MenderStateInventoryUpdateRetryWait // wait for new update or inventory sending MenderStateCheckWait // check update MenderStateUpdateCheck // update fetch MenderStateUpdateFetch // update store MenderStateUpdateStore // after update store (Download_Leave) MenderStateUpdateAfterStore // install update MenderStateUpdateInstall // wait before retrying fetch & install after first failing (timeout, // for example) MenderStateFetchStoreRetryWait // verify update MenderStateUpdateVerify // Retry sending status report before committing MenderStateUpdatePreCommitStatusReportRetry // commit needed MenderStateUpdateCommit // first commit is finished MenderStateUpdateAfterFirstCommit // all commits are finished MenderStateUpdateAfterCommit // status report MenderStateUpdateStatusReport // wait before retrying sending either report or deployment logs MenderStateStatusReportRetry // reboot MenderStateReboot // first state after booting device after rollback reboot MenderStateVerifyReboot // state which runs the ArtifactReboot_Leave scripts MenderStateAfterReboot // rollback MenderStateRollback // reboot after rollback MenderStateRollbackReboot // first state after booting device after rollback reboot MenderStateVerifyRollbackReboot // state which runs ArtifactRollbackReboot_Leave scripts MenderStateAfterRollbackReboot // error MenderStateError // update error MenderStateUpdateError // cleanup state MenderStateUpdateCleanup // exit state MenderStateDone // Update control main state MenderStateUpdateControl // pause if a control map demands it MenderStateUpdateControlPause // update the control maps from the server during a deployment MenderStateFetchUpdateControl // retry the above state upon request errors MenderStateFetchRetryUpdateControl // No longer used MenderStateReportStatusError )
func (MenderState) MarshalJSON ¶
func (m MenderState) MarshalJSON() ([]byte, error)
func (MenderState) String ¶
func (m MenderState) String() string
func (*MenderState) UnmarshalJSON ¶
func (m *MenderState) UnmarshalJSON(data []byte) error
type RebootRequestedType ¶
type RebootRequestedType []RebootType
func (*RebootRequestedType) Get ¶
func (r *RebootRequestedType) Get(n int) (RebootType, error)
func (*RebootRequestedType) Set ¶
func (r *RebootRequestedType) Set(n int, t RebootType) error
type RebootType ¶
type RebootType string
type StandaloneStateData ¶
type StateData ¶
type StateData struct { // version is providing information about the format of the data Version int // number representing the id of the last state to execute Name MenderState // update info and response data for the update that was in progress UpdateInfo UpdateInfo }
StateData is state information that can be used for restoring state from storage
type SupportsRollbackType ¶
type SupportsRollbackType string
func (*SupportsRollbackType) Set ¶
func (s *SupportsRollbackType) Set(value SupportsRollbackType) error
type UpdateInfo ¶
type UpdateInfo struct { Artifact Artifact ID string // Whether the currently running payloads asked for reboots. It is // indexed the same as PayloadTypes above. RebootRequested RebootRequestedType // Whether the currently running update supports rollback. All payloads // must either support rollback or not, so this is one global flag for // all of them. SupportsRollback SupportsRollbackType // How many times this update's state has been stored. This is roughly, // but not exactly, equivalent to the number of state transitions, and // is used to break out of loops. StateDataStoreCount int // Whether the current update includes a DB schema update (this // structure, and the StateData structure). This is set if we load state // data and discover that it is a different version. See also the // StateDataKeyUncommitted key. HasDBSchemaUpdate bool }
Info about the update in progress.
func (*UpdateInfo) ArtifactClearsProvides ¶
func (ur *UpdateInfo) ArtifactClearsProvides() []string
func (*UpdateInfo) ArtifactGroup ¶
func (ur *UpdateInfo) ArtifactGroup() string
func (*UpdateInfo) ArtifactName ¶
func (ur *UpdateInfo) ArtifactName() string
func (*UpdateInfo) ArtifactTypeInfoProvides ¶
func (ur *UpdateInfo) ArtifactTypeInfoProvides() map[string]string
func (*UpdateInfo) CompatibleDevices ¶
func (ur *UpdateInfo) CompatibleDevices() []string
func (*UpdateInfo) URI ¶
func (ur *UpdateInfo) URI() string
func (*UpdateInfo) Validate ¶
func (ur *UpdateInfo) Validate() error
Click to show internal directories.
Click to hide internal directories.