diff --git a/farmerbot/manager/node.v b/farmerbot/manager/node.v index 9bf20b3..83a1b9f 100644 --- a/farmerbot/manager/node.v +++ b/farmerbot/manager/node.v @@ -83,10 +83,10 @@ fn (mut n NodeManager) find_node(mut job jobs.ActionJob) ! { mut has_gpus := job.args.get_u8_default('has_gpus', 0)! gpu_vendors := job.args.get_list_default('gpu_vendors', []string{}) or { - return error("Invalid list gpu_vendors: ${err}") + return error('Invalid list gpu_vendors: ${err}') } gpu_devices := job.args.get_list_default('gpu_devices', []string{}) or { - return error("Invalid list gpu_devices: ${err}") + return error('Invalid list gpu_devices: ${err}') } certified := job.args.get_default_false('certified') public_config := job.args.get_default_false('public_config') @@ -179,7 +179,7 @@ fn (mut n NodeManager) find_node(mut job jobs.ActionJob) ! { // claim the resources until next update of the data // add a timeout (30 minutes) node.timeout_claimed_resources = time.now().add(time.minute * 30) - if dedicated { + if dedicated || has_gpus > 0 { // claim all capacity node.claim_resources(node.resources.total) } else { diff --git a/farmerbot/manager/power.v b/farmerbot/manager/power.v index dbec754..98b9eda 100644 --- a/farmerbot/manager/power.v +++ b/farmerbot/manager/power.v @@ -30,7 +30,6 @@ mut: } pub fn (mut p PowerManager) on_started() { - // power on all nodes on start of farmerbot p.logger.info("${manager.power_manager_prefix} Startup proces: powering on all nodes that are down.") p.poweron_all_nodes() } diff --git a/tests/nodemanager_test.v b/tests/nodemanager_test.v index 0c1ee84..b7a0eef 100644 --- a/tests/nodemanager_test.v +++ b/tests/nodemanager_test.v @@ -113,8 +113,11 @@ fn test_find_node_dedicated() { } // assert + ensure_no_error(&job)! ensure_result_contains_u32(&job, "nodeid", 20)! + resources_node_20 := t.farmerbot.db.get_node(20)!.resources + assert resources_node_20.used == resources_node_20.total, "All resources should be claimed when asking for a dedicated node!" } )! } @@ -255,6 +258,8 @@ fn test_find_node_with_gpu() { // assert ensure_no_error(&job)! ensure_result_contains_u32(&job, "nodeid", 8)! + resources_node_8 := t.farmerbot.db.get_node(8)!.resources + assert resources_node_8.used == resources_node_8.total, "All resources should be claimed when asking for a gpu as the whole node should be rented!" } )! }