Skip to content

Conversation

@zikra-iqbal
Copy link
Contributor

@zikra-iqbal zikra-iqbal commented Dec 3, 2025

Description

Added validation for OCP AI add-ons by retrieving the openshift-ai version and its supported OpenShift range via the API used by the CLI command ibmcloud oc cluster addon versions --output json, using the external data block.

data "ibm_iam_auth_token" "tokendata" {}

data "external" "ocp_addon_versions" {
  program = ["python3", "${path.module}/scripts/get_ocp_addon_versions.py"]
  query = {
    IAM_TOKEN = sensitive(data.ibm_iam_auth_token.tokendata.iam_access_token)
    region    = var.region
  }
}

Added a Python script scripts/get_ocp_addon_versions.py that retrieves the available OpenShift add-on versions. It is a generic script that can be used for add-on validations in the future and is not restricted to the OCP AI Add-on.

Release required?

  • No release
  • Patch release (x.x.X)
  • Minor release (x.X.x)
  • Major release (X.x.x)
Release notes content

Add validation for OCP AI add-ons.

Run the pipeline

If the CI pipeline doesn't run when you create the PR, the PR requires a user with GitHub collaborators access to run the pipeline.

Run the CI pipeline when the PR is ready for review and you expect tests to pass. Add a comment to the PR with the following text:

/run pipeline

Checklist for reviewers

  • If relevant, a test for the change is included or updated with this PR.
  • If relevant, documentation for the change is included or updated with this PR.

For mergers

  • Use a conventional commit message to set the release level. Follow the guidelines.
  • Include information that users need to know about the PR in the commit message. The commit message becomes part of the GitHub release notes.
  • Use the Squash and merge option.

Copy link
Contributor

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

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

@zikra-iqbal several times I mentioned not to use the CLI, but use the api the CLI calls - please re-check the issue details. Infact a python script might be better to use here if we are working directly with json (just don't use the requests pip package - use the inbuilt python http library)

@zikra-iqbal
Copy link
Contributor Author

@zikra-iqbal several times I mentioned not to use the CLI, but use the api the CLI calls - please re-check the issue details. Infact a python script might be better to use here if we are working directly with json (just don't use the requests pip package - use the inbuilt python http library)

@ocofaigh, I’m working on a Python script. I added this validation at the root level and to run the script ibmcloud_api_key is required . But there is no ibmcloud_api_key defined at the root level.
Should I add ibmcloud_api_key in the variables.tf file or create a submodule? Please suggest.

@ocofaigh
Copy link
Contributor

ocofaigh commented Dec 3, 2025

@zikra-iqbal You don't need to add a ibmcloud_api_key input. Instead you can generate a bearer token in terraform using the ibm_iam_auth_token data resource and pass the token to the script as an environment variable.

@zikra-iqbal zikra-iqbal requested a review from ocofaigh December 4, 2025 07:14
@zikra-iqbal
Copy link
Contributor Author

  • OCP AI add-on version: 417 and OCP version: 416
Screenshot 2025-12-04 at 3 57 31 PM
  • OCP AI add-on version: 419 and OCP version: 418
Screenshot 2025-12-04 at 3 58 44 PM
  • OCP AI add-on version: 416 and OCP version: 418
Screenshot 2025-12-04 at 4 30 58 PM
  • OCP AI add-on version: 417 and OCP version: 417
Screenshot 2025-12-04 at 4 30 22 PM

Copy link
Contributor

@ocofaigh ocofaigh left a comment

Choose a reason for hiding this comment

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

This looks promising - I left some comments. Please show in todays playback.
I'm also wondering if it could be extended to validate any of the addons, not just AI? We can discuss later.

list: Parsed JSON response containing add-on information.
"""
url = "/global/v1/addons"
host = "containers.cloud.ibm.com"
Copy link
Contributor

Choose a reason for hiding this comment

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

We need an environment variable override here to support other environments such as test.cloud.ibm.com. So you should refactor this to allow the user to pass an enviornmeent variable named IBMCLOUD_CS_API_ENDPOINT. If user does not specify the enviornment variable, the default value should be https://containers.test.cloud.ibm.com/global as per the provider docs:

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@zikra-iqbal zikra-iqbal marked this pull request as ready for review December 4, 2025 16:09
@zikra-iqbal zikra-iqbal requested a review from ocofaigh December 4, 2025 16:09
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