Schedule icon
Webhook icon
Assert icon
Get icon
Script icon
Docker icon
Set icon
If icon
SlackIncomingWebhook icon
Pause icon
Log icon

S3 Abandoned Multipart Upload & Orphan Part Reclaim Guard

Audit S3 and MinIO buckets for abandoned multipart uploads, pause for approval, abort stale uploads to reclaim wasted storage, and verify cleanup with Kestra.

Categories
DataInfrastructure

Eliminate hidden cloud storage waste caused by incomplete and abandoned multipart uploads in Amazon S3, MinIO, Cloudflare R2, and Ceph object storage. When distributed engines (Spark, Flink, Kafka Connect, or batch uploaders) crash mid-write, partial chunks remain stored indefinitely under active upload IDs. Standard object listings (s3 ls) do not expose these invisible parts, resulting in stealthy storage cost growth. This blueprint audits active multipart uploads, identifies abandoned uploads exceeding staleness thresholds, pauses for operator sign-off, executes AbortMultipartUpload commands, and cryptographically proves that the orphaned uploads were purged.

How it works

  1. Input Validation: Verifies that the target bucket, staleness threshold hours (minimum 1 hour), and safety abort limits are valid.
  2. Historical State Retrieval: Pulls the previous audit snapshot from Kestra's KV store (s3_multipart_state_<bucket>) to maintain multi-run visibility.
  3. Discovery & Inspection: Runs a containerized Python script using boto3 to paginate s3.list_multipart_uploads across the bucket and prefix, inspects individual parts via s3.list_parts to tally exact byte sizes and chunk counts, and calculates upload age against stale_threshold_hours.
  4. Plan Formulation: Sorts abandoned uploads descending by wasted byte size, caps the candidate list at max_uploads_to_abort, and saves the audit snapshot into Kestra KV.
  5. Slack Plan Notification: If abandoned uploads are detected, dispatches a rich notification card to Slack detailing affected keys, upload ages, and total reclaimable megabytes.
  6. Operator Approval Gate: If pause_for_approval: true and active remediation is enabled, the flow pauses execution (io.kestra.plugin.core.flow.Pause) for human review, allowing engineers to verify candidate keys before any deletion occurs.
  7. Active Reclamation: When approved and dry_run: false, iterates through the planned candidates and calls s3.abort_multipart_upload, immediately freeing the underlying storage on AWS S3 or MinIO.
  8. Post-Remediation Verification & Assertion: Re-queries s3.list_multipart_uploads to verify that none of the targeted upload IDs remain in the bucket, asserting complete remediation.
  9. Confirmation Alerting: Dispatches a confirmation Slack card summarizing the verified freed megabytes and total aborted uploads.

What you get

  • Automated elimination of hidden cloud storage leaks without waiting for delayed S3 lifecycle rules.
  • Full visibility into invisible orphaned multipart parts, including upload IDs, keys, ages, and byte sizes.
  • Safe-by-default execution featuring dry-run simulation, bounded per-run abort limits, and human approval gates.
  • Provable post-remediation verification that re-queries S3 and asserts that target uploads are deleted.
  • Compatible with AWS S3, MinIO, Ceph, and Cloudflare R2 object stores.

Who it's for

  • FinOps Practitioners and Cloud Platform Engineers looking to reduce runaway object storage costs.
  • Data Platform Engineers running Spark, Flink, Trino, or Kafka Connect S3 sink connectors where worker crashes leave abandoned parts.
  • Site Reliability Engineers maintaining on-premise MinIO or Ceph object storage clusters with disk capacity constraints.

Why orchestrate this with Kestra

  • Closed-Loop Auto-Remediation: Replaces passive alerting scripts with a complete discover-plan-approve-remediate-verify lifecycle.
  • Native Human-in-the-Loop Approval: Uses Kestra's declarative Pause task so engineers can review the exact list of keys before parts are purged.
  • Stateful Differential Tracking: Leverages Kestra KV store to track multi-run trends and calculate cumulative storage reclaimed over time.
  • Universal S3 Compatibility: Works seamlessly with AWS S3 IAM credentials, instance profiles, or S3-compatible endpoint overrides.

Prerequisites

  • AWS credentials (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) with s3:ListBucketMultipartUploads, s3:ListMultipartUploadParts, and s3:AbortMultipartUpload permissions on the target bucket.
  • Docker container runtime enabled on the Kestra worker to run the boto3 inspection and remediation tasks.
  • Slack incoming webhook URL for notifications.

Secrets

  • AWS_ACCESS_KEY_ID: AWS access key for authenticating S3 API requests.
  • AWS_SECRET_ACCESS_KEY: AWS secret key corresponding to the access key.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL for posting reclamation plans and success confirmations.
  • S3_RECLAIM_WEBHOOK_KEY: Secret authentication key for the on-demand webhook trigger.

Quick start

  1. Configure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  2. Import this blueprint into your Kestra instance.
  3. Run a test execution with dry_run: true pointing to your target bucket to inspect current abandoned uploads and wasted storage without mutating anything.
  4. Set dry_run: false and pause_for_approval: true to execute active reclamation with human sign-off.
  5. Enable scheduled_multipart_sweep to run weekly background maintenance.

How to extend

  • Automated Lifecycle Policy Comparison: Add an upstream task to fetch s3.get_bucket_lifecycle_configuration and flag buckets that lack native AbortIncompleteMultipartUpload lifecycle rules.
  • Multi-Bucket Fan-Out: Wrap this flow in a parent orchestrator using io.kestra.plugin.core.flow.Loop to sweep every bucket across an AWS account.
  • Datadog / Prometheus Metric Emission: Emit reclaimed gigabytes as custom FinOps metrics using io.kestra.plugin.datadog or HTTP push gateways.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.