Skip to content

idle-workload fires on every workload that omits the replicas field #45

@Ranjithhub08

Description

@Ranjithhub08

What happened?

Running optiqor analyze on any Helm chart that does not explicitly set replicas or replicaCount produces a spurious idle-workload finding for every workload.

Reproduction steps

1. Create `values.yaml` (see chart fragment below)
2. Run `optiqor analyze ./values.yaml`
3. See `idle-workload` finding for `api` despite replicas never being set

optiqor-cli version

dev (built from source, main branch)

Install method

Built from source

OS and arch

macos

Relevant output

$ optiqor analyze ./values.yaml

────────────────────────────────────────────────────────────────────────
  ◆ optiqor   Helm chart cost optimization · security as a bonus
────────────────────────────────────────────────────────────────────────

  Source      api/values.yaml
  Workloads   1 workload analyzed
  Cost        1 optimization

  ── Cost optimizations ──────────────────────────────────────────────

  ┌─ LOW · api ────────────────────────────────────────────┐
  │                                                          │
  │  Workload declared with replicas=0 and no autoscaler    │
  │                                                          │
  │  api ships with replicas=0 and no HPA. In a live        │
  │  cluster this is the chart pattern that correlates      │
  │  with abandoned workloads — declared but never          │
  │  scheduled. If this is intentional (e.g. feature-       │
  │  flagged deployment), dismiss. Otherwise the chart       │
  │  can be slimmer: remove the workload entirely, or       │
  │  document the activation path.                          │
  │                                                          │
  │  confidence: ●○○                                        │
  └──────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────
  Sandbox accuracy: ±40%. Install the Optiqor agent for exact numbers.

Minimal chart fragment (if applicable)

api:
  resources:
    requests:
      cpu: 500m
      memory: 256Mi
    limits:
      cpu: 1000m
      memory: 512Mi
  image:
    repository: myapp
    tag: v1.2.3

Additional context

Root cause: parser.Workload.Replicas is documented as // Zero means "unset" but the detector cannot distinguish unset from explicit zero. The parser needs to use a pointer (*int) or a separate ReplicasSet bool field, OR the detector needs to guard against !w.ReplicasSet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNeeds maintainer review and labeling

    Type

    No type
    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