Skip to content

tests: make cleanup.sh more robust for Stratis pools#388

Merged
bmr-cymru merged 1 commit intomainfrom
bmr-stratis-cleanup-harder
Aug 21, 2025
Merged

tests: make cleanup.sh more robust for Stratis pools#388
bmr-cymru merged 1 commit intomainfrom
bmr-stratis-cleanup-harder

Conversation

@bmr-cymru
Copy link
Copy Markdown
Contributor

@bmr-cymru bmr-cymru commented Aug 20, 2025

If a stratis cleanup command fails, report the stdout/stderr, and separate pool cleanup from file system cleanup (if all file systems have been destroyed, /dev/stratis/$pool no longer exists, but the pool is still tracked by Stratis and needs to be destroyed separately).

Resolves: #387

Summary by CodeRabbit

  • Tests
    • Improved cleanup script to capture and surface detailed error output when filesystem or pool teardown fails, replacing silent failures with informative messages.
    • Pool destruction is now attempted only if the pool is detected, avoiding unnecessary operations.
    • Enhances reliability and clarity of test teardown logs for easier diagnosis in CI and local runs.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 20, 2025

Walkthrough

Capture and print stdout/stderr when stratis filesystem or pool destroy fails; stop unconditional pool destroy tied to /dev presence and instead check stratis pool list for pool existence before attempting pool destruction.

Changes

Cohort / File(s) Summary
Stratis cleanup robustness
tests/bin/cleanup.sh
Capture stderr/stdout from stratis ... destroy into a FAIL variable and print formatted error messages on failure; remove unconditional pool destroy inside /dev check; add conditional pool existence check (`stratis pool list

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Tester
    participant Script as tests/bin/cleanup.sh
    participant Stratis as stratis CLI

    Tester->>Script: run cleanup.sh
    loop each filesystem in pool1
        Script->>Stratis: filesystem destroy pool1 <FS>
        alt failure (captured FAIL)
            Stratis-->>Script: stderr/stdout
            Script-->>Tester: "Failed to clean up pool1 <FS>: <FAIL>"
        else success
            Stratis-->>Script: success
        end
    end

    Script->>Stratis: pool list
    alt pool1 present
        Script->>Stratis: pool destroy pool1
        alt failure (captured FAIL)
            Stratis-->>Script: stderr/stdout
            Script-->>Tester: "Failed to clean up pool1: <FAIL>"
        else success
            Stratis-->>Script: success
        end
    else pool1 absent
        Script-->>Tester: skip pool destroy
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Report stdout/stderr when cleanup commands fail (#387)
Separate filesystem cleanup from pool cleanup; handle pool tracked even if /dev path missing (#387)
Destroy pool only if it exists per stratis state (#387)

"I hop through scripts with tidy paws,
capturing errs and logging flaws.
Filesystems fall, the pool I check,
no silent fails — I print the speck.
Carrots saved, cleanup applause. 🥕🐇"

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e2b1556 and e75db25.

📒 Files selected for processing (1)
  • tests/bin/cleanup.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/bin/cleanup.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: python-basic-tests
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bmr-stratis-cleanup-harder

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@packit-as-a-service
Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/snapshotmanager-snapm-388
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

Copy link
Copy Markdown

@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: 0

🧹 Nitpick comments (2)
tests/bin/cleanup.sh (2)

26-26: Quote variables and use printf for robust, readable error reporting.

Safer when filesystem names or messages contain spaces/newlines; avoids word-splitting and globbing in echo. Prefer a clear if-not pattern.

-	    FAIL=$(stratis filesystem destroy pool1 $FS 2>&1) || echo Failed to clean up pool1 $FS: $FAIL
+	    if ! FAIL=$(stratis filesystem destroy pool1 "$FS" 2>&1); then
+	        printf 'Failed to clean up pool1 %s: %s\n' "$FS" "$FAIL"
+	    fi

Note: The if var=$(cmd) idiom tests the command’s exit status (not the assignment) per POSIX; this change is semantically equivalent but clearer. (unix.stackexchange.com)


30-31: Exact-match the pool name and harden error reporting.

Avoid substring matches (e.g., pool12) and keep the clearer if-not pattern with quotes/printf.

-if stratis pool | grep pool1 > /dev/null; then
-	FAIL=$(stratis pool destroy pool1 2>&1) || echo Failed to clean up pool1: $FAIL
+if stratis pool list | grep -qE '^pool1([[:space:]]|$)'; then
+	if ! FAIL=$(stratis pool destroy pool1 2>&1); then
+		printf 'Failed to clean up pool1: %s\n' "$FAIL"
+	fi

This uses an anchored, word-safe match and prevents echo/globbing pitfalls by quoting and using printf.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 45738e4 and a3ee69c.

📒 Files selected for processing (1)
  • tests/bin/cleanup.sh (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (22)
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: python-basic-tests
🔇 Additional comments (1)
tests/bin/cleanup.sh (1)

30-31: Nice separation of filesystem vs. pool cleanup.

Splitting pool destruction out of the /dev/stratis existence check directly addresses #387’s edge case and improves robustness.

@bmr-cymru
Copy link
Copy Markdown
Contributor Author

N.B.: cleanup.sh is provided only for manual cleanup during test development (which may leave artefacts behind, depending on the failure mode). During CI the tests are expected to clean up after themselves and the emergency cleanup script is not required.

@bmr-cymru bmr-cymru force-pushed the bmr-stratis-cleanup-harder branch from a3ee69c to e2b1556 Compare August 20, 2025 21:21
Comment thread tests/bin/cleanup.sh
Comment thread tests/bin/cleanup.sh
If a stratis cleanup command fails, report the stdout/stderr, and
separate pool cleanup from file system cleanup (if all file systems have
been destroyed, /dev/stratis/$pool no longer exists, but the pool is
still tracked by Stratis and needs to be destroyed separately).

Resolves: #387
@bmr-cymru bmr-cymru force-pushed the bmr-stratis-cleanup-harder branch from e2b1556 to e75db25 Compare August 20, 2025 21:33
@bmr-cymru bmr-cymru merged commit e75db25 into main Aug 21, 2025
17 of 18 checks passed
@bmr-cymru bmr-cymru deleted the bmr-stratis-cleanup-harder branch August 21, 2025 20:18
@coderabbitai coderabbitai Bot mentioned this pull request Oct 28, 2025
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.

tests: make cleanup.sh more robust for Stratis pools

1 participant