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..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,6 +343,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]; }; @@ -467,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) {