Skip to content

[Tech Debt]: DeleteManagedSecrets/DeleteManagedServices bail on first error, leaving partial cleanup #102

Description

@mrhillsman

Category

Error handling gaps

Description

DeleteManagedSecrets and DeleteManagedServices in internal/resources/resources.go return immediately on the first non-NotFound deletion error. This means if the third of ten secrets fails to delete, the remaining seven are never attempted. The caller receives an error for one resource but has no way to know which resources were skipped.

For cleanup operations, this is particularly problematic — a transient error on one resource abandons cleanup of all remaining resources, requiring the user to re-run cleanup to catch the rest.

Severity

Medium — increases maintenance burden or risk of future bugs

Affected Files

  • internal/resources/resources.go:70-96DeleteManagedSecrets returns on first delete error, skipping remaining secrets
  • internal/resources/resources.go:100-126DeleteManagedServices has the same early-return pattern

Proposed Fix

Collect all deletion errors using errors.Join (or a slice) and continue attempting to delete remaining resources. Return the aggregated error along with the count of successfully deleted resources. This gives the caller a complete picture and maximizes cleanup progress on each invocation.

Area

Cleanup

Architecture Layer

Layer 2 - K8s Abstractions (vm, resources, wait)

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtTechnical debt, code quality, or maintenance concern

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions