From a8149eba6be25d475705c81a1f739ca083ea4a0f Mon Sep 17 00:00:00 2001 From: Julie Date: Tue, 24 Oct 2023 15:41:05 +0200 Subject: [PATCH 1/2] Disable removing from cluster for ISO-booted nodes --- libs/locales/lib/en/translation.json | 1 + libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/libs/locales/lib/en/translation.json b/libs/locales/lib/en/translation.json index e3e68199a4..dc83d22821 100644 --- a/libs/locales/lib/en/translation.json +++ b/libs/locales/lib/en/translation.json @@ -419,6 +419,7 @@ "ai:It is not possible to remove a host which is being installed.": "It is not possible to remove a host which is being installed.", "ai:It is not possible to remove a node from a cluster during installation.": "It is not possible to remove a node from a cluster during installation.", "ai:It is not possible to remove control plane node from an installed cluster.": "It is not possible to remove control plane node from an installed cluster.", + "ai:It is not possible to remove this node from the cluster.": "It is not possible to remove this node from the cluster.", "ai:It may take a few minutes for the join request to appear.": "It may take a few minutes for the join request to appear.", "ai:It seems the Central infrastructure management is not configured which will prevent its features to be used. Please refer to the documentation for the first time setup steps.": "It seems the Central infrastructure management is not configured which will prevent its features to be used. Please refer to the documentation for the first time setup steps.", "ai:It seems the Metal3 operator is missing configuration which will prevent it to find bare metal hosts in this namespace. Please refer to the documentation for the first time setup steps.": "It seems the Metal3 operator is missing configuration which will prevent it to find bare metal hosts in this namespace. Please refer to the documentation for the first time setup steps.", diff --git a/libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx b/libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx index 62f431fb4f..34e150134e 100644 --- a/libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx +++ b/libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx @@ -342,6 +342,10 @@ export const canUnbindAgent = ( } } + if (!agent.metadata?.labels?.hasOwnProperty(AGENT_BMH_NAME_LABEL_KEY)) { + return [false, t('ai:It is not possible to remove this node from the cluster.')]; + } + return [true, undefined]; }; From 2a184875298643936885ee439c5f8c29247455a3 Mon Sep 17 00:00:00 2001 From: Julie Date: Tue, 31 Oct 2023 17:40:31 +0100 Subject: [PATCH 2/2] Disable removing from AI-flow cluster for ISO-booted nodes --- libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx b/libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx index 34e150134e..ab2a95881a 100644 --- a/libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx +++ b/libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx @@ -301,6 +301,7 @@ export const canUnbindAgent = ( agentClusterInstalls: AgentClusterInstallK8sResource[] | undefined, agent: AgentK8sResource, t: TFunction, + infraEnv?: InfraEnvK8sResource, ): ActionCheck => { if (!agent?.spec.clusterDeploymentName?.name) { return [false, t('ai:The agent is not bound to a cluster.')]; @@ -342,7 +343,10 @@ export const canUnbindAgent = ( } } - if (!agent.metadata?.labels?.hasOwnProperty(AGENT_BMH_NAME_LABEL_KEY)) { + if ( + !agent.metadata?.labels?.hasOwnProperty(AGENT_BMH_NAME_LABEL_KEY) && + infraEnv?.spec?.clusterRef + ) { return [false, t('ai:It is not possible to remove this node from the cluster.')]; } @@ -471,7 +475,7 @@ export const useAgentsTable = ( const agent = agents.find((a) => a.metadata?.uid === host.id); if (agent) { - return canUnbindAgent(agentClusterInstalls, agent, t); + return canUnbindAgent(agentClusterInstalls, agent, t, infraEnv); } const bmh = bmhs?.find((bmh) => bmh.metadata?.uid === host.id); if (bmh) {