Skip to content

Conversation

@rnetser
Copy link
Collaborator

@rnetser rnetser commented Nov 13, 2025

Short description:

Some resources overwrite wait function but did not declare the parent function's sleep arg in their signature.
This led to:

    def wait_for_condition(
        self,
        condition: str,
        status: str,
        timeout: int = 300,
        sleep_time: int = 1,
        reason: str | None = None,
        message: str = "",
    ) -> None:
        """
        Wait for Resource condition to be in desire status.

        Args:
            condition (str): Condition to query.
            status (str): Expected condition status.
            reason (None): Expected condition reason.
            message (str): Expected condition text inclusion.
            timeout (int): Time to wait for the resource.
            sleep_time(int): Interval between each retry when checking the resource's condition.

        Raises:
            TimeoutExpiredError: If Resource condition in not in desire status.
        """
        self.logger.info(f"Wait for {self.kind}/{self.name}'s '{condition}' condition to be '{status}'")

        timeout_watcher = TimeoutWatch(timeout=timeout)
>       self.wait(timeout=timeout, sleep=sleep_time)
E       TypeError: DataVolume.wait() got an unexpected keyword argument 'sleep'

More details:
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
Bug:

Summary by CodeRabbit

  • New Features
    • Added optional sleep parameter to wait methods, enabling configurable polling intervals during resource operations.

@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Walkthrough

Two OCP resource classes (DataVolume and VirtualMachineImport) now accept a configurable sleep parameter in their wait() methods, replacing hardcoded sleep values to enable tunable polling intervals.

Changes

Cohort / File(s) Summary
Wait method sleep parameter addition
ocp_resources/datavolume.py, ocp_resources/virtual_machine_import.py
Added optional sleep parameter (default=1) to wait() methods. In DataVolume, threads sleep through superclass call when wait_for_exists_only is True. In VirtualMachineImport, replaces hardcoded sleep value in TimeoutSampler with parameterized value.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify sleep parameter threading and defaults are consistent across both classes
  • Confirm no unintended side effects on existing wait logic paths

Suggested labels

size/XS, branch-main, can-be-merged

Suggested reviewers

  • dbasunag
  • jpeimer
  • myakove

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description provides a short description and includes context via a concrete error example, but lacks complete sections like 'More details' and 'What this PR does / why we need it' from the template.
Title check ✅ Passed The title accurately reflects the main change: adding the missing sleep parameter to overridden wait functions to match the parent function signature.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-sleep-wait

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@redhat-qe-bot1
Copy link

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the "
    "OWNERS file in the repository root
    "
    "* Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are "
    "automatically applied based on changes
    "
    f"* Issue Creation: A tracking issue is created for this PR and will be closed when the PR is merged or closed
    "
    "* Pre-commit Checks: pre-commit runs "
    "automatically if .pre-commit-config.yaml exists
    "
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (maintainers and approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest python-module-install - Test Python package installation
  • /retest conventional-title - Validate commit message format
  • /retest all - Run all available tests

Container Operations

  • /build-and-push-container - Build and push container image (tagged with PR number)
    • Supports additional build arguments: /build-and-push-container --build-arg KEY=value

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. LGTM Count: Minimum 0 /lgtm from reviewers
  3. Status Checks: All required status checks must pass
  4. No Blockers: No WIP, hold, or conflict labels
  5. Verified: PR must be marked as verified (if verification is enabled)

📊 Review Process

Approvers and Reviewers

Approvers:

  • myakove
  • rnetser

Reviewers:

  • dbasunag
  • myakove
  • rnetser
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is automatically removed on each new commit
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Container Builds: Container images are automatically tagged with the PR number
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@rnetser
Copy link
Collaborator Author

rnetser commented Nov 13, 2025

/verified

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
ocp_resources/datavolume.py (1)

260-260: Optional: Explicit return None is unnecessary.

The explicit return None is functionally correct but unnecessary since Python functions return None by default. While it does provide symmetry with the if branch's explicit return, it can be omitted without changing behavior.

Apply this diff if you prefer to omit the explicit return:

         self.wait_for_status(status=self.Status.SUCCEEDED, timeout=timeout)
         self.pvc.wait_for_status(status=PersistentVolumeClaim.Status.BOUND, timeout=timeout)
-        return None
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 425cadf and 99cf126.

📒 Files selected for processing (2)
  • ocp_resources/datavolume.py (1 hunks)
  • ocp_resources/virtual_machine_import.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
ocp_resources/datavolume.py (2)
ocp_resources/resource.py (3)
  • wait (897-921)
  • wait_for_status (958-1004)
  • status (1062-1072)
ocp_resources/persistent_volume_claim.py (1)
  • Status (12-13)
🔇 Additional comments (3)
ocp_resources/virtual_machine_import.py (2)

192-199: LGTM! Fixes the TypeError for sleep parameter.

The addition of the sleep=1 parameter correctly resolves the issue where callers passing sleep as a keyword argument would encounter a TypeError. The default value maintains backward compatibility with existing calls.


201-208: LGTM! Sleep parameter properly threaded through.

The sleep parameter is correctly passed to TimeoutSampler, replacing the previous hardcoded value and enabling configurable polling intervals.

ocp_resources/datavolume.py (1)

251-253: LGTM! Fixes TypeError and correctly threads sleep parameter.

The addition of the sleep=1 parameter resolves the TypeError issue, and the parameter is correctly passed to the parent's wait() method in the wait_for_exists_only path.

@rnetser rnetser changed the title Add missing arg in wait function which overwrites parent function fix: Add missing arg in wait function which overwrites parent function Nov 13, 2025
@rnetser
Copy link
Collaborator Author

rnetser commented Nov 13, 2025

/retest conventional-title

@myakove
Copy link
Collaborator

myakove commented Nov 14, 2025

/lgtm
/approve
/verified

@myakove myakove merged commit a5e2d4b into main Nov 14, 2025
7 checks passed
@myakove myakove deleted the fix-sleep-wait branch November 14, 2025 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants