Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(revert): reverts "fix implicit version handling of an artifact identity (#1026)" #1217

Conversation

jakobmoellerdev
Copy link
Contributor

@jakobmoellerdev jakobmoellerdev commented Dec 30, 2024

This reverts commit 782970c.

What this PR does / why we need it

We have multiple regressions that were introduced with this change that did not get noticed properly.

considering that a simple ocm get cv used to return:

ocm0.18.0 get resources --lookup OCIRegistry::europe-docker.pkg.dev/sap-se-gcp-k8s-delivery/releases-staging-private   github.com/gardener/gardener:v1.110.1 nginx-ingress-controller
NAME                     VERSION IDENTITY            TYPE     RELATION
nginx-ingress-controller v1.9.6                      ociImage external
nginx-ingress-controller v1.11.3 "version"="v1.11.3" ociImage external

and now returns

ocm get resources --lookup OCIRegistry::europe-docker.pkg.dev/sap-se-gcp-k8s-delivery/releases-staging-private   github.com/gardener/gardener:v1.110.1 nginx-ingress-controller
NAME                     VERSION IDENTITY            TYPE     RELATION
nginx-ingress-controller v1.11.3 "version"="v1.11.3" ociImage external
nginx-ingress-controller v1.9.6  "version"="v1.9.6"  ociImage external

even though the repository is unchanged is already problematic because the defaulting logic now applies not only with a transfer but also if it is not persisted in the repository. this causes side effects because now the signatures will change even through normalization because the new default behavior is differing.

There is also a bug in #1214 that describes an issue where after this change the signing hash calculation changes (because the defaulting also affects the component descriptor parsing involuntarily) which is unacceptable, because existing component version hashes are not allowed to change. This needs to be tested with a follow up PR.

There is furthermore an issue in the debuggability of the commandline and this change as it is impossible to have been tested with a case where extraidentity was set for one version but not for the other. before this PR is reintroduced this should be addressed.

Which issue(s) this PR fixes

Fixes #1214

@jakobmoellerdev jakobmoellerdev requested a review from a team as a code owner December 30, 2024 17:33
@github-actions github-actions bot added kind/bugfix Bug area/documentation Documentation related component/ocm-cli OCM Command Line Interface size/l Large and removed area/documentation Documentation related component/ocm-cli OCM Command Line Interface labels Dec 30, 2024
Copy link
Contributor

@frewilhelm frewilhelm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you ran make to check for any generated docs. It looks good to me. The only comments made are nit

Comment on lines 11 to 12
// Replace enables to replace existing elements (same raw identity) with a different version instead
// of appending a new element.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment could stay, i guess

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I touch the original revert to accomodate this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the comment sounds valid and independent from the changes. However, I would add the comment on an additional commit (not rebased or --amend)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be squashed either way so that is a bit moot. I can add it into the final PR on merge.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i forgot about the squash :O

I thought it would be beneficial to have the revert as separate commit in case we need the changes in the future. However, this option is probably not valid and, thus, irrelevant.

@@ -33,7 +33,7 @@ func (o *Option) AddFlags(fs *pflag.FlagSet) {
fs.BoolVarP(&o.Actual, "actual", "", false, "use actual component descriptor")
fs.BoolVarP(&o.Update, "update", "U", false, "update digests in component version")
fs.BoolVarP(&o.Verify, "verify", "V", false, "verify digests found in component version")
fs.StringVarP(&o.outfile, "outfile", "O", "-", "Output file for normalized component descriptor")
fs.StringVarP(&o.outfile, "outfile", "O", "norm.ncd", "Output file for normalized component descriptor")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know what the reason for the change to - was?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was because the output file was written by default. I can patch this back in if you want

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably also a reasonable change that should stay and is independent from the revert.

@frewilhelm
Copy link
Contributor

There is furthermore an issue in the debuggability of the commandline and this change as it is impossible to have been tested with a case where extraidentity was set for one version but not for the other. before this PR is reintroduced this should be addressed.

Do we have an issue for that?

@frewilhelm
Copy link
Contributor

Does this PR close #1214?

@jakobmoellerdev
Copy link
Contributor Author

yes, and this is a revert specifically to target 1214 and other side effects discovered during debugging (described in the PR title)

@jakobmoellerdev
Copy link
Contributor Author

I assume you ran make to check for any generated docs. It looks good to me. The only comments made are nit

Yes otherwise the diff checker would fail

@github-actions github-actions bot added area/documentation Documentation related component/ocm-cli OCM Command Line Interface labels Jan 3, 2025
@frewilhelm
Copy link
Contributor

yes, and this is a revert specifically to target 1214 and other side effects discovered during debugging (described in the PR title)

I edited the PR description to link the issue

@jakobmoellerdev
Copy link
Contributor Author

superceded by a better normalization algorithm

jakobmoellerdev added a commit that referenced this pull request Jan 8, 2025
…ion/v1 as well as jsonNormalisation/v2 (#1218)

<!-- markdownlint-disable MD041 -->
#### What this PR does / why we need it

Package jsonv3 provides a normalization which is completely based on the
abstract (internal) version of the component descriptor and is therefore
agnostic of the final serialization format. Signatures using this
algorithm can be transferred among different schema versions, as long as
is able to handle the complete information using for the normalization.
jsonv2 is the predecessor of this version but had internal defaulting
logic that is no longer included as part of this normalization. Thus v3
should be preferred over v2. Note that between v2 and v3 differences can
occur mainly if the "extra identity" field is not unique, in which case
the v2 normalization opinionated on how to differentiate these items.
This no longer happens in v3, meaning the component descriptor is
normalized as is.

v2 and v1 were adjusted to accomodate the old(but new because forgotten)
legacy behavior in legacy.go. Without this, old signatures would not
work. This means this should be (at least partially) back-ported to the
last minor versioned released without this correction.

#### Which issue(s) this PR fixes
<!--
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
This issue fixes #1214
and supercedes #1217 as
a better solution longterm (by getting rid of the old normalization) and
shortterm (by achieving full backwards compatibility + introducing a
simple test case)

Note that this changes the default normalization algorithm to be
`jsonNormalisation/v3` instead of `jsonNormalisation/v1` as it is
important for users to migrate as soon as possible.
jakobmoellerdev added a commit to jakobmoellerdev/ocm that referenced this pull request Jan 8, 2025
…ion/v1 as well as jsonNormalisation/v2 (open-component-model#1218)

<!-- markdownlint-disable MD041 -->
#### What this PR does / why we need it

Package jsonv3 provides a normalization which is completely based on the
abstract (internal) version of the component descriptor and is therefore
agnostic of the final serialization format. Signatures using this
algorithm can be transferred among different schema versions, as long as
is able to handle the complete information using for the normalization.
jsonv2 is the predecessor of this version but had internal defaulting
logic that is no longer included as part of this normalization. Thus v3
should be preferred over v2. Note that between v2 and v3 differences can
occur mainly if the "extra identity" field is not unique, in which case
the v2 normalization opinionated on how to differentiate these items.
This no longer happens in v3, meaning the component descriptor is
normalized as is.

v2 and v1 were adjusted to accomodate the old(but new because forgotten)
legacy behavior in legacy.go. Without this, old signatures would not
work. This means this should be (at least partially) back-ported to the
last minor versioned released without this correction.

#### Which issue(s) this PR fixes
<!--
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
This issue fixes open-component-model#1214
and supercedes open-component-model#1217 as
a better solution longterm (by getting rid of the old normalization) and
shortterm (by achieving full backwards compatibility + introducing a
simple test case)

Note that this changes the default normalization algorithm to be
`jsonNormalisation/v3` instead of `jsonNormalisation/v1` as it is
important for users to migrate as soon as possible.
ikhandamirov pushed a commit that referenced this pull request Jan 8, 2025
…ion/v1 as well as jsonNormalisation/v2 (#1218) (#1230)

Note that this introduces a json normalization algorithm v3 which
technically will break a minor release. however this is needed as we
currently broke hashing and need to offer a working alternative. thus it
should have been part of v0.19.0 already:
#1214

<!-- markdownlint-disable MD041 -->
#### What this PR does / why we need it

Package jsonv3 provides a normalization which is completely based on the
abstract (internal) version of the component descriptor and is therefore
agnostic of the final serialization format. Signatures using this
algorithm can be transferred among different schema versions, as long as
is able to handle the complete information using for the normalization.
jsonv2 is the predecessor of this version but had internal defaulting
logic that is no longer included as part of this normalization. Thus v3
should be preferred over v2. Note that between v2 and v3 differences can
occur mainly if the "extra identity" field is not unique, in which case
the v2 normalization opinionated on how to differentiate these items.
This no longer happens in v3, meaning the component descriptor is
normalized as is.

v2 and v1 were adjusted to accomodate the old(but new because forgotten)
legacy behavior in legacy.go. Without this, old signatures would not
work. This means this should be (at least partially) back-ported to the
last minor versioned released without this correction.

#### Which issue(s) this PR fixes
<!--
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. -->
This issue fixes #1214
and supercedes #1217 as
a better solution longterm (by getting rid of the old normalization) and
shortterm (by achieving full backwards compatibility + introducing a
simple test case)

Note that this changes the default normalization algorithm to be
`jsonNormalisation/v3` instead of `jsonNormalisation/v1` as it is
important for users to migrate as soon as possible.

This is a backport of
a93ecca
in #1218
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Documentation related component/ocm-cli OCM Command Line Interface kind/bugfix Bug size/l Large
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incompatible change of OCM-Component-Descriptor-Normalisation between OCM-CLI v0.18.0 vs v0.19.0
2 participants