Skip to content

Commit 464807b

Browse files
authored
Do not delete disconnected cluster/infraenv. (#3368)
Filter out disconnected clusters from list view
1 parent 33008bf commit 464807b

File tree

4 files changed

+10
-58
lines changed

4 files changed

+10
-58
lines changed

libs/types/assisted-installer-service.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export interface Cluster {
113113
* 'AddHostsCluster' for cluster that add hosts to existing OCP cluster,
114114
*
115115
*/
116-
kind: 'Cluster' | 'AddHostsCluster';
116+
kind: 'Cluster' | 'AddHostsCluster' | 'DisconnectedCluster';
117117
/**
118118
* (DEPRECATED) Please use 'controlPlaneCount' instead. Guaranteed availability of the installed cluster. 'Full' installs a Highly-Available cluster
119119
* over multiple master nodes whereas 'None' installs a full cluster over one node.

libs/ui-lib/lib/ocm/components/clusterWizard/disconnected/OptionalConfigurationsStep.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const OptionalConfigurationsStep = () => {
141141

142142
const { moveNext, moveBack, setDisconnectedInfraEnv, disconnectedInfraEnv } =
143143
useClusterWizardContext();
144-
const { addAlert } = useAlerts();
144+
const { addAlert, clearAlerts } = useAlerts();
145145
// If no pull secret is available, default the checkbox to checked so the field is expanded
146146
const [editPullSecret, setEditPullSecret] = React.useState(!pullSecret);
147147

@@ -185,6 +185,7 @@ const OptionalConfigurationsStep = () => {
185185
validateOnMount
186186
validate={validate}
187187
onSubmit={async (values) => {
188+
clearAlerts();
188189
if (!cluster?.id) {
189190
addAlert({
190191
title: t('ai:Missing cluster'),

libs/ui-lib/lib/ocm/components/clusterWizard/disconnected/ReviewStep.tsx

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,10 @@ import { Formik } from 'formik';
2828
import { useNavigate, useParams } from 'react-router-dom-v5-compat';
2929

3030
import { getOperatorSpecs } from '../../../../common/components/operators/operatorSpecs';
31-
import ClustersService from '../../../services/ClustersService';
32-
import { handleApiError, getApiErrorMessage } from '../../../../common/api';
33-
import { useAlerts } from '../../../../common/components/AlertsContextProvider';
34-
import { AlertVariant } from '@patternfly/react-core';
3531

3632
const ReviewStep = () => {
37-
const { moveBack, disconnectedInfraEnv, setDisconnectedInfraEnv } = useClusterWizardContext();
33+
const { moveBack, disconnectedInfraEnv } = useClusterWizardContext();
3834
const { clusterId } = useParams<{ clusterId: string }>();
39-
const { addAlert } = useAlerts();
4035
const opSpecs = getOperatorSpecs(() => undefined);
4136
const navigate = useNavigate();
4237

@@ -52,55 +47,10 @@ const ReviewStep = () => {
5247
footer={
5348
<ClusterWizardFooter
5449
onNext={() => {
55-
void (async () => {
56-
if (disconnectedInfraEnv?.downloadUrl) {
57-
// Open download in new tab - we need the window reference to detect when download starts
58-
const downloadWindow = window.open(disconnectedInfraEnv.downloadUrl, '_blank');
59-
60-
// Wait for the download tab to close (indicates download has started)
61-
// The tab closes automatically when browser initiates the file download
62-
if (downloadWindow) {
63-
await new Promise<void>((resolve) => {
64-
const checkClosed = setInterval(() => {
65-
if (downloadWindow.closed) {
66-
clearInterval(checkClosed);
67-
resolve();
68-
}
69-
}, 200);
70-
// Fallback timeout in case the window doesn't close (e.g., popup blocker)
71-
setTimeout(() => {
72-
clearInterval(checkClosed);
73-
resolve();
74-
}, 10000);
75-
});
76-
}
77-
}
78-
if (clusterId) {
79-
try {
80-
await ClustersService.remove(clusterId);
81-
// Remove infraEnv from wizard context after successful deregistration
82-
setDisconnectedInfraEnv(undefined);
83-
// Navigate to cluster-list only after successful deregistration
84-
navigate('/cluster-list');
85-
} catch (error) {
86-
handleApiError(error, () => {
87-
addAlert({
88-
title: 'Failed to deregister cluster',
89-
message: getApiErrorMessage(error),
90-
variant: AlertVariant.danger,
91-
});
92-
});
93-
// Error handling: continue with navigation even if deregistration fails
94-
// Still clear the context to avoid stale data
95-
setDisconnectedInfraEnv(undefined);
96-
// Navigate even on error to avoid getting stuck
97-
navigate('/cluster-list');
98-
}
99-
} else {
100-
// If there's no cluster to deregister, navigate immediately
101-
navigate('/cluster-list');
102-
}
103-
})();
50+
if (disconnectedInfraEnv?.downloadUrl) {
51+
window.open(disconnectedInfraEnv.downloadUrl, '_blank');
52+
}
53+
navigate('/cluster-list');
10454
}}
10555
onBack={moveBack}
10656
nextButtonText="Download ISO"

libs/ui-lib/lib/ocm/store/slices/clusters/selectors.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import ClusterStatus, { getClusterStatusText } from '../../../components/cluster
1717
import { RootStateDay1 } from '../../store-day1';
1818
import type { Cluster } from '@openshift-assisted/types/assisted-installer-service';
1919

20-
const selectClusters = (state: RootStateDay1) => state.clusters.data;
20+
const selectClusters = (state: RootStateDay1) =>
21+
state.clusters.data.filter((c) => c.kind !== 'DisconnectedCluster');
2122
const clustersUIState = (state: RootStateDay1) => state.clusters.uiState;
2223

2324
export const selectClustersUIState = createSelector(

0 commit comments

Comments
 (0)