Skip to content

[Feature]: Redesign MultiVMWorkload interface to declare per-role VM counts #116

Description

@mrhillsman

Problem Statement

The MultiVMWorkload interface returns a flat VMCount() total and a list of role names via Roles(). The orchestrator in cmd/virtwork/main.go divides VMCount() / len(Roles()) to determine how many VMs each role gets. This design has two problems:

  1. Integer division truncation — if VMCount() is not evenly divisible by the number of roles, remainder VMs are silently dropped (now mitigated by a warning log added in [Bug]: Integer division truncation silently drops remainder VMs in multi-VM workloads #107).
  2. No support for asymmetric role counts — a workload that needs 1 controller and 5 workers cannot express that through the current interface. Every role gets the same count.

Current implementations (network, tps) always produce even totals (config.VMCount * 2 with 2 roles), so this works today but the interface is structurally unable to support workloads with heterogeneous role requirements.

Proposed Solution

Replace Roles() []string and the flat VMCount() with a single method that declares per-role counts:

type RoleSpec struct {
    Role    string
    VMCount int
}

type MultiVMWorkload interface {
    Workload
    RoleDistribution() []RoleSpec
    UserdataForRole(role string, namespace string) (string, error)
}

The orchestrator would iterate RoleDistribution() directly instead of dividing. VMCount() on the base Workload interface would sum the role counts (or be removed from MultiVMWorkload if redundant).

Migration path

  • Update MultiVMWorkload interface with RoleDistribution() []RoleSpec
  • Update NetworkWorkload and TPSWorkload to return []RoleSpec{{Role: "server", VMCount: N}, {Role: "client", VMCount: N}}
  • Update orchestrator loop in cmd/virtwork/main.go to use RoleDistribution() instead of VMCount() / len(Roles())
  • Remove the truncation warning added in [Bug]: Integer division truncation silently drops remainder VMs in multi-VM workloads #107 (no longer needed)
  • Update tests

Alternatives Considered

Area

  • Workloads
  • VM provisioning

Architecture Layer

  • Layer 3 - Workload Definitions (workloads, registry)
  • Layer 4 - Orchestration (cmd, cleanup)

Additional Context

Related: #107 (added truncation warning as interim fix)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.size/LDenotes a PR that changes 100-499 lines, ignoring generated files.

    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