Skip to content

feat: add OCP version compatibility check - #151

Open
p-rog wants to merge 3 commits into
validatedpatterns:mainfrom
p-rog:compatibility-check
Open

feat: add OCP version compatibility check#151
p-rog wants to merge 3 commits into
validatedpatterns:mainfrom
p-rog:compatibility-check

Conversation

@p-rog

@p-rog p-rog commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • Adds a validate_ocp_version Ansible role that checks the target cluster's OCP version against compatibility metadata defined in pattern-metadata.yaml
  • Wires the new role into the existing validate_cluster playbook so it runs automatically during make install
  • Patterns without ocp_versions metadata are unaffected — the check is gracefully skipped

How it works

Each pattern can declare an ocp_versions section in pattern-metadata.yaml:

ocp_versions:
  minimum: "4.20"
  unsupported:
    - version: "4.23"
      reason: "Not yet validated — operator catalog and channel availability unconfirmed"
Cluster version Behavior
Supported (>= minimum, not in unsupported list) Confirmation message, installation proceeds
Below minimum Polite warning, installation proceeds
Explicitly unsupported Hard fail with reason displayed
No ocp_versions in metadata Silently skipped (backward compatible)

Override the hard fail for testing: SKIP_OCP_VERSION_CHECK=true ./pattern.sh make install

Companion PR

Context

This originated from a ZTVP-specific implementation (layered-zero-trust#163) that was closed in favor of a framework-level solution after team discussion. The agreed approach was to use pattern-metadata.yaml for version data and the rhvp.cluster_utils collection for validation logic.

Test plan

  • Install a pattern with ocp_versions metadata on a supported OCP version — should show OK
  • Install on a version below minimum — should show warning, proceed
  • Install on an explicitly unsupported version — should hard fail with reason
  • SKIP_OCP_VERSION_CHECK=true — should skip the check entirely
  • Install a pattern without ocp_versions in metadata — should skip gracefully

Made with Cursor

Add a validate_ocp_version role that reads ocp_versions from
pattern-metadata.yaml and checks the target cluster version before
installation. Explicitly unsupported versions cause a hard fail;
versions below the minimum trigger a warning. Patterns without
ocp_versions metadata are unaffected (graceful skip).

Override with SKIP_OCP_VERSION_CHECK=true for testing.

Signed-off-by: Przemyslaw Roguski <proguski@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@mbaldessari

Copy link
Copy Markdown
Contributor

Hi @p-rog, thanks for the PR, nice work! Can we extend the schema for pattern-metadata yaml here https://github.com/validatedpatterns/pattern-ui-catalog/blob/main/pattern.schema.json so we have it in the reference place.

Note that right now this code won't run when doing "make install" it will only run when running "make validate-cluster"

You will need to add SKIP_OCP_VERSION_CHECK to your pattern.sh (once this lands we will land it in the https://github.com/validatedpatterns/patternizer/ repo)

@mbaldessari

Copy link
Copy Markdown
Contributor

Could you also do a s/SKIP_OCP_VERSION_CHECK/DISABLE_OCP_VERSION_CHECK/g since we already use that DISABLE_ prefix for other env vars?

@mlorenzofr mlorenzofr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good job. I think the implementation is quite good, although one task needs to be removed as it doesn't really make sense since we're comparing a k8s version with an ocp version, which have different versioning

Comment thread roles/validate_ocp_version/tasks/main.yml Outdated
Comment thread roles/validate_ocp_version/tasks/main.yml Outdated
Comment thread roles/validate_ocp_version/tasks/main.yml Outdated
Comment thread roles/validate_ocp_version/defaults/main.yml Outdated
- Rename SKIP_OCP_VERSION_CHECK to DISABLE_OCP_VERSION_CHECK (VP convention)
- Remove Kubernetes version extraction (k8s version != OCP version)
- Make ClusterVersion CVO fetch unconditional with assertion
- Replace errors='ignore' with stat + slurp + rescue for proper
  handling of missing vs malformed pattern-metadata.yaml

Signed-off-by: Przemyslaw Roguski <proguski@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@p-rog

p-rog commented Aug 5, 2026

Copy link
Copy Markdown
Author

Hi @p-rog, thanks for the PR, nice work! Can we extend the schema for pattern-metadata yaml here https://github.com/validatedpatterns/pattern-ui-catalog/blob/main/pattern.schema.json so we have it in the reference place.

Sure. Here is PR:
validatedpatterns/pattern-ui-catalog#36

@mbaldessari please review it.

Note that right now this code won't run when doing "make install" it will only run when running "make validate-cluster"

You will need to add SKIP_OCP_VERSION_CHECK to your pattern.sh (once this lands we will land it in the https://github.com/validatedpatterns/patternizer/ repo)

@mbaldessari so, do you think we should update the common and add validate-cluster target in common/Makefile like it's done currently with the validate-prereq? IMHO it can be next improvement and for now we can keep validation by running make validate-cluster. WDYT?

@mhjacks mhjacks left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The set_fact/rescue bit has to change.

I'm curious what others think of the text box output - I could be persuaded on this point.

The note on changing pattern.sh is a change I think we would make and propogate.

Comment thread roles/validate_ocp_version/tasks/main.yml

- name: OCP version check disabled
ansible.builtin.debug:
msg: "OCP version compatibility check disabled (DISABLE_OCP_VERSION_CHECK=true)."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Note: we'll need to add this to pattern.sh's list of env vars to pass through to the utlity container.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We can add it later to the patternizer repo once this PR merges.

ansible.builtin.fail:
msg: |

╔══════════════════════════════════════════════════════════════════╗

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would prefer to not have the "text box" output. It seems to depend on using the null STDOUT callback (which is default) but does not look good e.g. with the normal stdout callback. I think from a UX standpoint halting the installation with instructions on how to recover it is sufficient.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Personally I like "text boxes" because it's very clear that this is the core information you have to read. If you don't mind I would prefer to leave text boxes.

msg: |

┌──────────────────────────────────────────────────────────────────┐
│ WARNING │

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same note on text box formatting as above.

@mbaldessari

Copy link
Copy Markdown
Contributor

Hi @p-rog, thanks for the PR, nice work! Can we extend the schema for pattern-metadata yaml here https://github.com/validatedpatterns/pattern-ui-catalog/blob/main/pattern.schema.json so we have it in the reference place.

Sure. Here is PR: validatedpatterns/pattern-ui-catalog#36

@mbaldessari please review it.

Note that right now this code won't run when doing "make install" it will only run when running "make validate-cluster"
You will need to add SKIP_OCP_VERSION_CHECK to your pattern.sh (once this lands we will land it in the https://github.com/validatedpatterns/patternizer/ repo)

@mbaldessari so, do you think we should update the common and add validate-cluster target in common/Makefile like it's done currently with the validate-prereq? IMHO it can be next improvement and for now we can keep validation by running make validate-cluster. WDYT?

Let's stick with leaving it in the validated-cluster, maybe some readme (iirc) might need some tweaking here and there since it is not being run by default during install. We can always add it later to the install target

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants