CNTRLPLANE-2781: Document valid character sets and add validation for Azure Marketplace image fields#8223
Conversation
…Marketplace image fields - Replace TODO comments with proper documentation for imageID, publisher, offer, and sku fields in AzureVMImage and AzureMarketplaceImage - Add kubebuilder validation pattern for offer field enforcing valid Azure Marketplace characters (alphanumeric, hyphens, underscores, periods) - Add concrete examples and links to Microsoft Learn documentation - Document expected Azure resource ID format for imageID with examples Signed-off-by: OpenShift CI Bot <ci-bot@redhat.com> Commit-Message-Assisted-by: Claude (via Claude Code)
…lidation - Revendor api/hypershift/v1beta1/azure.go with updated field docs - Regenerate NodePool CRD manifests (Default, CustomNoUpgrade, TechPreviewNoUpgrade) with new offer pattern and expanded descriptions Signed-off-by: OpenShift CI Bot <ci-bot@redhat.com> Commit-Message-Assisted-by: Claude (via Claude Code)
- Correct map literal alignment for armNodeLabels in testARM64Provisioning Signed-off-by: OpenShift CI Bot <ci-bot@redhat.com> Commit-Message-Assisted-by: Claude (via Claude Code)
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@hypershift-jira-solve-ci[bot]: This pull request references CNTRLPLANE-2781 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@hypershift-jira-solve-ci[bot]: This pull request references CNTRLPLANE-2781 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@hypershift-jira-solve-ci[bot]: This pull request references CNTRLPLANE-2781 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (8)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR updates field documentation and validation for Azure image selection in api/hypershift/v1beta1/azure.go: it clarifies AzureVMImage.ImageID as an Azure resource ID (with examples), expands AzureMarketplaceImage.Publisher docs and allowed characters, specifies format and adds a kubebuilder XValidation rule for AzureMarketplaceImage.Offer (must match ^[a-zA-Z0-9][a-zA-Z0-9._-]*$), and documents AzureMarketplaceImage.SKU length/characters. In test/e2e/karpenter_test.go, only whitespace/indentation in the armNodeLabels map was adjusted. 🚥 Pre-merge checks | ✅ 9 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (9 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@hypershift-jira-solve-ci[bot]: This pull request references CNTRLPLANE-2781 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@api/hypershift/v1beta1/azure.go`:
- Around line 174-176: The publisher examples in the azure.go comment contradict
the lowercase-only validation (regex ^[a-z0-9][a-z0-9-_]{2,49}$) — replace the
mixed-case examples "Canonical" and "RedHat" with lowercase-valid examples
(e.g., "canonical", "redhat") so the examples match the enforced rule; update
the comment near the publisher description/regex in azure.go accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: ad6816d4-78e6-4a0c-a1c0-11173828cb9a
⛔ Files ignored due to path filters (9)
api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/AAA_ungated.yamlis excluded by!**/zz_generated.featuregated-crd-manifests/**api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/GCPPlatform.yamlis excluded by!**/zz_generated.featuregated-crd-manifests/**api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OpenStack.yamlis excluded by!**/zz_generated.featuregated-crd-manifests/**cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-CustomNoUpgrade.crd.yamlis excluded by!**/zz_generated.crd-manifests/**,!cmd/install/assets/**/*.yamlcmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-Default.crd.yamlis excluded by!**/zz_generated.crd-manifests/**,!cmd/install/assets/**/*.yamlcmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-TechPreviewNoUpgrade.crd.yamlis excluded by!**/zz_generated.crd-manifests/**,!cmd/install/assets/**/*.yamldocs/content/reference/aggregated-docs.mdis excluded by!docs/content/reference/aggregated-docs.mddocs/content/reference/api.mdis excluded by!docs/content/reference/api.mdvendor/github.com/openshift/hypershift/api/hypershift/v1beta1/azure.gois excluded by!vendor/**,!**/vendor/**
📒 Files selected for processing (2)
api/hypershift/v1beta1/azure.gotest/e2e/karpenter_test.go
c1239e4 to
1276b77
Compare
|
@hypershift-jira-solve-ci[bot]: This pull request references CNTRLPLANE-2781 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8223 +/- ##
==========================================
+ Coverage 34.63% 35.61% +0.98%
==========================================
Files 767 767
Lines 93186 93333 +147
==========================================
+ Hits 32277 33245 +968
+ Misses 58236 57399 -837
- Partials 2673 2689 +16 🚀 New features to boost your workflow:
|
|
@coderabbitai Thanks for the review. The publisher examples have already been updated to lowercase-valid values ( AI-assisted response via Claude Code |
|
Is this essentially a duplicate of #8211 ? |
|
@everettraven Yes, there is significant overlap. Both PRs address the same TODO comments on the Key differences:
These will conflict if both are merged. They should be reconciled — either close one in favor of the other, or merge the best parts of both into a single PR. AI-assisted response via Claude Code |
- Update api.md and aggregated-docs.md with improved field descriptions, examples, and documentation links for Azure Marketplace image types Signed-off-by: OpenShift CI Bot <ci-bot@redhat.com> Commit-Message-Assisted-by: Claude (via Claude Code)
|
Re: review PRR_kwDOE7ekcc70eIzd @coderabbitai Good catch on the mixed-case publisher examples. The Go source ( AI-assisted response via Claude Code |
1276b77 to
1fd2eaf
Compare
|
@hypershift-jira-solve-ci[bot]: This pull request references CNTRLPLANE-2781 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
| // The value must consist of only alphanumeric characters (a-z, A-Z, 0-9), | ||
| // hyphens (-), underscores (_), and periods (.). | ||
| // It must start with an alphanumeric character. | ||
| // See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more |
There was a problem hiding this comment.
is there a canonical source to API rather than CLI?
There was a problem hiding this comment.
The closest canonical API source is the Azure Compute REST API reference for Virtual Machine Images:
https://learn.microsoft.com/en-us/rest/api/compute/virtual-machine-images
With specific operations for each field:
- List Publishers: https://learn.microsoft.com/en-us/rest/api/compute/virtual-machine-images/list-publishers
- List Offers: https://learn.microsoft.com/en-us/rest/api/compute/virtual-machine-images/list-offers
- List SKUs: https://learn.microsoft.com/en-us/rest/api/compute/virtual-machine-images/list-skus
However, the REST API docs don't document the character set constraints explicitly — those come from the Partner Center docs for publishers creating offers (e.g., https://learn.microsoft.com/en-us/partner-center/marketplace-offers/azure-vm-offer-setup). The CLI page currently linked is arguably the most user-friendly consumer-facing reference for finding valid values.
Happy to update the links to the REST API reference or the Partner Center docs — let me know which you'd prefer.
AI-assisted response via Claude Code
| // See https://learn.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage for more | ||
| // information on Azure Marketplace image offers. | ||
| // | ||
| // +kubebuilder:validation:Pattern=`^[a-zA-Z0-9][a-zA-Z0-9._-]*$` |
There was a problem hiding this comment.
please use // +kubebuilder:validation:XValidation:rule="self.matches and add an envtest to validate this
There was a problem hiding this comment.
Done. Replaced +kubebuilder:validation:Pattern with +kubebuilder:validation:XValidation:rule="self.matches('^[a-zA-Z0-9][a-zA-Z0-9._-]*$')" for the offer field, consistent with the pattern used elsewhere in the codebase (e.g., GCP project IDs in gcp.go, Azure client IDs in azure.go).
Added three envtest cases to stable.nodepools.azure.testsuite.yaml:
- Rejects offer with invalid characters (spaces,
!) - Rejects offer starting with a hyphen
- Accepts offer with valid mixed characters (alphanumeric, hyphens, underscores, periods)
Regenerated CRDs and vendor.
AI-assisted response via Claude Code
|
/test address-review-comments |
Replace kubebuilder Pattern validation with XValidation CEL rule using self.matches() for the Azure Marketplace offer field, as requested in review. This approach is consistent with other field validations in the codebase (e.g., GCP project IDs, Azure client IDs) and provides better error messages via the message parameter. Also adds envtest cases to validate the offer field character constraints: rejects invalid characters and non-alphanumeric starts, accepts valid offer strings with hyphens, underscores, and periods. Regenerated CRDs and vendor to reflect the change. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@hypershift-jira-solve-ci[bot]: This pull request references CNTRLPLANE-2781 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/retest |
|
Both agents converged on the same root cause. Here is the final report: Test Failure Analysis CompleteJob Information
Test Failure AnalysisErrorSummaryBoth Enterprise Contract checks failed because the Snyk SAST scanner ( Root CauseThe Snyk CLI, running as part of the The Snyk task itself completed as a Tekton task (exit code 0) but set its Comparison with other PRs confirms this is transient:
All other build tasks (clair-scan, clamav-scan, sast-unicode-check, rpms-signature-scan, deprecated-base-image-check) passed identically across all PRs. The 38 warnings (sast-shell-check, coverity-availability-check, trusted_task.current) are informative-only and also identical across PRs. Recommendations
Evidence
|
|
/uncc |
|
/retest |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: enxebre, hypershift-jira-solve-ci[bot] The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
PTAL @everettraven /label tide/merge-method-squash |
|
Re: #8223 (comment) @everettraven Good question — there is significant overlap, but also some meaningful differences between the two PRs that may be worth considering: Overlap: Both PRs resolve the same TODO comments on the Key differences:
Consolidating into a single PR would make sense to avoid merge conflicts on the same lines. The decision on which approach to keep (XValidation vs Pattern for AI-assisted response via Claude Code |
|
Re: #8223 (comment) @everettraven Good question — there is definite overlap, but also some meaningful differences between the two PRs:
Both resolve the same TODO comments on Since @enxebre has already approved this PR, happy to defer to you both on whether to consolidate or proceed with this one as-is. Either approach works — if proceeding separately, whichever merges second would need a rebase to resolve the AI-assisted response via Claude Code |
What this PR does / why we need it:
Documents the valid character sets for Azure Marketplace image fields (
offer,publisher,sku,imageID) and adds kubebuilder validation for theofferfield.Previously, these API fields had TODO comments instead of proper documentation. This PR:
offerfield enforcing valid Azure Marketplace characters (alphanumeric, hyphens, underscores, periods)Which issue(s) this PR fixes:
Fixes https://redhat.atlassian.net/browse/CNTRLPLANE-2781
Special notes for your reviewer:
The validation pattern
^[a-zA-Z0-9._-]+$for theofferfield matches the character set accepted by Azure Marketplace. Other fields (publisher,sku) were documented but not given validation patterns since their constraints may vary — this can be added in a follow-up if desired.Checklist:
Always review AI generated responses prior to use.
Generated with Claude Code via
/jira:solve [CNTRLPLANE-2781](https://redhat.atlassian.net/browse/CNTRLPLANE-2781)Summary by CodeRabbit