Skip to content

ttl-reaper: a failed security/placement group delete is recorded as a successful region (records the nil describe error) #1211

Closed

Description

@scttfrdmn

reapSecurityGroups and reapPlacementGroups in lambda/ttl-reaper/netresources.go record the wrong error when a delete fails:

if _, derr := cli.DeleteSecurityGroup(ctx, ...); derr != nil {
    ...
    log.Printf("net-resources: %s/%s: delete security group %s: %v", acct.label, region, id, derr)
    outcome.record(err)   // err is the DescribeSecurityGroups error, already checked == nil
    continue
}

(same at the DeletePlacementGroup call, netresources.go ~252). err is always nil there, and accountOutcome.record(nil) classifies as failureNone, so it does regions++; reached++. A failed delete is therefore counted as a successful region reach, never as opErrors (so errorsToCount() / Summary.Errors stays 0) and never as denied.

Evidence

Found by golangci-lint's nilnesserr while measuring for #1028 (call function with a nil value error after check error, netresources.go:191 and :252).

Confirmed with a throwaway test against the existing fakeNetAPI (one aged SG + one aged PG, both deletes failing):

err="UnauthorizedOperation: You are not authorized to perform this operation." reaped=0 errorsToCount=0 regions=2 reached=2 denied=0 opErrors=0
err="InternalError: boom"                                                         reaped=0 errorsToCount=0 regions=2 reached=2 denied=0 opErrors=0

So a permission regression on ec2:DeleteSecurityGroup / ec2:DeletePlacementGroup (or any non-DependencyViolation / non-InUse failure) is visible only in the log line; nothing that alarms sees it, and the region/reached counters are inflated by one per failed delete.

Cost

Low. Security groups and placement groups cost nothing, so this is not a spend leak; it is a silent-failure/observability bug in the reaper. DependencyViolation and InvalidPlacementGroup.InUse are already handled before this line and are unaffected.

Not done in #1028

The obvious change is outcome.record(derr), but it is a judgement call, not a typo fix: record is otherwise called once per region scan, so per-delete calls also inflate regions, and routing a denied delete through failureDenied feeds the account-level "denied everywhere" logic (#469). The fix should decide which counter a failed delete belongs in and add a test for it (none of the existing netresources tests sets a non-tolerated sgDelErr/pgDelErr and checks errorsToCount()). nilnesserr stays off in .golangci.yml until then (docs/lint-ratchet.md).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions