Skip to content

refactor: extract orchestration logic into internal/orchestrator#136

Merged
mrhillsman merged 5 commits into
mainfrom
refactor/123-extract-orchestrator
May 29, 2026
Merged

refactor: extract orchestration logic into internal/orchestrator#136
mrhillsman merged 5 commits into
mainfrom
refactor/123-extract-orchestrator

Conversation

@mrhillsman

Copy link
Copy Markdown
Contributor

Summary

Extracts the monolithic runE (438 lines) and cleanupE (144 lines) functions from cmd/virtwork/main.go into a testable internal/orchestrator package with injected dependencies, addressing the core ask of issue #123.

  • RunOrchestrator coordinates workload planning, dry-run output, namespace/service/secret creation, concurrent VM creation (errgroup), and readiness waiting
  • CleanupOrchestrator coordinates resource preview and deletion with audit recording
  • cmd layer reduced from 839 to 355 lines; now a thin shell for flag parsing, signal handling, auditor lifecycle, and cluster connection
  • No behavior changes, same flags, same output, same Kubernetes resources created

Resolves #123

Introduce internal/orchestrator with VMPlan, RunResult,
NamespaceDataVolumes, and skeleton RunOrchestrator/CleanupOrchestrator
structs. This is the foundation for extracting orchestration logic from
cmd/virtwork/main.go

Resolves #123

Signed-off-by: Melvin Hillsman <mhillsma@redhat.com>
Extract the full run orchestration flow from cmd/virtwork/main.go runE
into RunOrchestrator.Run(). Includes workload planning, dry-run output,
namespace/service/secret creation, concurrent VM creation via errgroup,
and readiness waiting. All phases are tested with Ginkgo BDD using fake
K8s clients and NoOpAuditor.

24 tests covering: dry-run mode, multi-workload, multi-VM, workload
filtering (enabled/disabled), unknown workload error, resource creation,
run-id labeling, config overrides, concurrent VM creation,
and DataVolume namespacing.

Resolves #123

Signed-off-by: Melvin Hillsman <mhillsma@redhat.com>
Add Preview() and Execute() methods to CleanupOrchestrator. Preview
delegates to cleanup.PreviewCleanup for resource counting. Execute
delegates to cleanup.CleanupAll and records audit data (cleanup counts,
linked run IDs, events).

6 tests covering: empty preview, managed VM counting, run-id filtering,
VM deletion, secret deletion, and audit recording.

Resolves #123

Signed-off-by: Melvin Hillsman <mhillsma@redhat.com>
Replace the 438-line runE and 144-line cleanupE monolithic functions
with thin shells that delegate to RunOrchestrator and
CleanupOrchestrator. The cmd layer now only handles flag parsing,
config loading, auditor/logger init, signal context, cluster
connection, and audit lifecycle.

main.go reduced from 839 to 355 lines (58% reduction). All
orchestration logic now lives in internal/orchestrator with full
unit test coverage.

Resolves #123

Signed-off-by: Melvin Hillsman <mhillsma@redhat.com>
Fix gci import ordering in orchestrator_test.go and golines long line
in orchestrator.go.

Resolves #123

Signed-off-by: Melvin Hillsman <mhillsma@redhat.com>
@exe-prow-github-app
exe-prow-github-app Bot requested a review from OchiengEd May 29, 2026 22:53
@exe-prow-github-app

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mrhillsman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@exe-prow-github-app exe-prow-github-app Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 29, 2026
@mrhillsman
mrhillsman merged commit d767799 into main May 29, 2026
3 of 4 checks passed
@mrhillsman
mrhillsman deleted the refactor/123-extract-orchestrator branch May 30, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tech Debt]: Extract orchestration logic from runE/cleanupE for testability

1 participant