59 Commits

Author SHA1 Message Date
Alfonso Sánchez-Beato
b1f86bedfd asserts: add support for components in model assertion 2024-03-22 19:06:32 +00:00
Alfonso Sánchez-Beato
c32f6b7d90 asserts: refactor so checkModelSnap fills all ModelSnap fields
instead doing it only partially and filling part of them in other
method that should not have a saying on this.
2024-03-22 19:06:32 +00:00
Andrew Phelps
0238dca2a7 asserts: add Model.AllSnaps method (#13456)
* asserts: add Model.AllSnaps method

* o/devicestate: use model.AllSnaps rather than concatenating essential and non-essential snaps

* asserts: update Model.AllSnaps doc comment to be more clear

* asserts: update Model.AllSnaps test to assert that test is actually useful
2024-01-11 13:03:02 +02:00
Andrew Phelps
154d46b46c many: take into account validation sets during remodel (#13243)
This PR makes remodels take into account revision constraints from validation sets on the new model. Additionally, snaps that are marked as invalid in validation sets are checked for in the model.

* a/snapasserts: add methods for extracting more information out of ValidationSets type

* o/assertstate: add ValidationSetsFromModel function for extracting a snapasserts.ValidationSets from an asserts.Model

* o/snapstate: prevent installing/updating a snap from a local file that does not match requested revision

* o/devicestate: consider validation sets during remodeling

* tests/nested/manual: add remodel test that downgrades a snap because of a validation set

* tests/nested/manual: add remodel test that fails to remodel because of an invalid snap in a validation set

* tests/nested/manual: extend offline remodel test to also include a validation set

* tests/lib/assertions: fix timestamps on assertions

* asserts: add Key method to ValidationSet and ModelValidationSet

* o/devicestate: use new Key methods

* o/devicestate: maybe enforce validation sets during doSetModel

* o/devicestate: add test for enforcing validation sets in doSetModel

* a/snapasserts: simplify TestCanBePresent with loop

* tests/lib/assertions: add bluez snap to offline remodel test

* o/devicestate: remove done TODO

* o/snapstate: if remodeling, do not install prereq if link-snap task is present

* tests/nested/manual/remodel-offline: extend test to verify that validation sets are accounted for

* Revert "o/snapstate: if remodeling, do not install prereq if link-snap task is present"

This reverts commit 57c7725a2513df51be7ac1c06c492aaed07a6e3b.

This change is independent and will be included in another PR.

* a/snapasserts: add methods for extracting more information out of ValidationSets type

* o/assertstate: add ValidationSetsFromModel function for extracting a snapasserts.ValidationSets from an asserts.Model

* o/devicestate: add test for ValidationSetsConflictError.Is

* a/snapasserts: move methods after New function

* a/snapasserts: add test for ValidationSets.Revisions to verify ValidationSetsConflictError is returned

* o/assertstate: change ValidationSetsFromModel to take in a DeviceContext, rather than a StoreService

* o/assertstate: rename ValidationSetsModelFlags to ValidationSetsModelOptions

* o/devicestate: add type to export_test to make testing simpler

* tests: add details to new spread tests

* asserts: rename ModelValidationSet.Key and ValidationSet.Key to .SequenceName and add unit tests for them

* o/snapstate: update snap revision mismatch error message to be more clear

* o/devicestate: introduce helper for setting ValidationSets on snapstate.RevisionOptions if Revision is set

* o/devicestate: verify the parameters that fakeSequenceStore receives

* o/devicestate: fix revisions not being respected for essential snaps (and add a test for it)

* o/devicestate: extend TestRemodelUC20EssentialSnapsAlreadyInstalledAndLocal to also exercise case where a validation set requires a revision but the currently installed version is unasserted

* s/seedtest: update retrieveSeq to handle unconstrained sequence forming assertions

* a/snapasserts: add ValidationSets.Sets method

* o/assertstate: add deviceContext to ForgetValidationSet function so that change can happen during remodel

* o/devicestate: attempt to handle rollback of validation sets during failed remodel

* overlord: test for replacing conflicting validation sets during remodel

* o/assertstate: update ForgetValidationSet to take in a DeviceContext and to allow for forcing removal even if the validation set is in use by the model

* o/devicestate: roll back validation set changes on remodel failure

* o/devicestate: make sure that validation sets unrelated to the model survive a remodel

* o/devicestate: rename param in installedSnapRevisionChanged

* o/devicestate: rename field newSnapRevision to newRequiredRevision in modelSnapsForRemodel

* o/devicestate: simplify loops in checkForInvalidSnapsInModel

* o/devicestate: compare validation sets using SequenceName methods

* o/devicestate: fail remodel if we attempt to use an unasserted snap as a specific revision

* tests/nested/manual/remodel-offline: fix test to actually use validation set

* o/devicestate: create helper for creating snapstate.RevisionOptions during remodel

* o/devicestate: name param literals for clarity

* o/devicestate: invert logic to eliminate double negative

* o/devicestate: fix missed inversion of logic

* o/assertstate: update comment on ForgetValidationSetOpts.ForceForget

* overlord, o/devicestate: update remodel test to change models that contain the same validation set

* o/assertstate: test ForceForget functionality in ForgetValidationSet

* o/devicestate: rename function newRevisionOptionsForRemodel to revisionOptionsForRemodel

* o/assertstate, o/devicestate, daemon: remove unneeded DeviceContext param from ForgetValidationSet

* o/devicestate: remove println

* o/devicestate: clarify comment in rollback of adding validation sets

* o/devicestate: rename variable in enforceValidationSetsForRemodel

* o/snapstate: clarify error when attempting to install/refresh local snap with different revision than requested

* o/devicestate: naming consistency

* o/devicestate: simplify error when model is missing snap that is required in validation set

* asserts, overlord, o/devicestate: rename SequenceName to SequenceKey and prefix the series to the string that is returned
2023-12-12 10:00:48 +01:00
J. Brock
7c17cf2669 asserts,seed: preseed authority delegation (#13034)
* asserts/model: add preseedAuthority field to Model

* seed20: allow authority-id to differ from the brand-id

* fixup! asserts/model: add preseedAuthority field to Model

fix comment wording to PreseedAuthority

* fixup! seed20: allow authority-id to differ from the brand-id

clarify error message as "preseed authority-id"

* fixup! asserts/model: add preseedAuthority field to Model

standardize checkOptionalAuthority() signature and make acceptsAny bool explicit when invoking it

* fixup! seed20: allow authority-id to differ from the brand-id

fix ineffectual assignment to preseedAs2

* fixup! asserts/model: add preseedAuthority field to Model

bump copyright years for files touched by 5593e76312

* fixup! seed20: allow authority-id to differ from the brand-id

bump copyright years for files touched by ce7ba34e0f

* fixup! asserts/model: add preseedAuthority field to Model

asserts/model.go: rename "acceptsAny" to "acceptsWildcard"
2023-09-04 10:22:43 +02:00
Philip Meulengracht
c715c2fd85 asserts,seed/seedwriter: support for validation sets in seedwriter (#12571)
* asserts,seed/seedwriter: support for validation sets when writing the image seed.

* seed/seedwriter: simplify writer code

* seed/seedwriter: updatethe docs for Start

* asserts,seed/seedwriter: review feedback

Add unit tests for AtSequence, ensure CheckValidationSets cannot be called unless download step has completed

* seed/seedwriter: review feedback

add unit test for CheckValidationSets to early call, reuse checkStepCompleted in checkSnapsAccessor
2023-04-04 09:55:44 +02:00
Philip Meulengracht
d1f1074adf asserts: review feedback
add Optional to the sequence check, change error for wrongly formatted validation-set entry
2023-03-10 07:22:44 +01:00
Philip Meulengracht
6c167b9ab6 asserts: review feedback
clarify error description if specifying an invalid sequence
2023-03-10 07:22:44 +01:00
Philip Meulengracht
9a006ce79d asserts: review feedback
dont allow 0 in sequence, remove checkDefaultIntWhat as its not needed anymore, add unit test for the 0 case
2023-03-10 07:22:44 +01:00
Philip Meulengracht
77c9bfb609 asserts: review feedback
improve error messages, add missing unit test cases for these errors
2023-03-10 07:22:43 +01:00
Philip Meulengracht
080f154631 asserts: review feedback
use 'what' methods instead to provide error context when data members are invalid, change certain error messages to align with the rest, and introduce a What variant of checkIntWithDefault
2023-03-10 07:22:43 +01:00
Philip Meulengracht
b3f15803d1 asserts: remove monitor as a mode 2023-03-10 07:22:43 +01:00
Philip Meulengracht
1f903f7524 asserts: default to brand ID when account ID is not set 2023-03-10 07:22:42 +01:00
Philip Meulengracht
b18a7aab80 asserts: support validation-sets in model assertion 2023-03-10 07:22:42 +01:00
Miguel Pires
d097436c1c many: fix formatting w/ gofmt 1.19
Go 1.19 includes some changes to gofmt which intend to make lists and
heading clearer when rendered (https://go.dev/doc/go1.19). This commit
is the result of running the new gofmt and manually fixing some of it.
This was necessary because the new gofmt assumed lines beginning w/ tabs
to start lists or examples. While this is often true in our codebase,
we occasionally also use tabs to indent the lines after a TODO or FIXME
prefix or in yaml (e.g., excerpts of a snap.yaml). This meant that a lot of the
reformatted comments were broken and had to be fixed manually.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-16 14:23:11 +01:00
Samuele Pedroni
fcd9668e0c asserts,o/devicestate: fix typos and clarify naming
thanks @Meulengracht and @mardy
2022-10-07 18:40:58 +02:00
Samuele Pedroni
58bb6b4f21 many: support explicitly allowing classic snaps in extended models 2022-10-06 18:05:00 +02:00
Samuele Pedroni
9280bdc7d4 many: cleanups
thanks @alfonsosanchezbeato
2022-09-30 18:20:32 +02:00
Samuele Pedroni
54d5fa832c many: support extended classic models that omit kernel/gadget
redefine IsCoreBoot as the model having a kernel

there are at least tests that show we can seed such systems

the changes ind devicemgr.go prompted fixes for some remodel tests that were
confusingly running wiht OnClassic true though they were using Core models
2022-09-29 18:34:10 +02:00
Samuele Pedroni
285eb30391 asserts,boot,secboot: switch to a secboot version measuring classic
to have the information available when we seal capture classic in
modeenv and bootchains as we do for other mode characteristics

as for now we assume we don't want so support classic/core remodels

some things need to be tested but it's best if the tests are added
when we are actually looking at the full picture of installing classic
systems with modes
2022-09-05 15:23:28 +02:00
Alfonso Sánchez-Beato
4a1f4c93fc asserts: add distribution field to model, for extended classic model
Allow extended classic models and require for them a distribution field.
2022-07-14 16:29:00 +01:00
Michael Vogt
439f267378 many: replace use of "sanity" for interface implementation checks
This commit replaces the use of "sanity" with more inclusive
naming. When `// sanity` is used to check if an interface is
implemented the comment `expected interface is implemented`
is used.
2022-03-14 17:35:33 +01:00
Michael Vogt
b6dcc7e048 asserts: tweak error/code layout in assembleModel around storageSafety checks 2020-11-17 12:59:01 +01:00
Michael Vogt
9efbec05da asserts: set defaults on uc20 for storage-safety (if unset) 2020-11-16 18:21:56 +01:00
Michael Vogt
c00944e7de asserts: tweak error for uc16/uc18 storage-safety headers 2020-11-16 18:14:53 +01:00