From 4109996e5639b9823d3d18b4e9f5b4bb8a323c8e Mon Sep 17 00:00:00 2001 From: Artem Chernyshev Date: Tue, 18 Jun 2024 20:05:31 +0300 Subject: [PATCH] fix: make `MachineSetNode` controller select only connected machines Filter them in the same way as in manual allocation: available, connected and reporting events. Signed-off-by: Artem Chernyshev --- .../omni/controllers/omni/machine_set_node.go | 6 ++++ .../controllers/omni/machine_set_node_test.go | 36 ++++++++++++------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/internal/backend/runtime/omni/controllers/omni/machine_set_node.go b/internal/backend/runtime/omni/controllers/omni/machine_set_node.go index 671b64aa..0c4a3f7b 100644 --- a/internal/backend/runtime/omni/controllers/omni/machine_set_node.go +++ b/internal/backend/runtime/omni/controllers/omni/machine_set_node.go @@ -269,6 +269,12 @@ func (ctrl *MachineSetNodeController) createNodes( selector.Terms = append(selector.Terms, resource.LabelTerm{ Key: omni.MachineStatusLabelAvailable, Op: resource.LabelOpExists, + }, resource.LabelTerm{ + Key: omni.MachineStatusLabelConnected, + Op: resource.LabelOpExists, + }, resource.LabelTerm{ + Key: omni.MachineStatusLabelReportingEvents, + Op: resource.LabelOpExists, }) availableMachineClassMachines := allMachineStatuses.FilterLabelQuery(resource.RawLabelQuery(selector)) diff --git a/internal/backend/runtime/omni/controllers/omni/machine_set_node_test.go b/internal/backend/runtime/omni/controllers/omni/machine_set_node_test.go index aa5c77b8..9026c22a 100644 --- a/internal/backend/runtime/omni/controllers/omni/machine_set_node_test.go +++ b/internal/backend/runtime/omni/controllers/omni/machine_set_node_test.go @@ -82,18 +82,24 @@ func (suite *MachineSetNodeSuite) TestReconcile() { machines := suite.createMachines( map[string]string{ - omni.MachineStatusLabelArch: "amd64", - omni.MachineStatusLabelAvailable: "", + omni.MachineStatusLabelArch: "amd64", + omni.MachineStatusLabelAvailable: "", + omni.MachineStatusLabelConnected: "", + omni.MachineStatusLabelReportingEvents: "", }, map[string]string{ - omni.MachineStatusLabelAvailable: "", - omni.MachineStatusLabelArch: "amd64", + omni.MachineStatusLabelAvailable: "", + omni.MachineStatusLabelArch: "amd64", + omni.MachineStatusLabelConnected: "", + omni.MachineStatusLabelReportingEvents: "", }, map[string]string{}, map[string]string{ - omni.MachineStatusLabelCPU: "AMD", - omni.MachineStatusLabelAvailable: "", - "userlabel": "value", + omni.MachineStatusLabelCPU: "AMD", + omni.MachineStatusLabelAvailable: "", + "userlabel": "value", + omni.MachineStatusLabelConnected: "", + omni.MachineStatusLabelReportingEvents: "", }, ) @@ -186,15 +192,21 @@ func (suite *MachineSetNodeSuite) TestReconcile() { // add more machines and wait for the controller to scale up machines = append(machines, suite.createMachines( map[string]string{ - omni.MachineStatusLabelCPU: "AMD", - omni.MachineStatusLabelAvailable: "", + omni.MachineStatusLabelCPU: "AMD", + omni.MachineStatusLabelAvailable: "", + omni.MachineStatusLabelConnected: "", + omni.MachineStatusLabelReportingEvents: "", }, map[string]string{ - omni.MachineStatusLabelCPU: "AMD", + omni.MachineStatusLabelCPU: "AMD", + omni.MachineStatusLabelConnected: "", + omni.MachineStatusLabelReportingEvents: "", }, map[string]string{ - omni.MachineStatusLabelCPU: "AMD", - omni.MachineStatusLabelAvailable: "", + omni.MachineStatusLabelCPU: "AMD", + omni.MachineStatusLabelAvailable: "", + omni.MachineStatusLabelConnected: "", + omni.MachineStatusLabelReportingEvents: "", }, )...)