Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MGMT-15365: It's possible to attempt to delete a host from infraenv for a standalone cluster created by integrated UI flow [BACKPORT 2.8] #2459

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/locales/lib/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
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 @@ -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.')];
Expand Down Expand Up @@ -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];
};

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