From 0c879ac93745f7e509c867dbf5c7421b4248caca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julie=20Gyselov=C3=A1?= Date: Fri, 5 Jan 2024 15:01:53 +0100 Subject: [PATCH] MGMT-15365: It's possible to attempt to delete a host from infraenv for a standalone cluster created by integrated UI flow [BACKPORT 2.9] (#2460) * Disable removing from cluster for ISO-booted nodes * Disable removing from AI-flow cluster for ISO-booted nodes --- libs/locales/lib/en/translation.json | 1 + libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/locales/lib/en/translation.json b/libs/locales/lib/en/translation.json index 6ee511b113..e94c9c8ea7 100644 --- a/libs/locales/lib/en/translation.json +++ b/libs/locales/lib/en/translation.json @@ -430,6 +430,7 @@ "ai:It is not possible to remove a host which is being installed.": "It is not possible to remove a host that 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 might 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.": "Central Infrastructure Management is not configured, which prevents its features from being used. 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.": "The Metal3 operator is not configured correctly, which prevents it from finding bare metal hosts in this namespace. 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 2a4b1edd88..62f68b8dce 100644 --- a/libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx +++ b/libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx @@ -302,6 +302,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.')]; @@ -343,6 +344,13 @@ export const canUnbindAgent = ( } } + 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.')]; + } + return [true, undefined]; }; @@ -468,7 +476,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) {