refactor: extract orchestration logic into internal/orchestrator#136
Merged
Conversation
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>
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extracts the monolithic
runE(438 lines) andcleanupE(144 lines) functions fromcmd/virtwork/main.gointo a testableinternal/orchestratorpackage with injected dependencies, addressing the core ask of issue #123.RunOrchestratorcoordinates workload planning, dry-run output, namespace/service/secret creation, concurrent VM creation (errgroup), and readiness waitingCleanupOrchestratorcoordinates resource preview and deletion with audit recordingResolves #123