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

Component version issue with OCM #1172

Open
arjunroy-89 opened this issue Dec 5, 2024 · 11 comments
Open

Component version issue with OCM #1172

arjunroy-89 opened this issue Dec 5, 2024 · 11 comments
Assignees
Labels
area/ipcei Important Project of Common European Interest kind/feature new feature, enhancement, improvement, extension

Comments

@arjunroy-89
Copy link

What would you like to be added:

I am trying to convert the LSS format product (specifically Cloud Foundry) to OCM format through one python script.
its failing because of one component has different version compare to others.

consolidated_components.yaml
...rror creating OCM descriptor. Error:
Error: failed adding component "github.tools.sap/cloudfoundry/product-cf-hcp/jumpbox"(components.yaml[1][56]): component.resources.10.version: Does not match pattern '^[v]?(0|[1-9]\d*)(?:.(0|[1-9]\d*))?(?:.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-])(?:.(?:0|[1-9]\d|\d*[a-zA-Z-][0-9a-zA-Z-]))))?(?:+([0-9a-zA-Z-]+(?:.[0-9a-zA-Z-]+)*))?$'

created rsa key pair key.priv[key.pub]
Error: error processing "None": invalid component version reference "None": component version "None" is invalid
ERROR:root:Signing component versions failed
Error: path is None, unable to transfer component.

Version format we have for other component is like
trendmicro:
version: 20.0.1.21510

slirp4netns_arm64:
name: slirp4netns
version: 1.3.1

Version format for ubuntu_packages is like below
ubuntu_packages:
version: ubuntu-20.04-v20240119-gdch

Why is this needed:

Is the ubuntu packages version is specific to alpha-numeric pattern or just randomly selected/created.
I am asking because I wants to know as the script is failing to generate OCM descriptor file due to this version mismatch error.

Reason:
its failing because of one component has different version compare to others.

https://github.tools.sap/cloudfoundry/product-cf-hcp/blob/d293c0916c5f3f31ddb2032120275d6254762b70/components/jumpbox/artifacts.yml#L44

https://github.tools.sap/cloudfoundry/product-cf-hcp/blob/d293c0916c5f3f31ddb2032120275d6254762b70/components/jumpbox/artifacts.yml#L37

@arjunroy-89 arjunroy-89 added the kind/feature new feature, enhancement, improvement, extension label Dec 5, 2024
@github-actions github-actions bot added the area/ipcei Important Project of Common European Interest label Dec 5, 2024
@morri-son
Copy link
Contributor

The version needs to follow a "relaxed" SemVer scheme:

major, minor (+ optional patch level) - optional v-prefix).

If versions of resources have a different versioning scheme not following this, they need to be converted to match the version format in OCM. You can think of using a label to store the original artifact version.

@arjunroy-89
Copy link
Author

Hi @morri-son,
One query.
can we add the regex for the version ubuntu-20.04-v20240119-gdch
does the ocm-cli support regex expression ?

@morri-son
Copy link
Contributor

Hi @arjunroy-89 , we can only support (relaxed) SemVer for our versioning scheme. Since we have a toolset for the lifecycle of component (versions), we need the ability to compare versions and determine order, e.g. when there is a SemVer specified on our subscription for components in our OCM controller based setup, the an expression using SemVer is used to determine when a newer version is available and should be pulled.

Allowing (relatively) arbitrary version schemes would make our implementation overly complex. Therefore we stick to the "relaxed" SemVer scheme.

On resource level you can completely omit the version attribute. For all versions that do not stick to the "relaxed" SemVer scheme, you need to convert them to it. For your example a possible conversion could look like 20.4-v20240119-gdch. As mentioned before you can also use labels on component, resource and source level to save the original version and make them available for your tooling, e.g.

components:
- name: ocm.software/examples/special-version-comp
  version: 20.4-v20240119-gdch
  provider:
    name: acme.org
  labels:
    # original version not conform with SemVer
    - name: original-version
      value: ubuntu-20.04-v20240119-gdch

@github-project-automation github-project-automation bot moved this from 🆕 ToDo to 🍺 Done in OCM Backlog Board Dec 6, 2024
@morri-son morri-son moved this from 🍺 Done to 🔒Closed in OCM Backlog Board Dec 6, 2024
@arjunroy-89
Copy link
Author

Thanks @morri-son
I will try to implement the above suggestion.

@arjunroy-89
Copy link
Author

Hi @morri-son,
Good Day.
We have tried the above suggestion.

`components:

  • name: ocm.software/examples/special-version-comp
    version: 20.4-v20240119-gdch
    provider:
    name: acme.org
    labels:

    original version not conform with SemVer

    • name: original-version
      value: ubuntu-20.04-v20240119-gdch`

But its failing to pass the version.
Getting same error as earlier.

Can we connect over team meeting to discuss on this issue, It will be feasible for all of us.
Please suggest on this.

@morri-son
Copy link
Contributor

Hi @arjunroy-89,

I tried to reproduce the issue. Let me paste my components.yaml, the ocm add cv to a local CTF and then an ocm get cv from that CTF. I'm using the current 0.19.0-dev version, but we didn't change anything wrt version handling from the last releases.

Can you please check again on your side?

❯ cat components.yaml
components:
- name: ocm.software/test-comp
  version: 20.4-v20240119-gdch
  provider:
    name: acme.org
  resources:
    - name: resource-1
      version: 20.4-v20240119-gdch
      labels:
        - name: original-version
          value: ubuntu-20.04-v20240119-gdch
      type: ociImage
      access:
        type: ociArtifact
        imageReference: ghcr.io/stefanprodan/charts/podinfo:6.7.1

❯ ocm add cv -c --file /tmp/ctf ./components.yaml
processing ./components.yaml...
  processing document 1...
    processing index 1
found 1 component
adding component ocm.software/test-comp:20.4-v20240119-gdch...
  adding resource ociImage: "name"="resource-1","version"="20.4-v20240119-gdch"...

❯ ocm get cv /tmp/ctf//ocm.software/test-comp -oyaml
---
component:
  componentReferences: []
  creationTime: "2024-12-16T09:26:29Z"
  name: ocm.software/test-comp
  provider: acme.org
  repositoryContexts: []
  resources:
  - access:
      imageReference: ghcr.io/stefanprodan/charts/podinfo:6.7.1
      type: ociArtifact
    digest:
      hashAlgorithm: SHA-256
      normalisationAlgorithm: ociArtifactDigest/v1
      value: 4d5bd3562f0b150bd6cdfdbfb149e7e4ac36e555e25baa1da9f511f4d9fb7391
    labels:
    - name: original-version
      value: ubuntu-20.04-v20240119-gdch
    name: resource-1
    relation: external
    type: ociImage
    version: 20.4-v20240119-gdch
  sources: []
  version: 20.4-v20240119-gdch
meta:
  schemaVersion: v2

@morri-son morri-son reopened this Dec 16, 2024
@github-project-automation github-project-automation bot moved this from 🔒Closed to 📋 Next-UP in OCM Backlog Board Dec 16, 2024
@arjunroy-89
Copy link
Author

arjunroy-89 commented Dec 17, 2024

Hi @morri-son,
Thanks for the suggestion. we tried above syntax but no luck.
Below is the component.yaml file that we are trying to run, its failing and getting below error

# yaml-language-server: $schema=https://ocm.software/schemas/configuration-schema.yaml
components:
- name: github.tools.sap/cloudfoundry/product-cf-hcp/jumpbox
  version: 2024.12.10
  provider:
    name: sap.com
  resources:
  - input:
      compress: true
      excludeFiles:
      - .git
      - artifacts.yml
      followSymlinks: true
      path: ./product-cf-hcp/components/jumpbox
      type: dir
    name: lss-component-content
    type: directoryTree
    version: 2024.12.10
  - input:
      path: ./lss-jumpbox-description.yaml
      type: file
    name: lss-component-descriptor
    type: sap.com/btp/lss/jumpbox/component
    version: 2024.12.10
  - input:
      type: wget
      url: https://common.repositories.cloud.sap/artifactory/deploy.releases.sapcp/com/sap/cp/rldocker/27.3.1/docker.tgz
    name: docker
    type: blob
    version: 27.3.1
  - input:
      type: wget
      url: https://common.repositories.cloud.sap/artifactory/deploy.releases.sapcp/com/sap/cp/rldocker/27.1.2/docker_arm64_arm64.tgz
    name: docker_arm64
    type: blob
    version: 27.1.2
  - input:
      type: wget
      url: https://common.repositories.cloud.sap/artifactory/deploy.releases.sapcp/com/sap/cp/rldocker/27.3.1/rootless.tgz
    name: rootlessdocker
    type: blob
    version: 27.3.1
  - input:
      type: wget
      url: https://common.repositories.cloud.sap/artifactory/deploy.releases.sapcp/com/sap/cp/rldocker/27.1.2/rootless_arm64.tgz
    name: rootlessdocker_arm64
    type: blob
    version: 27.1.2
  - input:
      type: wget
      url: https://common.repositories.cloud.sap/artifactory/deploy.releases.sapcp/com/sap/cp/rldocker/driver/slirp4netns/1.3.1/slirp4netns-x86_64
    name: slirp4netns
    type: blob
    version: 1.3.1
  - input:
      type: wget
      url: https://common.repositories.cloud.sap/artifactory/deploy.releases.sapcp/com/sap/cp/rldocker/driver/slirp4netns/1.3.1/slirp4netns-arm64
    name: slirp4netns_arm64
    type: blob
    version: 1.3.1
  - input:
      type: wget
      url: https://common.repositories.cloud.sap/artifactory/deploy.releases.sapcp/com/sap/cp/cloudfoundry/telegraf-monika-release/3/telegraf-monika-release-3.tgz
    name: telegraf
    type: blob
    version: '3'
  - input:
      type: wget
      url: https://common.repositories.cloud.sap/artifactory/deploy.releases.sapcp/com/sap/cp/trendmicro/20.0.1.23340/trendmicro.tar.gz
    name: trendmicro
    type: blob
    version: 20.0-1.23340
  - input:
     type: wget
     url: https://common.repositories.cloud.sap/artifactory/deploy.releases.sapcp/com/sap/cp/gdch/ubuntu-20.04-v20240119-gdch/ubuntu_packages/ubuntu_packages.tar.gz
    labels:
      - name: original-version
        value: ubuntu-20.04-v20240119-gdch  
    name: ubuntu_packages
    type: blob
    version: 20.04-v20240119-gdch

Error

Error: failed adding component "github.tools.sap/cloudfoundry/product-cf-hcp/jumpbox"(temp.yaml[1][1]): component.resources.10.version: Does not match pattern '^[v]?(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
I751342@GVVCXCYXTK cf-ocm-adapter % 

We are trying to achieve to accomodate multiple images (part of one artifacts.yml) under which this ubuntu_packages is causing the issue with the pattern. However, kindly recommend if we can use this for all the images as a standard approach.
Here is the entire component link
https://github.tools.sap/cloudfoundry/product-cf-hcp/blob/rel-2024.T11a/components/jumpbox/artifacts.yml

@morri-son
Copy link
Contributor

Hi @arjunroy-89,

the version 20.04-v20240119-gdch you used, does not follow the "relaxed" SemVer scheme as it has a leading zero in the minor version which is not allowed. It needs to be 20.4-v20240119-gdch if you would like to use a modified original version for the resource version attribute.

@hilmarf
Copy link
Member

hilmarf commented Dec 17, 2024

#1195 (comment)

@morri-son
Copy link
Contributor

@arjunroy-89 , please see my and Hilmar's comment and proposal.

@github-project-automation github-project-automation bot moved this from 📋 Next-UP to 🍺 Done in OCM Backlog Board Dec 19, 2024
@ocmbot ocmbot bot moved this from 🍺 Done to 🔒Closed in OCM Backlog Board Dec 27, 2024
@morri-son morri-son reopened this Jan 9, 2025
@github-project-automation github-project-automation bot moved this from 🔒Closed to 📋 Next-UP in OCM Backlog Board Jan 9, 2025
@morri-son
Copy link
Contributor

HI @arjunroy-89 , did you check Hilmar's comment? As mentioned above the last error you reported comes from the fact that the used version does not follow SemVer. Nonetheless I re-opened the ticket, so that you can confirm that if using SemVer you're able to correctly add the resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ipcei Important Project of Common European Interest kind/feature new feature, enhancement, improvement, extension
Projects
Status: 📋 Next-UP
Development

No branches or pull requests

3 participants