Skip to content

[Tech Debt]: tps file-size parser silently falls back to 10M default on parse failure #71

Description

@mrhillsman

Category

Error handling gaps

Description

internal/workloads/tps.go parses the file-size parameter via two helpers — fileSizeBytes() and fileSizeMBCount() — that accept only the form <int><K|M|G>. A value like 1.5G, 2GB, 10MiB, or garbage:

  • Returns the fallback 10485760 bytes / "10" MB silently, with no log message or audit event
  • The user gets a 10MB test file regardless of what they specified

The parser also reads only the final character as the unit suffix, so anything beyond a single suffix character is interpreted incorrectly.

Severity

Low — cosmetic or minor inconvenience

Affected Files

  • internal/workloads/tps.gofileSize(), fileSizeBytes(), fileSizeMBCount()
  • internal/workloads/tps_test.go — coverage for malformed input
  • docs/configuration.md — note the supported format explicitly

Proposed Fix

Two-part:

  1. Document the supported format in docs/configuration.md and docs/chaos-workloads.md: ^[0-9]+[KMG]$ (integer followed by a single unit suffix).
  2. Surface parse errors rather than silently substituting. Either:
    • Bubble the error up through CloudInitUserdata() so the orchestrator fails fast at workload-build time (preferred), or
    • Emit a warning via internal/logging and proceed with the default.

Add tests for both well-formed and malformed inputs.

Area

Workloads

Architecture Layer

Layer 3 - Workload Definitions (workloads, registry)

Metadata

Metadata

Assignees

No one assigned

    Labels

    size/SDenotes a PR that changes 10-29 lines, ignoring generated files.tech-debtTechnical debt, code quality, or maintenance concerntriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions