Repository navigation
Implement changes defined in ADR034 and 035 - #393
NotTheEvilOne wants to merge 4 commits into
Conversation
82428ae to
0efc342
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #393 +/- ##
==========================================
+ Coverage 91.28% 91.67% +0.39%
==========================================
Files 49 51 +2
Lines 2971 3075 +104
==========================================
+ Hits 2712 2819 +107
+ Misses 259 256 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
62064c1 to
bfd41fc
Compare
d8d08bd to
3871196
Compare
|
📚 Documentation Preview PR: gardenlinux/docs#184 A PR has been created/updated to preview the documentation changes from this PR. |
Thanks for taking your time reviewing. Regarding As the alternative to the enviromment variables an command line argument |
Sounds fine for me to stay this way, then.
Ok, so to not pull in the builder as a dependency, these stay for now. Fine with me. |
ac711f0 to
9687c9a
Compare
|
Reviewers note: The |
9687c9a to
4ac5692
Compare
4ac5692 to
8529dc4
Compare
|
|
||
| cname, arch = value.rsplit("-", 1) | ||
| self["annotations"][ImageManifest.ANNOTATION_ARCH_KEY] = arch | ||
| self["annotations"][ImageManifest.ANNOTATION_CNAME_KEY] = cname |
There was a problem hiding this comment.
We probably can NOT change the content of this annotation. This annotation is load bearing for the gardenlinux-update tool1.
So while this change would correctly bring the annotation in line with cname as defined in ADR035, it would break compatibility with existing versions of the update tooling. While we can update the tooling and in the future read this annotation correctly or use a different annotation, we can not do that retroactively for existing released images.
The existing images will need to continue to be able to fetch updates of new versions from the OCI, so the check:
strings.HasPrefix(entry.Annotations.Cname, cname)will need to continue to return true => we MUST maintain the incorrect value in the cname field of the OCI manifest or we brake the ability of existing versions to update to future versions.
Footnotes
There was a problem hiding this comment.
This has been addressed in commit e3eeb2f. I used the prefix io.gardenlinux for the time being as wen used the same for our mime types as well. Changing the prefix would most likely need an ADR in https://github.com/gardenlinux/gardenlinux.
There was a problem hiding this comment.
Are these changes in the right place? as in is this the annotation that goes into the images index, or is this an annotation inside a single artifacts image manifest?
The update tooling matches against the index annotation, so I'd guess we actually need the new io.gardenlinux.cname and the legacy cname = {artifact_base} annotations somewhere here:
python-gardenlinux-lib/src/gardenlinux/oci/image_manifest.py
Lines 332 to 336 in e3eeb2f
There was a problem hiding this comment.
In fact the relevant lines are for extended_dict in
python-gardenlinux-lib/src/gardenlinux/oci/image_manifest.py
Lines 240 to 247 in e3eeb2f
But in fact you pointed out correctly that we should write out the artifact_base_name to our metadata files as well.
There was a problem hiding this comment.
my understanding is this here is what creates the combined OCI index:
and that directly uses the values written by
python-gardenlinux-lib/src/gardenlinux/oci/image_manifest.py
Lines 332 to 336 in e3eeb2f
so this IS the place the needs the new io.gardenlinux.cname = {cname} and the legacy support cname = {cname}-{arch}-{version}-{commit} in order to not break in-place updates since the update tool checks annotations on the index, NOT the per flavour manifest.
There was a problem hiding this comment.
It is not helpful to create a new hard-coded set of annotations at all here again. Fixing that right away.
Signed-off-by: Tobias Wolf <[email protected]> On-behalf-of: SAP <[email protected]>
Signed-off-by: Tobias Wolf <[email protected]> On-behalf-of: <[email protected]>
4d18acc to
e3eeb2f
Compare
|
|
||
| @staticmethod | ||
| def get_flavor_from_feature_set(sorted_features: List[str]) -> str: | ||
| def get_cname_from_feature_set(feature_set_list: List[str]) -> str: |
There was a problem hiding this comment.
such a function can never work correctly. there simply is no way to construct a real cname from just a set of features without access to the underlying graph. else one can't be sure that it is the minimal set, that things are sorted in the correct canonical order, etc.
There was a problem hiding this comment.
In the caller here:
python-gardenlinux-lib/src/gardenlinux/features/__main__.py
Lines 284 to 293 in e3eeb2f
both a cname and the graph is available, thus there either the input cname should just be kept or assuming the aim is to sanitize the input cname in case it's not actually the right order etc (akin to how the builders parse_features corrects cname order) then this sorting should never the less be done aware of the graph. so there something that uses sort_graph_nodes could be used instead.
the only other caller I could find is:
python-gardenlinux-lib/src/gardenlinux/flavors/parser.py
Lines 116 to 117 in e3eeb2f
which genuinely does not have a cname or graph available and only the flavors.yml. but given that it's not actually possible to construct a true cname.
maybe we should split this into 2 functions, one that uses sort_graph_nodes and actually constructs a true cname with guaranteed correct sorting based on the graph, and a create_pseudo_cname for getting a cname like object out of the flavors yml, that gets the platform as a dedicated input and all other features as a list an creates the cname-like strings that the builder will happily consume yet may not always be correct sorted cnames.
There was a problem hiding this comment.
[...]
the only other caller I could find is:
python-gardenlinux-lib/src/gardenlinux/flavors/parser.py
Lines 116 to 117 in e3eeb2f
which genuinely does not have a cname or graph available and only the
flavors.yml. but given that it's not actually possible to construct a true cname.[...]
In fact this is a very specific use case described above before:
The lexicographical topological sorting needs a feature graph to work. As CName generation from a feature set based on an cached
*.releaseshould work without afeaturesdirectory only part of the sorting can be implemented in the named methods. They are sort by platform (first element of the feature set), features and flags, each sorted alphabetically.
This "pseudo" canonical name is a prerequisite of the above to work. Usually canonical name generation is always based on a minimal feature set and contains therefore the correct information required to generate the name.
There was a problem hiding this comment.
when working from a .release file there is NO reason to re-construct the cname. the cname is in the file. with gardenlinux/builder#171 and gardenlinux/gardenlinux#5536 this has been adjusted to be the correct form.
| if not feature_set_list: | ||
| raise ValueError("At least one platform must be given as a feature") | ||
|
|
||
| platform = feature_set_list.pop(0) |
There was a problem hiding this comment.
where is the assumption that the platform would be the first (and only the first) element in the list?
There was a problem hiding this comment.
gardenlinux.features.Parser.sort_graph_nodes() adds, as a base for our lexicographical topological sorting, platform as the first item. Based on ADR 020 only one platform (including "frankenstein") should exist.
There was a problem hiding this comment.
frankenstein would not even be part of the features though. frankenstein is simply the placeholder value that should be used in place of a feature as the platform the actual features list of a frankenstein image simply contain multiple platforms.
Also arguing here that this works because the input will come from sort_graph_nodes conflicts with this function not being able to call sort_graph_nodes to also work for callers without graph access.
So I still think we should split this up into one function that does it correctly, via the graph when available (and therefore does not potentially resort features incorrectly), and one that is explicitly intended to create a cname like string given a platform and some features which is exactly what we have when parsing the flavors.yml but that makes it clear that it is not guaranteed to produce a correct cname and that it only constructs a cname like builder target, not a true cname.
Signed-off-by: Tobias Wolf <[email protected]> On-behalf-of: SAP <[email protected]>
e3eeb2f to
e314683
Compare
|
python-gardenlinux-lib/src/gardenlinux/oci/index.py Lines 98 to 114 in e314683 This logic has not been adjusted by this PR, yet making the cname annotation only the cname without the arch means that two different arch flavours of the same cname would collide and overwrite each other. Changing the annotation to the one we need for in-place update compat will circumvent this issue, but we probably should already switch the check to use |
Signed-off-by: Tobias Wolf <[email protected]> On-behalf-of: [email protected]
As we added |
What this PR does / why we need it:
This PR implements changes required to suit ADR034 and 035.
Main changes
Flavor,VersionedFlavorandArtifactBaseName ingardenlinux.features`.flavors.yamlparser ingardenlinux.flavors.Parsergardenlinux.featuresgl-features-parseand remove shortcut command line toolgl-cname.gardenlinux.oci.Containerclass was (and is still) derived fromoras.container.Containerbut the name is misleading from an OCI naming perspective. Therefore it has been renamed togardenlinux.oci.Registryand some methods andgl-ocicommand line parameters have been changed.Which issue(s) this PR fixes:
Fixes #376
Fixes #377
Requires #390
Related gardenlinux/gardenlinux#5533
Related gardenlinux/gardenlinux#5534