Add OCP version compatibility check before installation#163
Conversation
mlorenzofr
left a comment
There was a problem hiding this comment.
For integration with VP, perhaps the best place to perform these checks would be in the utility-container, and within the ansible collection rhvp.cluster_utils.
Not only is it better integrated, but the container and ansible also have a number of tools that would make our lives easier and allow us to avoid the python script.
As for the rest, the JSON validation design seems good to me. Perhaps it would be good to have a JSON validation scheme with attributes and their types for validation purposes.
| fi | ||
|
|
||
| if python3 - "$compat_file" "$ocp_minor" "$cluster_version" <<'PYEOF' | ||
| import json, sys |
There was a problem hiding this comment.
Perhaps instead of using an inline script within bash, it would be better to separate it into a separate script. This way, we can take a more development-oriented approach, such as ensuring that linters are passed, controlling its style, and so on.
The other option is to implement the same functionality via shell scripting using jq. However, as I mentioned in the review message, perhaps the appropriate place for this functionality, and for better integration with VP, would be the rhvp.cluster_utils collection.
There was a problem hiding this comment.
Let's discuss where to put this functionality as the best place.
|
|
||
| compat_file, ocp_minor, cluster_version = sys.argv[1], sys.argv[2], sys.argv[3] | ||
|
|
||
| with open(compat_file) as f: |
There was a problem hiding this comment.
| with open(compat_file) as f: | |
| with open(compat_file, encoding="utf-8") as f: |
| if command -v oc &>/dev/null; then | ||
| cluster_version=$(oc get clusterversion version \ | ||
| -o jsonpath='{.status.desired.version}' 2>/dev/null) || true | ||
| elif command -v kubectl &>/dev/null; then |
There was a problem hiding this comment.
The clusterversion resource is specific to OpenShift (CVO). This doesn't mean it won't work with kubectl, it's a CRD, but I don't know how many people will actually use kubectl with OpenShift instead of using oc.
Perhaps it would detect which CLI is being used and then use it, thus avoiding this if statement and the repetition of cluster_version=.... which is the same in both cases except for the CLI:
local kube_cli
kube_cli=$(command -v oc 2>/dev/null) || kube_cli=$(command -v kubectl 2>/dev/null) || true
if [ -n "$kube_cli" ]; then
cluster_version=$($kube_cli get clusterversion ...
fi| "supported": ["4.20", "4.21"], | ||
| "tested": ["4.20", "4.21"], | ||
| "known_issues": { | ||
| "4.22": "ZTWIM operator (openshift-zero-trust-workload-identity-manager) is not available in redhat-marketplace:v4.22.", |
There was a problem hiding this comment.
Instead of a string, we could use a list. This way, we could add multiple messages to the same version if needed.
c92d5d1 to
5362473
Compare
Summary
pattern.shthat detects the target cluster version and warns the user before installing on unsupported OCP streamscompatibility.jsonas a machine-readable compatibility matrix defining supported versions and known issuesMotivation
Installing ZTVP on an unsupported OCP version (e.g., 4.22) silently proceeds and then fails with subscription errors (ZTWIM operator missing from catalog, ACM channel mismatch). The user gets no feedback
until ArgoCD applications go unhealthy. This check catches the problem before any cluster resources are deployed.
How it works
The
check_compatibilityfunction inpattern.shruns on the host before the utility container is launched:compatibility.jsonfrom the repo rootoc(falls back tokubectl)Bypass mechanisms
SKIP_COMPATIBILITY_CHECK=true ./pattern.sh make install— skips entirelyyat the prompt — proceeds with warning acknowledgedcompatibility.json— disables the featureGraceful fallbacks
No
oc/kubectlon host, nopython3, or nocompatibility.json— the check is silently skipped and installation proceeds normally.Tested
SKIP_COMPATIBILITY_CHECK=true— check skippedcompatibility.json— check skippedNext steps
We can extend this and make it default part of the VP framework and
compatibility.jsoncan be added to patterns who would like to adopt it. We can also update the graphical pattern installation in a similar way. Other tests can be added based on thecompatibility.jsonas well in the future.