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: unable to close, unable to unref last: unable to cleanup component version, while unref last: closing component version #1243

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hilmarf
Copy link
Member

@hilmarf hilmarf commented Jan 10, 2025

What this PR does / why we need it

When calling ocm-cli with oci-tag-version like 0.0.1-20250108132333.build-af79499 e.g.

ocm get cv ocm-oci-test.int.repositories.cloud.sap//docker.io/recmo/docker-hello-tiny:0.0.1-20250108132333.build-af79499

It fails during the finalize step, when doing an update, where another round of version comparison happens.

Which issue(s) this PR fixes

Fixes: #1235

Related: #355

@hilmarf hilmarf requested a review from a team as a code owner January 10, 2025 15:20
@hilmarf hilmarf added this to the 2025-Q1 milestone Jan 10, 2025
@github-actions github-actions bot added the size/xs Extra small label Jan 10, 2025
@hilmarf hilmarf changed the title fixes: https://github.com/open-component-model/ocm/issues/1235 fixes(#1235): unable to close, unable to unref last: unable to cleanup component version, while unref last: closing component version Jan 10, 2025
@hilmarf hilmarf added the kind/bugfix Bug label Jan 10, 2025
@hilmarf hilmarf changed the title fixes(#1235): unable to close, unable to unref last: unable to cleanup component version, while unref last: closing component version fix(#1235): unable to close, unable to unref last: unable to cleanup component version, while unref last: closing component version Jan 10, 2025
@hilmarf hilmarf changed the title fix(#1235): unable to close, unable to unref last: unable to cleanup component version, while unref last: closing component version fix(1235): unable to close, unable to unref last: unable to cleanup component version, while unref last: closing component version Jan 10, 2025
@hilmarf hilmarf changed the title fix(1235): unable to close, unable to unref last: unable to cleanup component version, while unref last: closing component version fix: unable to close, unable to unref last: unable to cleanup component version, while unref last: closing component version Jan 10, 2025
@@ -128,6 +128,10 @@ func (c *componentAccessImpl) HasVersion(vers string) (bool, error) {
}

func (c *componentAccessImpl) LookupVersion(version string) (*repocpi.ComponentVersionAccessInfo, error) {
// LookupVersion '0.0.1-20250108132333.build-af79499' would fail with:
// unable to unref last: unable to cleanup component version [%v] while unref last: closing component version [%v]: check failed: component version [%v] is invalid
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the actual error contain [%v] instead of the version? Just curious. :D

Copy link
Member Author

Choose a reason for hiding this comment

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

no - the actual error is:

closing session: unable to close: closing docker.io/recmo/docker-hello-tiny:0.0.1-20250108132333.build-af79499: unable to unref last: unable to cleanup component version docker.io/recmo/docker-hello-tiny/0.0.1-20250108132333.build-af79499 while unref last: closing component version docker.io/recmo/docker-hello-tiny:0.0.1-20250108132333.build-af79499: check failed: component version "0.0.1-20250108132333+af79499" is invalid

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem is, that a version with this .build- is not a valid version anymore for CVs. So, the error is basically correct, but it comes far too late.

It must be assured that the version name given at the API matches the version name stored in the component descriptor, otherwise the complete structure would be corrupted.

So, such a version should be rejected at all. Accepting two versions, the CV version and a technical versions used at the backend, as valid CV versions would be problematic. But there is no reason why to accept the technical version, also. (The ListVersions call correctly maps the technical versions found as OCI tag back to OCM versions).

So, there should be an error if the technical version is given, and it should be reported early.
May be you could add the following check to LookupVersion in api/ocm/cpi/repocpi/bridge_c.go Line 102

func (b *componentAccessBridge) LookupVersion(version string) (cpi.ComponentVersionAccess, error) {
	i, err := b.impl.LookupVersion(version)
	if err != nil {
		return nil, err
	}
	if i == nil || i.Impl == nil {
		return nil, errors.ErrInvalid("component implementation behaviour", "LookupVersion")
	}
	if i.Impl.GetDescriptor().Version != version {
		i.Impl.Close()
		return nil, errors.ErrInvalid("component version mismatch")
	}
	return NewComponentVersionAccess(b.GetName(), version, i.Impl, i.Lazy, i.Persistent, !compositionmodeattr.Get(b.GetContext()))
}

Skarlso
Skarlso previously approved these changes Jan 11, 2025
Copy link
Contributor

@mandelsoft mandelsoft left a comment

Choose a reason for hiding this comment

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

The technical version used at the backend should not be usable as OCM version (see my comment above). I would strongly recommend to provide an error instead of introducing this ambiguity.

@hilmarf hilmarf added the dev/second-opinion PR or issue needs a second opinion, is open for discussion label Jan 13, 2025
which has been replaced by META_SEPARATOR to create OCI compliant tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev/second-opinion PR or issue needs a second opinion, is open for discussion kind/bugfix Bug size/xs Extra small
Projects
Status: 🏗 In Progress
Development

Successfully merging this pull request may close these issues.

Bug: + in component version is replaced by .build-
3 participants