Skip to content

Commit

Permalink
MGMT-15365: It's possible to attempt to delete a host from infraenv f…
Browse files Browse the repository at this point in the history
…or 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
  • Loading branch information
jgyselov authored Jan 5, 2024
1 parent 24c83af commit 0c879ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions libs/locales/lib/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
10 changes: 9 additions & 1 deletion libs/ui-lib/lib/cim/components/Agent/tableUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.')];
Expand Down Expand Up @@ -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];
};

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 0c879ac

Please sign in to comment.