Skip to content

spawn launch --ttl 1d writes spawn:ttl=1d with no spawn:ttl-deadline, so neither spored nor the reaper enforces the TTL #990

Closed

Description

@scttfrdmn

Found while auditing writers of spawn:ttl for #983. I read the code and did not reproduce this live.

buildTags (pkg/aws/tags.go) writes spawn:ttl from config.TTL unconditionally, then writes spawn:ttl-deadline only if time.ParseDuration(config.TTL) succeeds:

tags = append(tags, types.Tag{Key: aws.String("spawn:ttl"), Value: aws.String(config.TTL)})
if d, err := time.ParseDuration(config.TTL); err == nil {
    deadline := ...
    tags = append(tags, types.Tag{Key: aws.String("spawn:ttl-deadline"), ...})
}

time.ParseDuration has no d unit. --ttl is not validated at launch (cmd/launch_config.go only sets config.TTL = ttl; its ParseDuration there only gates the ceiling warning). Other spawn surfaces accept days: --fsx-ttl documents 7d, validateTTL in cmd/extend.go accepts 1d, and parseDuration/config.ParseDurationE in cmd parse it.

So spawn launch ... --ttl 1d would:

  • tag spawn:ttl=1d and no deadline;
  • spored: pkg/provider/ec2.go parses spawn:ttl with time.ParseDuration, fails, leaves config.TTL=0, so no TTL is enforced on the instance;
  • reaper: no spawn:ttl-deadline, so only the REAPER_MAX_AGE ceiling (7d default) bounds it.

The user asked for 1 day and gets up to 7 days.

Suggested fix: parse --ttl once at launch with the same parser everything else uses (or reject what cannot be parsed), and fail the launch rather than tag a TTL without a deadline. TestEveryTTLTagWriterAlsoWritesTheDeadline (#983) checks that buildTags writes both tags somewhere in the function. It cannot see that one of the writes is conditional, so it does not catch this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions