Skip to content

test(drive): retry transient async cleanup contention - #2396

Closed
yxzhaao wants to merge 3 commits into
larksuite:mainfrom
yxzhaao:codex/stabilize-slides-screenshot-cleanup
Closed

test(drive): retry transient async cleanup contention#2396
yxzhaao wants to merge 3 commits into
larksuite:mainfrom
yxzhaao:codex/stabilize-slides-screenshot-cleanup

Conversation

@yxzhaao

@yxzhaao yxzhaao commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Stabilize Drive-backed E2E cleanup when concurrent deletes under the same folder make an asynchronous delete task report server_error: drive task failed.

Changes

  • Centralize the targeted retry in drive.DeleteDriveResourceAndVerify so Slides, Docs, Sheets, Base, Wiki, and Drive cleanups share one policy.
  • Verify the resource's real terminal state after each failed delete; retry only when it still exists.
  • Retry only the exact api/server_error/drive task failed envelope, with five attempts and 2s/4s/8s/8s bounded backoff.
  • Keep unrelated permission, validation, authentication, and protocol failures fatal.
  • Simplify the Slides screenshot cleanup back to a direct shared-helper call.

Impact

CLI behavior is unchanged. Live E2E teardown becomes more resilient to the backend's same-folder delete lock while preserving bounded failure behavior.

Root Cause

Live E2E jobs and Go packages run concurrently against the same test bot. Drive serializes deletes within a folder, so overlapping cleanup tasks can collide and one async task may terminate with drive task failed.

Test Plan

  • gofmt
  • git diff --check
  • go vet ./tests/cli_e2e/drive ./tests/cli_e2e/slides
  • Live E2E retry path in CI (the repository has no Docker E2E runner for a fixed local test account)

Related Issues

  • None

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when deleting drive resources by retrying temporary backend failures.
    • Added safeguards to stop retries on successful deletion, cleanup warnings, permanent failures, exhausted attempts, or canceled operations.
    • Improved presentation test cleanup for more consistent resource removal.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7df3dad4-1ae6-4c36-b750-601473f9acc9

📥 Commits

Reviewing files that changed from the base of the PR and between e0867e6 and 8489a3b.

📒 Files selected for processing (3)
  • tests/cli_e2e/drive/drive_delete_workflow_test.go
  • tests/cli_e2e/drive/helpers.go
  • tests/cli_e2e/slides/slides_screenshot_workflow_test.go

📝 Walkthrough

Walkthrough

The shared drive cleanup helper now retries recognized transient deletion-task failures with bounded exponential backoff. The slides screenshot workflow uses this helper for presentation cleanup and retains failure reporting.

Changes

Drive cleanup behavior

Layer / File(s) Summary
Transient deletion retry handling
tests/cli_e2e/drive/helpers.go
The helper adds retry and backoff limits, detects "drive task failed" JSON errors, and stops on success, warnings, cancellation, non-transient failures, or exhausted attempts.
Slides cleanup integration
tests/cli_e2e/slides/slides_screenshot_workflow_test.go
The screenshot workflow uses DeleteDriveResourceAndVerify for presentation cleanup and reports returned cleanup failures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SlidesScreenshotWorkflow
  participant DeleteDriveResourceAndVerify
  participant CLI
  participant API
  SlidesScreenshotWorkflow->>DeleteDriveResourceAndVerify: delete presentation drive resource
  DeleteDriveResourceAndVerify->>CLI: run drive deletion
  CLI->>API: execute deletion task
  API-->>CLI: return deletion result
  DeleteDriveResourceAndVerify->>DeleteDriveResourceAndVerify: retry recognized transient failures
  DeleteDriveResourceAndVerify-->>SlidesScreenshotWorkflow: return cleanup result and error
Loading

Suggested reviewers: wittam-01

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added the size/S Low-risk docs, CI, test, or chore only changes label Aug 18, 2026
@yxzhaao yxzhaao changed the title test(slides): retry transient screenshot cleanup test(drive): retry transient async cleanup contention Aug 18, 2026
@yxzhaao
yxzhaao marked this pull request as ready for review August 18, 2026 15:36
@yxzhaao yxzhaao closed this Aug 18, 2026
@yxzhaao
yxzhaao deleted the codex/stabilize-slides-screenshot-cleanup branch August 18, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Low-risk docs, CI, test, or chore only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant