Skip to content

[Bug]: Integer division truncation silently drops remainder VMs in multi-VM workloads #107

Description

@mrhillsman

Bug Description

In cmd/virtwork/main.go:352, multi-VM workloads distribute VMs across roles using integer division:

perRole := vmCount / len(roles)

When vmCount is not evenly divisible by the number of roles, the remainder VMs are silently dropped. For example, with vm-count=5 and 2 roles (server/client), only 4 VMs are created (2 per role) — the 5th VM vanishes with no warning, log message, or audit record.

This is particularly confusing because the audit event at line 408 reports the planned count (5), while the actual count is 4.

Steps to Reproduce

  1. Run virtwork run --workloads tps --vm-count 5
  2. TPS has 2 roles (server, client), so perRole = 5 / 2 = 2
  3. Only 4 VMs are created (2 servers + 2 clients)
  4. The deployment summary reports 4 VMs but the user requested 5

Expected Behavior

Either:

  • Return an error if vmCount is not evenly divisible by the number of roles
  • Distribute remainder VMs across roles (e.g., 3 servers + 2 clients for vm-count=5)
  • Log a warning explaining that the count was adjusted and why

Actual Behavior

The remainder is silently truncated. No warning, no error, no audit record. The user sees fewer VMs than requested with no explanation.

Command

virtwork run

Affected Files

  • cmd/virtwork/main.go:352perRole := vmCount / len(roles) truncates silently

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    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