From d5e1f854dbb0c2463dcb8b79b86959b79128394d Mon Sep 17 00:00:00 2001 From: Artem Chernyshev Date: Mon, 13 Jan 2025 15:11:28 +0300 Subject: [PATCH] fix: do not allow using static infra providers in the machine classes Auto-provision mode should be disabled for them. This change has two parts: 1. Filter the static providers in the UI. 2. Block creating machine classes which reference infra provider with the `is-static-infra-provider` label set. Signed-off-by: Artem Chernyshev --- client/pkg/omni/resources/omni/labels.go | 1 + frontend/src/api/resources.ts | 1 + .../views/omni/MachineClasses/ProviderConfig.vue | 11 +++++++++-- .../backend/runtime/omni/state_validation.go | 4 ++++ .../runtime/omni/state_validation_test.go | 16 ++++++++++++++++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/client/pkg/omni/resources/omni/labels.go b/client/pkg/omni/resources/omni/labels.go index 8c41b3e59..6a3fa79b4 100644 --- a/client/pkg/omni/resources/omni/labels.go +++ b/client/pkg/omni/resources/omni/labels.go @@ -60,6 +60,7 @@ const ( // LabelIsStaticInfraProvider is set on the infra.ProviderStatus resources to mark them as static providers - they do not work with MachineRequests to // allocate and de-allocate machines, but rather work with a static set of machines (e.g., bare-metal machines). + // tsgen:LabelIsStaticInfraProvider LabelIsStaticInfraProvider = SystemLabelPrefix + "is-static-infra-provider" // LabelMachineClassName is the name of the machine class. diff --git a/frontend/src/api/resources.ts b/frontend/src/api/resources.ts index 2c6a41e79..4c3aa0937 100644 --- a/frontend/src/api/resources.ts +++ b/frontend/src/api/resources.ts @@ -126,6 +126,7 @@ export const LabelMachine = "omni.sidero.dev/machine"; export const LabelSystemPatch = "omni.sidero.dev/system-patch"; export const LabelExposedServiceAlias = "omni.sidero.dev/exposed-service-alias"; export const LabelInfraProviderID = "omni.sidero.dev/infra-provider-id"; +export const LabelIsStaticInfraProvider = "omni.sidero.dev/is-static-infra-provider"; export const LabelMachineRequest = "omni.sidero.dev/machine-request"; export const LabelMachineRequestSet = "omni.sidero.dev/machine-request-set"; export const LabelNoManualAllocation = "omni.sidero.dev/no-manual-allocation"; diff --git a/frontend/src/views/omni/MachineClasses/ProviderConfig.vue b/frontend/src/views/omni/MachineClasses/ProviderConfig.vue index 91dfb5ee8..110b6a6e4 100644 --- a/frontend/src/views/omni/MachineClasses/ProviderConfig.vue +++ b/frontend/src/views/omni/MachineClasses/ProviderConfig.vue @@ -6,7 +6,7 @@ included in the LICENSE file. -->