Skip to content

Commit 8d82e5b

Browse files
authored
Merge pull request #17228 from richard-cox/mgmttoprov-smaller-parts
Update usages of PCIC, reduce fetching all clusters
2 parents e90bc1c + 5cd540d commit 8d82e5b

31 files changed

Lines changed: 266 additions & 227 deletions

cypress/e2e/blueprints/manager/digital-ocean-cluster-provisioning-response.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ export function clusterMgmtDigitalOceanSingleResponse(clusterName: string): obje
6666
name: `${ clusterName }`,
6767
namespace: `${ namespace }`
6868
}
69-
}
69+
},
70+
provider: 'rke2'
7071
},
7172
}],
7273
};

cypress/e2e/blueprints/nav/fake-cluster.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2528,6 +2528,7 @@ export function generateFakeClusterDataAndIntercepts({
25282528
cy.intercept({
25292529
method: 'GET',
25302530
pathname: '/v1/provisioning.cattle.io.clusters',
2531+
query: { pagesize: '*' }
25312532
}, (req) => {
25322533
req.continue((res) => {
25332534
const localIndex = res.body.data.findIndex((item: any) => item.id.includes('/local'));
@@ -2552,7 +2553,11 @@ export function generateFakeClusterDataAndIntercepts({
25522553
}).as('provCluster');
25532554

25542555
// add extra cluster to the nav list to test https://github.com/rancher/dashboard/issues/10452
2555-
cy.intercept('GET', `/v1/management.cattle.io.clusters?*`, (req) => {
2556+
cy.intercept({
2557+
method: 'GET',
2558+
pathname: '/v1/management.cattle.io.clusters',
2559+
query: { pagesize: '*' }
2560+
}, (req) => {
25562561
req.continue((res) => {
25572562
const localIndex = res.body.data.findIndex((item: any) => item.id.includes('local'));
25582563

@@ -2567,6 +2572,13 @@ export function generateFakeClusterDataAndIntercepts({
25672572
});
25682573
}).as('mgmtClusters');
25692574

2575+
cy.intercept('GET', `/v1/management.cattle.io.clusters/${ fakeNavClusterData.mgmtClusterObj.id }?*`, (req) => {
2576+
req.reply({
2577+
statusCode: 200,
2578+
body: fakeNavClusterData.mgmtClusterObj,
2579+
});
2580+
}).as('mgmtCluster');
2581+
25702582
// intercept counts for fake cluster https://github.com/rancher/dashboard/issues/10452
25712583
cy.intercept('GET', `/k8s/clusters/${ fakeMgmtClusterId }/v1/counts?*`, (req) => {
25722584
req.reply({

cypress/e2e/po/pages/cluster-manager/cluster-manager-list.po.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,35 @@ export default class ClusterManagerListPagePo extends BaseListPagePo {
3434
}
3535

3636
public static mockListRequests(provClusterList: any, mgmtClusterList: any) {
37-
cy.intercept('GET', '/v1/management.cattle.io.clusters?*', (req) => {
37+
// Covers specific get
38+
cy.intercept('GET', `/v1/management.cattle.io.clusters/${ mgmtClusterList.data[0].id }?*`, (req) => {
39+
req.reply({
40+
statusCode: 200,
41+
body: mgmtClusterList.data[0],
42+
});
43+
}).as('mgmtCluster');
44+
45+
// Covers both side bar and any standard cluster list
46+
cy.intercept({
47+
method: 'GET',
48+
pathname: '/v1/management.cattle.io.clusters',
49+
query: { pagesize: '*' }
50+
}, (req) => {
3851
req.reply({
3952
statusCode: 200,
4053
body: mgmtClusterList,
4154
});
4255
}).as('mgmtClusterList');
4356

44-
// Why aren't we doing `/v1/provisioning.cattle.io.clusters?*`
45-
// doesn't match the `/v1/provisioning.cattle.io.clusters?pagesize=100000&filter=id%20IN%20(fleet-default url
46-
// doesn't match the get
47-
57+
// Covers specific get
4858
cy.intercept('GET', `/v1/provisioning.cattle.io.clusters/${ provClusterList.data[0].id }?*`, (req) => {
4959
req.reply({
5060
statusCode: 200,
5161
body: provClusterList.data[0],
5262
});
5363
}).as('provCluster');
5464

65+
// Covers only fetch all of prov cluster, probably un-used
5566
cy.intercept({
5667
method: 'GET',
5768
pathname: '/v1/provisioning.cattle.io.clusters',

cypress/e2e/tests/pages/user-menu/preferences.spec.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ describe('User can update their preferences', () => {
444444

445445
// You want this to be last, there's some issues with logging in and logging out without sessions
446446

447-
function testLandingPageOption(key: { index: string, value: string, page: string, checkCluster?: string}) {
447+
function testLandingPageOption(key: { index: string, value: string, page: string}) {
448448
/*
449449
Select each radio button and verify its highlighted
450450
Validate http request's payload & response contain correct values per selection
@@ -455,13 +455,6 @@ describe('User can update their preferences', () => {
455455
prefPage.goTo();
456456
prefPage.landingPageRadioBtn().checkVisible();
457457

458-
// Check if the dropdown exists before doing anything for the 'specific cluster' option
459-
if (key.checkCluster) {
460-
// Ensure the clusters fetch has completed and the Select component has populated
461-
// with 'local' before we try to select the radio button.
462-
prefPage.expectClusterOptionExists(key.checkCluster);
463-
}
464-
465458
cy.intercept('PUT', 'v1/userpreferences/*', (req) => {
466459
let body = req.body;
467460

@@ -520,7 +513,7 @@ describe('User can update their preferences', () => {
520513

521514
it('Can select login landing page - specific cluster', { tags: ['@userMenu', '@adminUser'] }, () => {
522515
testLandingPageOption({ // This option only works when there is an existing local cluster
523-
index: '2', value: '{\"name\":\"c-cluster\",\"params\":{\"cluster\":\"local\"}}', page: '/explore', checkCluster: 'local'
516+
index: '2', value: '{\"name\":\"c-cluster\",\"params\":{\"cluster\":\"local\"}}', page: '/explore'
524517
});
525518
});
526519
});

shell/assets/translations/en-us.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2396,7 +2396,7 @@ cluster:
23962396
label: Auto Replace
23972397
toolTip: If greater than 0, nodes that are unreachable for this duration will be automatically deleted and replaced.
23982398
unit: "Seconds"
2399-
managementTimeout: The cluster to become available. It's possible the cluster was created. We suggest checking the clusters page before trying to create another.
2399+
managementTimeout: The {type} {name} to become available. It's possible the cluster was created. We suggest checking the clusters page before trying to create another.
24002400
memberRoles:
24012401
removeMessage: 'Note: Removing a user will not remove their project permissions'
24022402
addClusterMember:

shell/components/LandingPagePreference.vue

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ export default {
1414
Select,
1515
},
1616
17-
async fetch() {
18-
this.clusters = await this.$store.dispatch('management/findAll', { type: MANAGEMENT.CLUSTER });
19-
},
20-
2117
data() {
2218
// Store the route as it was on page load (before the user may have changed it)
2319
const customRoute = this.$store.getters['prefs/get'](AFTER_LOGIN_ROUTE);
@@ -90,13 +86,25 @@ export default {
9086
},
9187
9288
methods: {
93-
updateLoginRoute(neu) {
89+
async updateLoginRoute(neu) {
9490
if (neu) {
9591
this.afterLoginRoute = neu;
9692
} else {
93+
this.clusters = await this.$store.dispatch('management/findAll', { type: MANAGEMENT.CLUSTER });
9794
this.afterLoginRoute = this.routeFromDropdown?.value || this.routeDropdownOptions[0]?.value;
9895
}
9996
},
97+
},
98+
99+
watch: {
100+
afterLoginRoute: {
101+
async handler(neu) {
102+
if (typeof neu === 'object') {
103+
this.clusters = await this.$store.dispatch('management/findAll', { type: MANAGEMENT.CLUSTER });
104+
}
105+
},
106+
immediate: true
107+
},
100108
}
101109
};
102110
</script>
@@ -129,6 +137,7 @@ export default {
129137
/>
130138
<Select
131139
v-model:value="routeFromDropdown"
140+
:loading="clusters.length < 1"
132141
:aria-label="t('landing.landingPrefs.ariaLabelTakeMeToCluster')"
133142
:searchable="true"
134143
:disabled="afterLoginRoute === 'home' || afterLoginRoute === 'last-visited'"

shell/components/SingleClusterInfo.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default {
1313
},
1414
1515
async fetch() {
16+
// There's only one cluster, might as well fetch them all...
1617
this.clusters = await this.$store.dispatch('management/findAll', { type: MANAGEMENT.CLUSTER });
1718
},
1819

shell/components/form/WorkloadPorts.vue

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,19 @@ export default {
130130
const version = this.provisioningCluster?.kubernetesVersion;
131131
132132
if (this.provisioningCluster?.isRke2) {
133+
// This is a candidate for using the prov cluster provisioner (or now the mgmt cluster provisioner directly)
133134
const machineSelectorConfig = this.provisioningCluster?.spec?.rkeConfig?.machineSelectorConfig || {};
134135
const agentConfig = (machineSelectorConfig[0] || {}).config;
135136
136137
cloudProvider = agentConfig?.['cloud-provider-name'];
137-
} else if (this.provisioningCluster?.isRke1) {
138-
const currentCluster = this.$store.getters['currentCluster'];
139-
140-
cloudProvider = currentCluster?.spec?.rancherKubernetesEngineConfig?.cloudProvider?.name;
141138
}
142139
143140
return cloudProvider === HARVESTER &&
144141
isHarvesterSatisfiesVersion(version);
145142
},
146143
147144
provisioningCluster() {
148-
const out = this.$store.getters['management/all'](CAPI.RANCHER_CLUSTER).find((c) => c?.status?.clusterName === this.currentCluster.metadata.name);
149-
150-
return out;
145+
return this.$store.getters['management/byId'](CAPI.RANCHER_CLUSTER, this.currentCluster.provClusterId);
151146
},
152147
},
153148

shell/components/nav/TopLevelMenu.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ export default {
423423
},
424424
425425
async goToHarvesterCluster() {
426-
const localCluster = this.$store.getters['management/all'](CAPI.RANCHER_CLUSTER).find((C) => C.id === 'fleet-local/local');
426+
const localCluster = this.$store.getters['management/byId'](CAPI.RANCHER_CLUSTER, 'fleet-local/local');
427427
428428
try {
429429
await localCluster.goToHarvesterCluster();

shell/config/product/manager.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,13 @@ export function init(store) {
232232

233233
headers(CAPI.MACHINE_DEPLOYMENT, [
234234
STATE,
235-
NAME_COL,
235+
NAME_COL, {
236+
name: 'cluster',
237+
labelKey: 'tableHeaders.cluster',
238+
value: 'clusterName',
239+
getValue: (row) => row.clusterName,
240+
sort: ['clusterName'],
241+
},
236242
MACHINE_SUMMARY,
237243
AGE
238244
]);
@@ -271,4 +277,24 @@ export function init(store) {
271277
})
272278
}
273279
});
280+
281+
const clusterGroupConfig = {
282+
listGroups: [{
283+
tooltipKey: 'resourceTable.groupBy.none',
284+
icon: 'icon-list-flat',
285+
value: 'none',
286+
}, {
287+
icon: 'icon-folder',
288+
value: 'clusterName',
289+
field: 'clusterName',
290+
hideColumn: 'cluster',
291+
tooltipKey: 'resourceTable.groupBy.cluster',
292+
groupLabelKey: 'groupByLabel',
293+
}],
294+
listGroupsWillOverride: true,
295+
};
296+
297+
configureType(CAPI.MACHINE_DEPLOYMENT, { ...clusterGroupConfig });
298+
configureType(CAPI.MACHINE_SET, { ...clusterGroupConfig });
299+
configureType(CAPI.MACHINE, { ...clusterGroupConfig });
274300
}

0 commit comments

Comments
 (0)