Skip to content

[release-4.21] OCPBUGS-77502: test: add EC2 AMI related verification to Windows ImageType test#7830

Closed
openshift-cherrypick-robot wants to merge 1 commit intoopenshift:release-4.21from
openshift-cherrypick-robot:cherry-pick-7680-to-release-4.21
Closed

[release-4.21] OCPBUGS-77502: test: add EC2 AMI related verification to Windows ImageType test#7830
openshift-cherrypick-robot wants to merge 1 commit intoopenshift:release-4.21from
openshift-cherrypick-robot:cherry-pick-7680-to-release-4.21

Conversation

@openshift-cherrypick-robot
Copy link
Copy Markdown

This is an automated cherry-pick of #7680

/assign wangke19

Simplify the test to focus on core validation:
- Remove all scaling logic (orthogonal to ImageType validation)
- Keep BuildNodePoolManifest to create Windows ImageType NodePool
- Framework already waits for nodes to be ready
- Run method validates:
  1. ValidPlatformImageType condition shows Windows AMI
  2. Nodes are running expected RHCOS-based OS (WinLI AMI)

The Windows License Included (WinLI) AMI is RHCOS with Windows
licensing metadata, so nodes report linux OS with RHCOS image.

This addresses review feedback that scaling tests are orthogonal
to ImageType validation, and the framework already handles node
readiness checks.

test: add EC2 AMI verification to NodePoolImageTypeTest

Add critical validation layer to verify EC2 instances are actually
using the Windows LI AMI, not just that the controller found one.

This is the most important validation because:
- AWS bills based on the AMI used by EC2 instances
- Windows licensing compliance depends on using WinLI AMI
- A bug could result in the controller finding the correct AMI but
  applying a different one to EC2 instances

Validation layers (in order of criticality):
1. EC2 instance AMI matches expected Windows LI AMI (NEW)
2. NodePool ValidPlatformImageType condition shows Windows AMI
3. Nodes boot successfully with RHCOS

The EC2 verification queries AWS API to get the actual ImageId
of each instance and compares it to the expected Windows LI AMI
extracted from the NodePool condition message.

This addresses the root requirement from OCPSTRAT-1949: customers
running Windows VMs within OCP-Virt on ROSA-HCP must use nodes with
Windows LI metadata to be compliant with AWS EC2 LI terms.

test: wait for settled ValidPlatformImageType condition status

Fix race condition where test would proceed while condition Status
is still Unknown. The wait predicate now explicitly checks for settled
status (True or False) rather than treating empty Status as wildcard.

The previous implementation used ConditionPredicate with only Type set,
which matches any Status including Unknown due to wildcard behavior in
the Matches() function. This caused the test to continue before the
controller completed AMI discovery.

The fix uses a custom predicate that:
- Waits for condition Type to exist
- Ensures Status is True or False (settled state)
- Rejects Status=Unknown (controller still discovering)

This ensures deterministic test results and aligns with the test logic
that expects Status to be either True (AMI found) or False (AMI not
available), never Unknown.

Addresses review comment on PR openshift#7680.

test: improve EC2 instance validation robustness

Address code review feedback to improve error handling and validation:

1. Add context cancellation check in EC2 validation loop
   - Prevents unnecessary AWS API calls if context is cancelled
   - Provides early exit with clear error message

2. Safer providerID parsing with validation
   - Replace unsafe string slicing with strings.Split
   - Validate providerID format before extraction
   - Check for empty instance ID after extraction
   - Add clear error messages for malformed providerIDs

3. Stricter AMI ID regex pattern
   - Match exactly 8 hex chars (old format: ami-12345678)
   - Or exactly 17 hex chars (new format: ami-0abcdef1234567890)
   - Previous pattern matched 8-17 chars, allowing invalid lengths

These changes improve test reliability and provide better error
messages when validation fails.

test: fix import alias for metav1 types

Fix type mismatch error where v1.ConditionTrue was being compared
with condition.Status (metav1.ConditionStatus type).

Changed import alias from 'v1' to 'metav1' for consistency and
updated all references to use the correct type names:
- v1.ObjectMeta -> metav1.ObjectMeta
- v1.ConditionTrue -> metav1.ConditionTrue
- v1.ConditionFalse -> metav1.ConditionFalse

This fixes the CI error:
  invalid operation: condition.Status == v1.ConditionTrue
  (mismatched types corev1.ConditionStatus and metav1.ConditionStatus)

test: use corev1.ConditionStatus constants for NodePool condition check

Fix type mismatch error where NodePool condition.Status (corev1.ConditionStatus)
was being compared with metav1.ConditionTrue/False (metav1.ConditionStatus).

The hyperv1.NodePool.Status.Conditions use corev1.Condition type, so we must
compare with corev1.ConditionTrue and corev1.ConditionFalse constants.

test: use t.Skip when Windows AMI unavailable

When Windows AMI is not available for a region/version combination,
use t.Skipf instead of logging and returning. This properly marks
the test as skipped rather than passed, which is semantically correct
since the test cannot verify functionality when preconditions aren't met.

This improves CI/CD metrics by distinguishing between:
- Test passed: functionality verified
- Test skipped: preconditions not met
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Feb 28, 2026

@openshift-cherrypick-robot: Ignoring requests to cherry-pick non-bug issues: CNTRLPLANE-753

Details

In response to this:

This is an automated cherry-pick of #7680

/assign wangke19

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 28, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot added do-not-merge/needs-area area/testing Indicates the PR includes changes for e2e testing labels Feb 28, 2026
@openshift-ci openshift-ci Bot requested review from devguyio and jparrill February 28, 2026 06:27
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Feb 28, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: openshift-cherrypick-robot
Once this PR has been reviewed and has the lgtm label, please assign sjenning for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wangke19
Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Feb 28, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Feb 28, 2026

@openshift-cherrypick-robot: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

@wangke19
Copy link
Copy Markdown
Contributor

/auto-cc

@openshift-ci openshift-ci Bot requested a review from muraee February 28, 2026 11:10
@wangke19
Copy link
Copy Markdown
Contributor

/retitle [release-4.21] OCPBUGS-77502: test: add EC2 AMI related verification to Windows ImageType test

@openshift-ci openshift-ci Bot changed the title [release-4.21] CNTRLPLANE-753: test: add EC2 AMI related verification to Windows ImageType test [release-4.21] OCPBUGS-77502: test: add EC2 AMI related verification to Windows ImageType test Feb 28, 2026
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Feb 28, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@openshift-cherrypick-robot: This pull request references Jira Issue OCPBUGS-77502, which is invalid:

  • expected the bug to target the "4.21.z" version, but no target version was set
  • release note text must be set and not match the template OR release note type must be set to "Release Note Not Required". For more information you can reference the OpenShift Bug Process.
  • expected Jira Issue OCPBUGS-77502 to depend on a bug targeting a version in 4.22.0 and in one of the following states: VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA), but no dependents were found

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

This is an automated cherry-pick of #7680

/assign wangke19

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.

@wangke19
Copy link
Copy Markdown
Contributor

/jira refresh

@openshift-ci-robot
Copy link
Copy Markdown

@wangke19: This pull request references Jira Issue OCPBUGS-77502, which is invalid:

  • expected the bug to target the "4.21.z" version, but no target version was set
  • release note text must be set and not match the template OR release note type must be set to "Release Note Not Required". For more information you can reference the OpenShift Bug Process.
  • expected dependent Jira Issue OCPBUGS-77503 to be in one of the following states: VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA), but it is MODIFIED instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

/jira refresh

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.

@wangke19
Copy link
Copy Markdown
Contributor

wangke19 commented Mar 3, 2026

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Mar 3, 2026

@wangke19: Closed this PR.

Details

In response to this:

/close
No need a backport pr to 4.21: https://redhat-internal.slack.com/archives/G01QS0P2F6W/p1772462742644029?thread_ts=1772026014.095289&cid=G01QS0P2F6W

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 kubernetes-sigs/prow repository.

@openshift-ci openshift-ci Bot closed this Mar 3, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@openshift-cherrypick-robot: This pull request references Jira Issue OCPBUGS-77502. The bug has been updated to no longer refer to the pull request using the external bug tracker. All external bug links have been closed. The bug has been moved to the NEW state.

Details

In response to this:

This is an automated cherry-pick of #7680

/assign wangke19

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/testing Indicates the PR includes changes for e2e testing jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants