Skip to content
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
6 changes: 3 additions & 3 deletions libs/ui-lib-tests/cypress/support/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const { day2FlowIds } = fixtures;

const allInfraEnvsApiPath = '/api/assisted-install/v2/infra-envs/';
const allClustersApiPath = '/api/assisted-install/v2/clusters/';
const allOperatorsApiPath = '/api/assisted-install/v2/operators/';

const x86 = 'x86_64';
const arm = 'arm64';
Expand Down Expand Up @@ -146,7 +145,6 @@ const mockUISettingsResponse: HttpRequestInterceptor = (req) => {

const mockBundlesResponse: HttpRequestInterceptor = (req) => {
const fixtureMapping = getScenarioFixtureMapping();
console.log(fixtureMapping);
req.reply(fixtureMapping?.bundles || []);
};

Expand Down Expand Up @@ -436,7 +434,9 @@ const addAdditionalIntercepts = () => {
cy.intercept('GET', '/api/accounts_mgmt/v1/current_account', (req) => {
req.reply(fixtures.ocmUserAccount);
});
cy.intercept('GET', `${allOperatorsApiPath}/bundles`, mockBundlesResponse).as('bundles');
cy.intercept('GET', '/api/assisted-install/v2/operators/bundles*', mockBundlesResponse).as(
'bundles',
);
cy.intercept('GET', '/api/assisted-install/v2/supported-operators', mockSupportedOperators).as(
'supported-operators',
);
Expand Down
17 changes: 15 additions & 2 deletions libs/ui-lib/lib/common/api/assisted-service/BundleAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@ const BundleAPI = {
return `/v2/operators/bundles`;
},

list() {
return client.get<Bundle[]>(`${BundleAPI.makeBaseURI()}`);
list(
openshiftVersion?: string,
cpuArchitecture?: string,
platformType?: string,
featureIds?: string,
) {
return client.get<Bundle[]>(`${BundleAPI.makeBaseURI()}`, {
params: {
openshift_version: openshiftVersion,
cpu_architecture: cpuArchitecture,
platform_type: platformType,
feature_ids: featureIds,
...(platformType === 'external' ? { external_platform_name: 'oci' } : {}),
},
});
},

listOperatorsForBundle(bundleName: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import * as React from 'react';
import { List, ListItem } from '@patternfly/react-core';

export type BundleSpec = {
noSNO?: boolean;
incompatibleBundles?: string[];
Description: React.ComponentType;
docsLink?: string;
};

export const bundleSpecs: { [key: string]: BundleSpec } = {
virtualization: {
noSNO: true,
Description: () => (
<List>
<ListItem>
Expand All @@ -29,7 +27,6 @@ export const bundleSpecs: { [key: string]: BundleSpec } = {
),
},
'openshift-ai': {
noSNO: true,
incompatibleBundles: [],
Description: () => (
<List>
Expand Down
10 changes: 7 additions & 3 deletions libs/ui-lib/lib/ocm/components/clusterWizard/ClusterDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@ const ClusterDetails = ({ cluster, infraEnv }: ClusterDetailsProps) => {
//For Assisted Migration we need the LVMs operator and also the virtualization bundle operators
if (isAssistedMigration) {
params.olmOperators = [{ name: 'lvm' }];
const selectedBundle = (await BundleService.listBundles()).find(
(b) => b.id === 'virtualization',
);
const selectedBundle = (
await BundleService.listBundles(
params.openshiftVersion,
params.cpuArchitecture,
params.platform?.type,
)
).find((b) => b.id === 'virtualization');
const virtOperators = selectedBundle?.operators;
params.olmOperators = [
...params.olmOperators,
Expand Down
15 changes: 6 additions & 9 deletions libs/ui-lib/lib/ocm/components/clusterWizard/OperatorsBundle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import { ExternalLink, OperatorsValues, PopoverIcon, singleClusterBundles } from
import { useFormikContext } from 'formik';
import { useNewFeatureSupportLevel } from '../../../common/components/newFeatureSupportLevels';
import { useFeature } from '../../hooks/use-feature';
import { useSelector } from 'react-redux';
import { selectIsCurrentClusterSNO } from '../../store/slices/current-cluster/selectors';
import { getNewBundleOperators } from '../clusterConfiguration/operators/utils';
import { bundleSpecs } from '../clusterConfiguration/operators/bundleSpecs';
import {
Expand Down Expand Up @@ -84,7 +82,6 @@ const BundleCard = ({
searchTerm?: string;
}) => {
const { values, setFieldValue } = useFormikContext<OperatorsValues>();
const isSNO = useSelector(selectIsCurrentClusterSNO);
const { isFeatureSupported } = useNewFeatureSupportLevel();
const { byKey: opSpecs } = useOperatorSpecs();
const { uiSettings } = useClusterWizardContext();
Expand All @@ -105,16 +102,14 @@ const BundleCard = ({
const isAssistedMigration = uiSettings?.isAssistedMigration;
const disabledReason = hasUnsupportedOperators
? 'Some operators in this bundle are not supported with the current configuration.'
: isSNO && bundleSpec?.noSNO
? bundle.id === 'openshift-ai'
? 'This bundle is not available when deploying a Single Node OpenShift, but you can use the standalone operator instead.'
: 'This bundle is not available when deploying a Single Node OpenShift.'
: incompatibleBundle
? `Bundle cannot be installed together with ${
bundles.find(({ id }) => id === incompatibleBundle)?.title || incompatibleBundle
}`
: isAssistedMigration
? 'This bundle needs to be selected for clusters created from Migration Assessment'
: !bundles.some((b) => b.id === bundle.id)
? 'This bundle is not available for the current configuration, you might be able to use the standalone operators instead.'
: undefined;

const onSelect = (checked: boolean) => {
Expand Down Expand Up @@ -172,10 +167,12 @@ const BundleCard = ({

const OperatorsBundle = ({
bundles,
allBundles,
preflightRequirements,
searchTerm,
}: {
bundles: Bundle[];
allBundles: Bundle[];
preflightRequirements: PreflightHardwareRequirements | undefined;
searchTerm?: string;
}) => {
Expand All @@ -191,8 +188,8 @@ const OperatorsBundle = ({
<StackItem>
<Gallery hasGutter minWidths={{ default: '350px' }}>
{(isSingleClusterFeatureEnabled
? bundles.filter((b) => b.id && singleClusterBundles.includes(b.id))
: bundles
? allBundles.filter((b) => b.id && singleClusterBundles.includes(b.id))
: allBundles
).map((bundle) => (
<GalleryItem key={bundle.id}>
<BundleCard
Expand Down
24 changes: 22 additions & 2 deletions libs/ui-lib/lib/ocm/components/clusterWizard/OperatorsStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,26 @@ export const OperatorsStep = ({ cluster }: ClusterOperatorProps) => {
const { addAlert } = useAlerts();
const [bundlesLoading, setBundlesLoading] = React.useState(true);
const [bundles, setBundles] = React.useState<Bundle[]>([]);
const [allBundles, setAllBundles] = React.useState<Bundle[]>([]);
const { preflightRequirements, isLoading } = useClusterPreflightRequirements(cluster.id);
const [searchTerm, setSearchTerm] = React.useState('');
React.useEffect(() => {
const fetchBundles = async () => {
try {
const fetchedBundles = await BundleService.listBundles();
const fetchedBundles = await BundleService.listBundles(
cluster?.openshiftVersion || '',
cluster?.cpuArchitecture || '',
cluster?.platform?.type || '',
cluster?.controlPlaneCount === 1 ? 'SNO' : undefined,
);
const allBundles = await BundleService.listBundles(
cluster?.openshiftVersion || '',
cluster?.cpuArchitecture || '',
cluster?.platform?.type || '',
undefined,
);
setBundles(fetchedBundles);
setAllBundles(allBundles);
} catch (error) {
handleApiError(error, () =>
addAlert({
Expand All @@ -38,7 +51,13 @@ export const OperatorsStep = ({ cluster }: ClusterOperatorProps) => {
};

void fetchBundles();
}, [addAlert]);
}, [
addAlert,
cluster.cpuArchitecture,
cluster.openshiftVersion,
cluster.platform?.type,
cluster.controlPlaneCount,
]);

const filteredBundles = bundles.filter(
(bundle) =>
Expand Down Expand Up @@ -75,6 +94,7 @@ export const OperatorsStep = ({ cluster }: ClusterOperatorProps) => {
bundles={filteredBundles}
preflightRequirements={preflightRequirements}
searchTerm={searchTerm}
allBundles={allBundles}
/>
</StackItem>
<StackItem>
Expand Down
14 changes: 12 additions & 2 deletions libs/ui-lib/lib/ocm/services/BundleService.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import BundleAPI from '../../common/api/assisted-service/BundleAPI';

const BundleService = {
async listBundles() {
const { data: bundles } = await BundleAPI.list();
async listBundles(
openshiftVersion?: string,
cpuArchitecture?: string,
platformType?: string,
featureIds?: string,
) {
const { data: bundles } = await BundleAPI.list(
openshiftVersion,
cpuArchitecture,
platformType,
featureIds,
);
return bundles;
},
async listOperatorsByBundle(bundleName: string) {
Expand Down
Loading