mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-21 10:45:25 +02:00
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:
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user