Skip to content

Commit 5dc791f

Browse files
authored
AGENT-1180: ABI: Set TechPreviewNoUpgrade on the target cluster (openshift-assisted#2904)
1 parent 62cfcc8 commit 5dc791f

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

libs/ui-lib/lib/common/api/assisted-service/ClustersAPI.ts

+6
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ const ClustersAPI = {
239239
params,
240240
);
241241
},
242+
243+
updateInstallConfig(clusterId: Cluster['id'], config: string) {
244+
return client.patch(`${ClustersAPI.makeBaseURI(clusterId)}/install-config`, config, {
245+
headers: { 'Content-Type': 'application/json' },
246+
});
247+
},
242248
};
243249

244250
export default ClustersAPI;

libs/ui-lib/lib/ocm/components/clusterWizard/ClusterDetails.tsx

+28-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import { useLocation, useNavigate } from 'react-router-dom-v5-compat';
33
import { useDispatch } from 'react-redux';
44
import { useAlerts, LoadingState, ClusterWizardStep, ErrorState } from '../../../common';
55
import { usePullSecret } from '../../hooks';
6-
import { getApiErrorMessage, handleApiError, isUnknownServerError } from '../../../common/api';
6+
import {
7+
ClustersAPI,
8+
getApiErrorMessage,
9+
handleApiError,
10+
isUnknownServerError,
11+
} from '../../../common/api';
712
import { setServerUpdateError, updateCluster } from '../../store/slices/current-cluster/slice';
813
import { useClusterWizardContext } from './ClusterWizardContext';
914
import { canNextClusterDetails, ClusterWizardFlowStateNew } from './wizardTransition';
@@ -18,6 +23,7 @@ import {
1823
UISettingService,
1924
} from '../../services';
2025
import { Cluster, InfraEnv } from '@openshift-assisted/types/assisted-installer-service';
26+
import { useFeature } from '../../hooks/use-feature';
2127

2228
type ClusterDetailsProps = {
2329
cluster?: Cluster;
@@ -38,6 +44,7 @@ const ClusterDetails = ({ cluster, infraEnv }: ClusterDetailsProps) => {
3844
latestVersions: versions,
3945
} = useOpenShiftVersionsContext();
4046
const location = useLocation();
47+
const isSingleClusterFeatureEnabled = useFeature('ASSISTED_INSTALLER_SINGLE_CLUSTER_FEATURE');
4148

4249
const handleClusterUpdate = React.useCallback(
4350
async (
@@ -76,6 +83,25 @@ const ClusterDetails = ({ cluster, infraEnv }: ClusterDetailsProps) => {
7683
const searchParams = new URLSearchParams(location.search);
7784
const isAssistedMigration = searchParams.get('source') === 'assisted_migration';
7885
const cluster = await ClustersService.create(params, isAssistedMigration);
86+
if (isSingleClusterFeatureEnabled) {
87+
try {
88+
await ClustersAPI.updateInstallConfig(
89+
cluster.id,
90+
JSON.stringify(JSON.stringify({ featureSet: 'TechPreviewNoUpgrade' })),
91+
);
92+
} catch (e) {
93+
handleApiError(e, () =>
94+
addAlert({
95+
title: 'Failed to update install-config',
96+
message: getApiErrorMessage(e),
97+
}),
98+
);
99+
if (isUnknownServerError(e as Error)) {
100+
dispatch(setServerUpdateError());
101+
}
102+
return;
103+
}
104+
}
79105
navigate(`../${cluster.id}`, { state: ClusterWizardFlowStateNew });
80106
await UISettingService.update(cluster.id, { addCustomManifests });
81107
//TO-DO: Assisted-Migration. Provisional code. Needs to be removed when MTV integration be finished
@@ -91,7 +117,7 @@ const ClusterDetails = ({ cluster, infraEnv }: ClusterDetailsProps) => {
91117
}
92118
}
93119
},
94-
[clearAlerts, location.search, navigate, addAlert, dispatch],
120+
[clearAlerts, location.search, navigate, addAlert, dispatch, isSingleClusterFeatureEnabled],
95121
);
96122

97123
const navigation = <ClusterWizardNavigation cluster={cluster} />;

0 commit comments

Comments
 (0)