Worker: better cleanup mechanisms (#139)

* Always Close() the Worker instance

* orchard list vms: show assigned worker for each of the VMs

* Stop the failed VMs before we schedule new VMs

To avoid violating resource constraints.

* syncOnDiskVMs: don't ignore running VMs

* Worker: show correct remote and local VM counts
This commit is contained in:
Nikolay Edigaryev
2023-09-28 19:09:43 +00:00
committed by GitHub
parent 40f58e4aee
commit 063405672f
5 changed files with 67 additions and 36 deletions
+1 -1
View File
@@ -54,10 +54,10 @@ func runDev(cmd *cobra.Command, args []string) error {
devController, devWorker, err := CreateDevControllerAndWorker(devDataDirPath,
fmt.Sprintf(":%d", netconstants.DefaultControllerPort), resources,
nil, nil)
if err != nil {
return err
}
defer devWorker.Close()
errChan := make(chan error, 2)
+2 -2
View File
@@ -40,13 +40,13 @@ func runListVMs(cmd *cobra.Command, args []string) error {
table := uitable.New()
table.AddRow("Name", "Created", "Image", "Status", "Restart policy")
table.AddRow("Name", "Created", "Image", "Status", "Restart policy", "Assigned worker")
for _, vm := range vms {
restartPolicyInfo := fmt.Sprintf("%s (%d restarts)", vm.RestartPolicy, vm.RestartCount)
createdAtInfo := humanize.RelTime(vm.CreatedAt, time.Now(), "ago", "in the future")
table.AddRow(vm.Name, createdAtInfo, vm.Image, vm.Status, restartPolicyInfo)
table.AddRow(vm.Name, createdAtInfo, vm.Image, vm.Status, restartPolicyInfo, vm.Worker)
}
fmt.Println(table)
+1
View File
@@ -105,6 +105,7 @@ func runWorker(cmd *cobra.Command, args []string) (err error) {
if err != nil {
return err
}
defer workerInstance.Close()
return workerInstance.Run(cmd.Context())
}