Skip to content

Conversation

SargunNarula
Copy link
Contributor

@SargunNarula SargunNarula commented Sep 26, 2025

The GetSMTLevel util function previously used gomega assertions which could cause panics when called outside of Ginkgo It blocks.

This PR addresses:

  • Modified the GetSMTLevel signature to return (int, error)
  • Replaced ExpectWithOffset assertions with standard error handling
  • Updated all function refrences to handle the error return

@SargunNarula SargunNarula changed the title e2e: refactor: Remove gomega assertions from GetSMTLevel utility function e2e: Remove gomega assertions from GetSMTLevel utility function Sep 26, 2025
@SargunNarula SargunNarula changed the title e2e: Remove gomega assertions from GetSMTLevel utility function e2e: refactor GetSMTLevel to remove Gomega assertions and add multi arch support Sep 26, 2025
@SargunNarula
Copy link
Contributor Author

/retest

@SargunNarula SargunNarula changed the title e2e: refactor GetSMTLevel to remove Gomega assertions and add multi arch support e2e: refactor GetSMTLevel to remove Gomega assertions Sep 29, 2025
The GetSMTLevel util function previously used gomega assertions which could cause panics when called outside of
Ginkgo It blocks.

This PR addresses:
- Modified the GetSMTLevel signature to return (int, error)
- Replaced ExpectWithOffset assertions with standard error handling
- Updated all function refrences to handle the error return

Signed-Off-by: Sargun Narula <snarula@redhat.com>
Copy link
Contributor

@swatisehgal swatisehgal left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 29, 2025
// GetSMTLevel returns the SMT level on the node using the given cpuID as target
// Use a random cpuID from the return value of GetOnlineCPUsSet if not sure
func GetSMTLevel(ctx context.Context, cpuID int, node *corev1.Node) int {
func GetSMTLevel(ctx context.Context, cpuID int, node *corev1.Node) (int, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

GinkgoHelper() in the first line will solve exactly that without having to change the function API
https://onsi.github.io/ginkgo/#mental-model-how-ginkgo-handles-failure

Copy link
Contributor

@ffromani ffromani Sep 29, 2025

Choose a reason for hiding this comment

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

@Tal-or is very correct. In addition, that would allow us to remove the fragile WithOffset expectations (mostly my fault here).

That said, changing the function signature and return an explicit error LGTM and I slightly prefer that approach for library code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Tal-or If i understand correctly, if we used GinkgoHelper(), it would remove the panic and point the failure to Test itself, which originally is not the motive of the API change.

Considering a library function, it should work when called outside a test spec block, where it would panic. Please let me know if I’ve misunderstood anything here.

Copy link
Contributor

@Tal-or Tal-or Sep 29, 2025

Choose a reason for hiding this comment

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

What is considered to be panic? a go assertion? because it's expected to abort a test with an assertion in Ginkgo.
All GinkgoHelper() is doing is point to the caller of the function (in the stack trace), it's basically equal to call Fail with offset.

Considering a library function, it should work when called outside a test spec block

this function scope is only for the NTO e2e test, it should not be imported into other projects and not even in the none-test code of this specific project, so assertion here is completely fine.

Bottom line, I don't mind whether this function return an errors or asserts, my initial comment was mainly for the sake of discussion and broadening the knowledge and expertise as part of the reviewing process.

Copy link
Contributor

Choose a reason for hiding this comment

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

this function scope is only for the NTO e2e test, it should not be imported into other projects and not even in the none-test code of this specific project, so assertion here is completely fine.

I fully agree with this sentence

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the remaining open point boils down to: where is this function planned to be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ffromani Here is a use- case where this function was tend to be used - Link. Ignore the checkHyperthreding() for now as it is just a wrapper over getSMTLevel and would be removed once it itself gets fixed.

@SargunNarula
Copy link
Contributor Author

/retest

4 similar comments
@SargunNarula
Copy link
Contributor Author

/retest

@SargunNarula
Copy link
Contributor Author

/retest

@SargunNarula
Copy link
Contributor Author

/retest

@SargunNarula
Copy link
Contributor Author

/retest

@ffromani
Copy link
Contributor

considering the proposed usage, which is still within the test code, I'm inclined to approve. @Tal-or any concern or comment?

@Tal-or
Copy link
Contributor

Tal-or commented Sep 30, 2025

considering the proposed usage, which is still within the test code, I'm inclined to approve. @Tal-or any concern or comment?

@ffromani Works for me

Copy link
Contributor

@ffromani ffromani left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

Copy link
Contributor

openshift-ci bot commented Sep 30, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ffromani, SargunNarula

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

The pull request process is described here

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 30, 2025
@SargunNarula SargunNarula changed the title e2e: refactor GetSMTLevel to remove Gomega assertions CNF-19657: e2e: refactor GetSMTLevel to remove Gomega assertions Sep 30, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Sep 30, 2025
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Sep 30, 2025

@SargunNarula: This pull request references CNF-19657 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 story to target either version "4.21." or "openshift-4.21.", but it targets "openshift-4.20" instead.

In response to this:

The GetSMTLevel util function previously used gomega assertions which could cause panics when called outside of Ginkgo It blocks.

This PR addresses:

  • Modified the GetSMTLevel signature to return (int, error)
  • Replaced ExpectWithOffset assertions with standard error handling
  • Updated all function refrences to handle the error return

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.

@SargunNarula
Copy link
Contributor Author

/retest

@SargunNarula
Copy link
Contributor Author

/label verified

Copy link
Contributor

openshift-ci bot commented Sep 30, 2025

@SargunNarula: The label(s) /label verified cannot be applied. These labels are supported: acknowledge-critical-fixes-only, platform/aws, platform/azure, platform/baremetal, platform/google, platform/libvirt, platform/openstack, ga, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, px-approved, docs-approved, qe-approved, ux-approved, no-qe, downstream-change-needed, rebase/manual, cluster-config-api-changed, run-integration-tests, approved, backport-risk-assessed, bugzilla/valid-bug, cherry-pick-approved, jira/valid-bug, ok-to-test, stability-fix-approved, staff-eng-approved. Is this label configured under labels -> additional_labels or labels -> restricted_labels in plugin.yaml?

In response to this:

/label verified

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.

@mrniranjan
Copy link
Contributor

/verified by @mrniranjan

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Oct 1, 2025
@openshift-ci-robot
Copy link
Contributor

@mrniranjan: This PR has been marked as verified by @mrniranjan.

In response to this:

/verified by @mrniranjan

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.

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD b5d66f8 and 2 for PR HEAD 0be8ef3 in total

@SargunNarula SargunNarula changed the title CNF-19657: e2e: refactor GetSMTLevel to remove Gomega assertions OCPBUGS-62605: e2e: refactor GetSMTLevel to remove Gomega assertions Oct 1, 2025
@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Oct 1, 2025
@openshift-ci-robot
Copy link
Contributor

@SargunNarula: This pull request references Jira Issue OCPBUGS-62605, which is invalid:

  • expected the bug to target the "4.21.0" version, but no target version was set

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.

In response to this:

The GetSMTLevel util function previously used gomega assertions which could cause panics when called outside of Ginkgo It blocks.

This PR addresses:

  • Modified the GetSMTLevel signature to return (int, error)
  • Replaced ExpectWithOffset assertions with standard error handling
  • Updated all function refrences to handle the error return

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.

@SargunNarula
Copy link
Contributor Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Oct 1, 2025
@openshift-ci-robot
Copy link
Contributor

@SargunNarula: This pull request references Jira Issue OCPBUGS-62605, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (liqcui@redhat.com), skipping review request.

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.

Copy link
Contributor

openshift-ci bot commented Oct 1, 2025

@SargunNarula: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-scos-e2e-aws-ovn 0be8ef3 link false /test okd-scos-e2e-aws-ovn

Full PR test history. Your PR dashboard.

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.

@openshift-merge-bot openshift-merge-bot bot merged commit ccb071f into openshift:main Oct 1, 2025
18 of 19 checks passed
@openshift-ci-robot
Copy link
Contributor

@SargunNarula: Jira Issue Verification Checks: Jira Issue OCPBUGS-62605
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-62605 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

In response to this:

The GetSMTLevel util function previously used gomega assertions which could cause panics when called outside of Ginkgo It blocks.

This PR addresses:

  • Modified the GetSMTLevel signature to return (int, error)
  • Replaced ExpectWithOffset assertions with standard error handling
  • Updated all function refrences to handle the error return

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.

@openshift-merge-robot
Copy link
Contributor

Fix included in accepted release 4.21.0-0.nightly-2025-10-02-002727

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-bug Indicates that a referenced Jira bug is valid 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. verified Signifies that the PR passed pre-merge verification criteria
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants