forked from openshift-assisted/assisted-installer-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeatureStateUtils.ts
363 lines (340 loc) · 12.2 KB
/
featureStateUtils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
import {
ActiveFeatureConfiguration,
architectureData,
CpuArchitecture,
FeatureId,
isSNO,
OperatorsValues,
SupportedCpuArchitecture,
} from '../../../common';
import {
Cluster,
PlatformType,
SupportLevel,
} from '@openshift-assisted/types/assisted-installer-service';
import { ExternalPlatformLabels } from '../clusterConfiguration/platformIntegration/constants';
const CNV_OPERATOR_LABEL = 'Openshift Virtualization';
const LVMS_OPERATOR_LABEL = 'Logical Volume Manager Storage';
const LVM_OPERATOR_LABEL = 'Logical Volume Manager';
const ODF_OPERATOR_LABEL = 'OpenShift Data Foundation';
const OPENSHIFT_AI_OPERATOR_LABEL = 'OpenShift AI';
const MTV_OPERATOR_LABEL = 'Migration Toolkit for Virtualization';
const OSC_OPERATOR_LABEL = 'OpenShift sandboxed containers';
export const clusterExistsReason = 'This option is not editable after the draft cluster is created';
export const getCnvIncompatibleWithLvmReason = (
operatorValues: OperatorsValues,
lvmSupport: SupportLevel | undefined,
) => {
const mustDisableCnv =
!operatorValues.useContainerNativeVirtualization &&
operatorValues.useOdfLogicalVolumeManager &&
lvmSupport !== 'supported';
// In versions with none or limited support for LVM (< 4.12), it's not possible to select CNV + LVM
return mustDisableCnv
? `Currently, you cannot install ${CNV_OPERATOR_LABEL} operator at the same time as ${LVM_OPERATOR_LABEL} operator.`
: undefined;
};
export const getLvmIncompatibleWithCnvReason = (
operatorValues: OperatorsValues,
lvmSupport: SupportLevel | undefined,
) => {
const hasSelectedCnv = operatorValues.useContainerNativeVirtualization;
// In versions with none or limited support for LVM (< 4.12), it's not possible to select CNV + LVM
if (hasSelectedCnv && lvmSupport !== 'supported') {
return `Currently, you cannot install ${LVM_OPERATOR_LABEL} operator at the same time as ${CNV_OPERATOR_LABEL} operator.`;
}
return undefined;
};
const getSNODisabledReason = (cluster: Cluster | undefined, isSupported: boolean) => {
if (cluster) {
return clusterExistsReason;
}
if (!isSupported) {
return 'Single-Node OpenShift is not supported in this OpenShift version';
}
return '';
};
const getArmDisabledReason = (cluster: Cluster | undefined) => {
if (cluster) {
return clusterExistsReason;
} else return 'arm64 is not supported in this OpenShift version';
};
const getOdfDisabledReason = (
cluster: Cluster | undefined,
activeFeatureConfiguration: ActiveFeatureConfiguration | undefined,
isSupported: boolean,
) => {
if (!cluster) {
return undefined;
}
const isArm = activeFeatureConfiguration?.underlyingCpuArchitecture === CpuArchitecture.ARM;
if (isArm && isSNO(cluster)) {
return `${ODF_OPERATOR_LABEL} is not available when using Single Node OpenShift or ARM CPU architecture.`;
}
if (isArm) {
return `${ODF_OPERATOR_LABEL} is not available when ARM CPU architecture is selected.`;
}
if (isSNO(cluster)) {
return `${ODF_OPERATOR_LABEL} is not available when deploying a Single Node OpenShift.`;
}
if (!isSupported) {
return `The installer cannot currently enable ${ODF_OPERATOR_LABEL} with the selected OpenShift version, but it can be enabled later through the OpenShift Console once the installation is complete.`;
}
return undefined;
};
const getCnvDisabledReason = (
activeFeatureConfiguration: ActiveFeatureConfiguration,
isSupported: boolean,
platformType?: PlatformType,
) => {
if (!activeFeatureConfiguration) {
return undefined;
}
if (platformType === 'nutanix') {
return `${CNV_OPERATOR_LABEL} is not available when Nutanix platform type is selected.`;
}
if (!isSupported) {
const cpuArchitectureLabel =
architectureData[
activeFeatureConfiguration.underlyingCpuArchitecture as SupportedCpuArchitecture
].label;
return `${CNV_OPERATOR_LABEL} is not available when ${
cpuArchitectureLabel
? cpuArchitectureLabel
: activeFeatureConfiguration.underlyingCpuArchitecture
} CPU architecture is selected.`;
} else {
return undefined;
}
};
const getLvmDisabledReason = (
activeFeatureConfiguration: ActiveFeatureConfiguration,
isSupported: boolean,
platformType?: PlatformType,
) => {
if (!activeFeatureConfiguration) {
return undefined;
}
const operatorLabel = isSupported ? LVMS_OPERATOR_LABEL : LVM_OPERATOR_LABEL;
if (platformType === 'nutanix') {
return `${operatorLabel} is not supported when Nutanix platform type is selected.`;
}
if (!isSupported) {
return `${operatorLabel} is not supported in this OpenShift version.`;
}
return undefined;
};
const getOscDisabledReason = (
cluster: Cluster | undefined,
activeFeatureConfiguration: ActiveFeatureConfiguration | undefined,
isSupported: boolean,
) => {
if (!cluster) {
return undefined;
}
if (!isSupported) {
return `${OSC_OPERATOR_LABEL} is not supported in this OpenShift version.`;
}
return undefined;
};
const getNetworkTypeSelectionDisabledReason = (cluster: Cluster | undefined) => {
if (!cluster) {
return undefined;
}
if (isSNO(cluster)) {
return 'Network management selection is not supported for Single-Node OpenShift';
}
return undefined;
};
const getOciDisabledReason = (cpuArchitecture: string | undefined, isSupported: boolean) => {
if (!isSupported) {
if (cpuArchitecture === CpuArchitecture.s390x || cpuArchitecture === CpuArchitecture.ppc64le) {
return `Integration with Oracle is not available with the selected CPU architecture.`;
} else {
return 'Integration with Oracle is available for OpenShift 4.14 and later versions.';
}
}
};
export const getNewFeatureDisabledReason = (
featureId: FeatureId,
cluster: Cluster | undefined,
activeFeatureConfiguration: ActiveFeatureConfiguration,
isSupported: boolean,
cpuArchitecture?: SupportedCpuArchitecture,
platformType?: PlatformType,
): string | undefined => {
switch (featureId) {
case 'SNO': {
return getSNODisabledReason(cluster, isSupported);
}
case 'ARM64_ARCHITECTURE': {
return getArmDisabledReason(cluster);
}
case 'CNV': {
return getCnvDisabledReason(
activeFeatureConfiguration,
isSupported,
platformType ?? cluster?.platform?.type,
);
}
case 'LVM': {
return getLvmDisabledReason(
activeFeatureConfiguration,
isSupported,
platformType ?? cluster?.platform?.type,
);
}
case 'ODF': {
return getOdfDisabledReason(cluster, activeFeatureConfiguration, isSupported);
}
case 'OPENSHIFT_AI': {
return getOpenShiftAIDisabledReason(cluster, activeFeatureConfiguration, isSupported);
}
case 'OSC': {
return getOscDisabledReason(cluster, activeFeatureConfiguration, isSupported);
}
case 'NETWORK_TYPE_SELECTION': {
return getNetworkTypeSelectionDisabledReason(cluster);
}
case 'CLUSTER_MANAGED_NETWORKING': {
return `Cluster-managed networking is not supported when using ${
platformType ? ExternalPlatformLabels[platformType] : ''
}`;
}
case 'EXTERNAL_PLATFORM_OCI': {
return getOciDisabledReason(cpuArchitecture, isSupported);
}
case 'MCE': {
if (platformType === 'nutanix') {
return 'Multicluster engine is not supported with Nutanix platform type.';
}
if (!isSupported) {
return 'Multicluster engine is not supported in this OpenShift version.';
}
}
case 'NUTANIX_INTEGRATION': {
if (!isSupported) {
return `Integration with Nutanix is not available with the selected CPU architecture.`;
}
}
case 'VSPHERE_INTEGRATION': {
if (!isSupported) {
return `Integration with vSphere is not available with the selected CPU architecture.`;
}
}
case 'USER_MANAGED_NETWORKING': {
if (!isSupported) {
return `User-Managed Networking is not supported when using ${
platformType ? ExternalPlatformLabels[platformType] : ''
}`;
}
}
case 'MTV': {
if (!isSupported) {
return 'Migration Toolkit for Virtualization is not supported in this OpenShift version';
}
}
case 'AUTHORINO': {
if (!isSupported) {
return `Authorino is not available with the selected CPU architecture.`;
}
}
case 'LSO': {
if (!isSupported) {
return `Lso is not available with the selected CPU architecture.`;
}
}
case 'NMSTATE': {
if (!isSupported) {
return `Nmstate is not available with the selected CPU architecture.`;
}
}
case 'NODE_FEATURE_DISCOVERY': {
if (!isSupported) {
return `Node Feature Discovery is not available with the selected CPU architecture.`;
}
}
case 'NVIDIA_GPU': {
if (!isSupported) {
return `NVIDIA GPU is not available with the selected CPU architecture.`;
}
}
case 'PIPELINES': {
if (!isSupported) {
return `Pipelines is not available with the selected CPU architecture.`;
}
}
case 'SERVERLESS': {
if (!isSupported) {
return `Serverless is not available with the selected CPU architecture.`;
}
}
case 'SERVICEMESH': {
if (!isSupported) {
return `Service mesh is not available with the selected CPU architecture.`;
}
}
case 'AMD_GPU': {
if (!isSupported) {
return `AMD GPU is not available with the selected CPU architecture.`;
}
}
default: {
return undefined;
}
}
};
export const isFeatureSupportedAndAvailable = (supportLevel: SupportLevel | undefined): boolean => {
return supportLevel !== 'unsupported' && supportLevel !== 'unavailable';
};
export const hostsNetworkConfigurationDisabledReason =
"DHCP only is the supported hosts' network configuration when external partner integrations is selected";
export const getOdfIncompatibleWithLvmsReason = (operatorValues: OperatorsValues) => {
const mustDisableOdf = operatorValues.useOdfLogicalVolumeManager;
// In versions >= 4.15, it's not possible to select ODF + LVMS
return mustDisableOdf
? `Currently, you cannot install ${ODF_OPERATOR_LABEL} operator at the same time as ${LVMS_OPERATOR_LABEL} operator.`
: undefined;
};
export const getOpenShiftAIIncompatibleWithLvmsReason = (operatorValues: OperatorsValues) => {
// Currently OpenShift AI requires ODF, and that is incompatible with LVM.
const mustDisableOpenShiftAI = operatorValues.useOdfLogicalVolumeManager;
return mustDisableOpenShiftAI
? `Currently the ${OPENSHIFT_AI_OPERATOR_LABEL} requires ${ODF_OPERATOR_LABEL}, and you cannot install that at the same time as ${LVMS_OPERATOR_LABEL} operator.`
: undefined;
};
export const getLvmsIncompatibleWithOdfReason = (operatorValues: OperatorsValues) => {
const mustDisableLvms = operatorValues.useOpenShiftDataFoundation;
// In versions >= 4.15, it's not possible to select ODF + LVMS
return mustDisableLvms
? `Currently, you cannot install ${LVMS_OPERATOR_LABEL} operator at the same time as ${ODF_OPERATOR_LABEL} operator.`
: undefined;
};
const getOpenShiftAIDisabledReason = (
cluster: Cluster | undefined,
activeFeatureConfiguration: ActiveFeatureConfiguration | undefined,
isSupported: boolean,
) => {
if (!cluster) {
return undefined;
}
const isArm = activeFeatureConfiguration?.underlyingCpuArchitecture === CpuArchitecture.ARM;
if (isArm) {
return `${OPENSHIFT_AI_OPERATOR_LABEL} is not available when ARM CPU architecture is selected.`;
}
if (isSNO(cluster)) {
return `${OPENSHIFT_AI_OPERATOR_LABEL} is not available when deploying a Single Node OpenShift.`;
}
if (!isSupported) {
return `The installer cannot currently enable ${OPENSHIFT_AI_OPERATOR_LABEL} with the selected OpenShift version, but it can be enabled later through the OpenShift Console once the installation is complete.`;
}
return undefined;
};
export const getCnvDisabledWithMtvReason = (operatorValues: OperatorsValues) => {
const mustDisableCnv =
operatorValues.useContainerNativeVirtualization &&
!operatorValues.useMigrationToolkitforVirtualization;
return mustDisableCnv
? `Currently, you need to install ${CNV_OPERATOR_LABEL} operator at the same time as ${MTV_OPERATOR_LABEL} operator.`
: undefined;
};