@rancher/shell 0.3.26 → 0.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/translations/en-us.yaml +8 -23
- package/assets/translations/zh-hans.yaml +2 -26
- package/chart/gatekeeper.vue +2 -11
- package/chart/istio.vue +1 -10
- package/chart/logging/index.vue +2 -11
- package/chart/monitoring/index.vue +1 -9
- package/chart/rancher-backup/index.vue +1 -9
- package/components/AlertTable.vue +8 -6
- package/components/Carousel.vue +2 -1
- package/components/EmberPage.vue +2 -2
- package/components/EtcdInfoBanner.vue +12 -2
- package/components/GlobalRoleBindings.vue +10 -0
- package/components/GrafanaDashboard.vue +8 -3
- package/components/Wizard.vue +17 -1
- package/components/auth/RoleDetailEdit.vue +17 -1
- package/components/form/ArrayList.vue +20 -11
- package/components/form/__tests__/ArrayList.test.ts +44 -0
- package/components/formatter/ClusterProvider.vue +1 -18
- package/components/nav/Header.vue +5 -4
- package/components/nav/TopLevelMenu.vue +38 -15
- package/components/nav/WindowManager/ContainerLogs.vue +22 -19
- package/components/nav/__tests__/TopLevelMenu.test.ts +120 -0
- package/components/nav/__tests__/Type.test.ts +139 -0
- package/config/private-label.js +1 -1
- package/config/product/manager.js +0 -13
- package/config/settings.ts +0 -2
- package/config/types.js +0 -4
- package/core/types.ts +11 -4
- package/edit/management.cattle.io.project.vue +1 -52
- package/edit/management.cattle.io.setting.vue +31 -2
- package/edit/provisioning.cattle.io.cluster/Basics.vue +19 -107
- package/edit/provisioning.cattle.io.cluster/CustomCommand.vue +1 -1
- package/edit/provisioning.cattle.io.cluster/__tests__/Basics.tests.ts +0 -3
- package/edit/provisioning.cattle.io.cluster/rke2.vue +3 -128
- package/edit/workload/mixins/workload.js +14 -4
- package/middleware/authenticated.js +4 -2
- package/models/__tests__/management.cattle.io.cluster.test.ts +19 -0
- package/models/__tests__/provisioning.cattle.io.cluster.test.ts +90 -0
- package/models/cluster.x-k8s.io.machine.js +1 -1
- package/models/fleet.cattle.io.cluster.js +11 -1
- package/models/management.cattle.io.cluster.js +4 -0
- package/models/management.cattle.io.project.js +0 -36
- package/models/management.cattle.io.setting.js +11 -7
- package/models/provisioning.cattle.io.cluster.js +16 -4
- package/package.json +1 -1
- package/pages/auth/setup.vue +38 -1
- package/pages/c/_cluster/apps/charts/__tests__/install.helper.test.ts +2 -17
- package/pages/c/_cluster/apps/charts/index.vue +0 -15
- package/pages/c/_cluster/apps/charts/install.helpers.js +2 -13
- package/pages/c/_cluster/apps/charts/install.vue +1 -1
- package/pages/c/_cluster/auth/roles/index.vue +11 -1
- package/pages/c/_cluster/explorer/index.vue +7 -49
- package/pages/c/_cluster/manager/pages/_page.vue +4 -5
- package/pages/c/_cluster/monitoring/index.vue +26 -39
- package/pages/support/index.vue +1 -8
- package/promptRemove/management.cattle.io.project.vue +6 -9
- package/rancher-components/BadgeState/BadgeState.vue +1 -5
- package/rancher-components/Banner/Banner.test.ts +1 -51
- package/rancher-components/Banner/Banner.vue +53 -134
- package/rancher-components/Card/Card.vue +7 -24
- package/rancher-components/Form/Checkbox/Checkbox.test.ts +29 -20
- package/rancher-components/Form/Checkbox/Checkbox.vue +20 -45
- package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +8 -2
- package/rancher-components/Form/LabeledInput/LabeledInput.vue +10 -22
- package/rancher-components/Form/Radio/RadioButton.vue +13 -30
- package/rancher-components/Form/Radio/RadioGroup.vue +7 -26
- package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +6 -7
- package/rancher-components/Form/ToggleSwitch/ToggleSwitch.test.ts +38 -25
- package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +11 -23
- package/rancher-components/LabeledTooltip/LabeledTooltip.vue +5 -19
- package/rancher-components/StringList/StringList.test.ts +49 -453
- package/rancher-components/StringList/StringList.vue +58 -92
- package/rancher-components/components/Form/Radio/RadioGroup.test.ts +30 -0
- package/rancher-components/components/Form/Radio/RadioGroup.vue +4 -0
- package/rancher-components/components/StringList/StringList.test.ts +270 -0
- package/rancher-components/components/StringList/StringList.vue +57 -18
- package/store/features.js +1 -0
- package/store/prefs.js +0 -3
- package/types/shell/index.d.ts +26 -17
- package/utils/__tests__/object.test.ts +67 -1
- package/utils/__tests__/version.test.ts +13 -23
- package/utils/cluster.js +1 -1
- package/utils/custom-validators.js +0 -2
- package/utils/error.js +16 -1
- package/utils/grafana.js +1 -2
- package/utils/monitoring.js +25 -1
- package/utils/object.js +4 -3
- package/utils/sort.js +1 -1
- package/utils/validators/formRules/__tests__/index.test.ts +49 -4
- package/utils/validators/formRules/index.ts +13 -10
- package/utils/validators/role-template.js +1 -1
- package/utils/validators/setting.js +6 -10
- package/utils/version.js +0 -13
- package/components/ChartPsp.vue +0 -76
- package/components/__tests__/ChartPsp.test.ts +0 -75
- package/components/formatter/__tests__/ClusterProvider.test.ts +0 -28
- package/rancher-components/Card/Card.test.ts +0 -37
- package/rancher-components/Form/Radio/RadioButton.test.ts +0 -31
- package/yarn-error.log +0 -200
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
DEFAULT_WORKSPACE,
|
|
17
17
|
SECRET,
|
|
18
18
|
HCI,
|
|
19
|
-
PSPS,
|
|
20
19
|
} from '@shell/config/types';
|
|
21
20
|
import { _CREATE, _EDIT, _VIEW } from '@shell/config/query-params';
|
|
22
21
|
|
|
@@ -31,7 +30,6 @@ import { sortBy } from '@shell/utils/sort';
|
|
|
31
30
|
import { camelToTitle } from '@shell/utils/string';
|
|
32
31
|
import { compare, sortable } from '@shell/utils/version';
|
|
33
32
|
import { isHarvesterSatisfiesVersion } from '@shell/utils/cluster';
|
|
34
|
-
import * as VERSION from '@shell/utils/version';
|
|
35
33
|
|
|
36
34
|
import ArrayList from '@shell/components/form/ArrayList';
|
|
37
35
|
import ArrayListGrouped from '@shell/components/form/ArrayListGrouped';
|
|
@@ -155,7 +153,6 @@ export default {
|
|
|
155
153
|
},
|
|
156
154
|
|
|
157
155
|
async fetch() {
|
|
158
|
-
this.psps = await this.getPsps();
|
|
159
156
|
await this.fetchRke2Versions();
|
|
160
157
|
await this.initSpecs();
|
|
161
158
|
await this.initAddons();
|
|
@@ -196,16 +193,11 @@ export default {
|
|
|
196
193
|
set(this.value.spec, 'rkeConfig.machineSelectorConfig', [{ config: {} }]);
|
|
197
194
|
}
|
|
198
195
|
|
|
199
|
-
// Store the initial PSP template name, so we can set it back if needed
|
|
200
|
-
const lastDefaultPodSecurityPolicyTemplateName = this.value.spec.defaultPodSecurityPolicyTemplateName;
|
|
201
|
-
const previousKubernetesVersion = this.value.spec.kubernetesVersion;
|
|
202
|
-
|
|
203
196
|
const truncateLimit = this.value.defaultHostnameLengthLimit;
|
|
204
197
|
|
|
205
198
|
return {
|
|
206
199
|
loadedOnce: false,
|
|
207
200
|
lastIdx: 0,
|
|
208
|
-
allPSPs: null,
|
|
209
201
|
allPSAs: [],
|
|
210
202
|
credentialId: '',
|
|
211
203
|
credential: null,
|
|
@@ -238,11 +230,7 @@ export default {
|
|
|
238
230
|
path: 'metadata.name', rules: ['subDomain'], translationKey: 'nameNsDescription.name.label'
|
|
239
231
|
}],
|
|
240
232
|
harvesterVersionRange: {},
|
|
241
|
-
lastDefaultPodSecurityPolicyTemplateName, // Used for reset on k8s version changes
|
|
242
|
-
previousKubernetesVersion,
|
|
243
233
|
cisOverride: false,
|
|
244
|
-
cisPsaChangeBanner: false,
|
|
245
|
-
psps: null, // List of policies if any
|
|
246
234
|
truncateHostnames: truncateLimit === NETBIOS_TRUNCATION_LENGTH,
|
|
247
235
|
truncateLimit,
|
|
248
236
|
busy: false,
|
|
@@ -286,20 +274,6 @@ export default {
|
|
|
286
274
|
return this.value.agentConfig;
|
|
287
275
|
},
|
|
288
276
|
|
|
289
|
-
/**
|
|
290
|
-
* Define PSP deprecation and restrict use of PSP based on min k8s version
|
|
291
|
-
*/
|
|
292
|
-
needsPSP() {
|
|
293
|
-
return this.getNeedsPSP();
|
|
294
|
-
},
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Define introduction of Rancher defined PSA templates
|
|
298
|
-
*/
|
|
299
|
-
hasPsaTemplates() {
|
|
300
|
-
return !this.needsPSP;
|
|
301
|
-
},
|
|
302
|
-
|
|
303
277
|
unsupportedSelectorConfig() {
|
|
304
278
|
let global = 0;
|
|
305
279
|
let kubeletOnly = 0;
|
|
@@ -933,10 +907,6 @@ export default {
|
|
|
933
907
|
}
|
|
934
908
|
}
|
|
935
909
|
|
|
936
|
-
if ( this.value.spec.defaultPodSecurityPolicyTemplateName === undefined ) {
|
|
937
|
-
set(this.value.spec, 'defaultPodSecurityPolicyTemplateName', '');
|
|
938
|
-
}
|
|
939
|
-
|
|
940
910
|
if ( this.value.spec.defaultPodSecurityAdmissionConfigurationTemplateName === undefined ) {
|
|
941
911
|
set(this.value.spec, 'defaultPodSecurityAdmissionConfigurationTemplateName', '');
|
|
942
912
|
}
|
|
@@ -952,10 +922,6 @@ export default {
|
|
|
952
922
|
k3sVersions: this.$store.dispatch('management/request', { url: '/v1-k3s-release/releases' }),
|
|
953
923
|
};
|
|
954
924
|
|
|
955
|
-
if ( this.$store.getters['management/canList'](MANAGEMENT.POD_SECURITY_POLICY_TEMPLATE) ) {
|
|
956
|
-
hash.allPSPs = await this.$store.dispatch('management/findAll', { type: MANAGEMENT.POD_SECURITY_POLICY_TEMPLATE });
|
|
957
|
-
}
|
|
958
|
-
|
|
959
925
|
if (this.$store.getters['management/canList'](MANAGEMENT.PSA)) {
|
|
960
926
|
hash.allPSAs = await this.$store.dispatch('management/findAll', { type: MANAGEMENT.PSA });
|
|
961
927
|
}
|
|
@@ -980,7 +946,6 @@ export default {
|
|
|
980
946
|
|
|
981
947
|
const res = await allHash(hash);
|
|
982
948
|
|
|
983
|
-
this.allPSPs = res.allPSPs || [];
|
|
984
949
|
this.allPSAs = res.allPSAs || [];
|
|
985
950
|
this.rke2Versions = res.rke2Versions.data || [];
|
|
986
951
|
this.k3sVersions = res.k3sVersions.data || [];
|
|
@@ -1069,16 +1034,6 @@ export default {
|
|
|
1069
1034
|
this.value.removeDefaultHostnameLengthLimit();
|
|
1070
1035
|
}
|
|
1071
1036
|
},
|
|
1072
|
-
/**
|
|
1073
|
-
* Define PSP deprecation and restrict use of PSP based on min k8s version and current/edited mode
|
|
1074
|
-
*/
|
|
1075
|
-
getNeedsPSP(value = this.value) {
|
|
1076
|
-
const release = value?.spec?.kubernetesVersion || '';
|
|
1077
|
-
const version = release.match(/\d+/g);
|
|
1078
|
-
const isRequiredVersion = version?.length ? +version[0] === 1 && +version[1] < 25 : false;
|
|
1079
|
-
|
|
1080
|
-
return isRequiredVersion;
|
|
1081
|
-
},
|
|
1082
1037
|
|
|
1083
1038
|
/**
|
|
1084
1039
|
* Get machine pools from the cluster configuration
|
|
@@ -1359,23 +1314,6 @@ export default {
|
|
|
1359
1314
|
});
|
|
1360
1315
|
},
|
|
1361
1316
|
|
|
1362
|
-
/**
|
|
1363
|
-
* Inform user to remove PSP for current cluster due deprecation
|
|
1364
|
-
*/
|
|
1365
|
-
showPspConfirmation() {
|
|
1366
|
-
return new Promise((resolve, reject) => {
|
|
1367
|
-
this.$store.dispatch('cluster/promptModal', {
|
|
1368
|
-
component: 'GenericPrompt',
|
|
1369
|
-
componentProps: {
|
|
1370
|
-
title: this.t('cluster.rke2.modal.pspChange.title'),
|
|
1371
|
-
body: this.t('cluster.rke2.modal.pspChange.body'),
|
|
1372
|
-
applyMode: 'continue',
|
|
1373
|
-
confirm: resolve
|
|
1374
|
-
},
|
|
1375
|
-
});
|
|
1376
|
-
});
|
|
1377
|
-
},
|
|
1378
|
-
|
|
1379
1317
|
// Set busy before save and clear after save
|
|
1380
1318
|
async saveOverride(btnCb) {
|
|
1381
1319
|
this.$set(this, 'busy', true);
|
|
@@ -1413,13 +1351,6 @@ export default {
|
|
|
1413
1351
|
}
|
|
1414
1352
|
|
|
1415
1353
|
const isEditVersion = this.isEdit && this.liveValue?.spec?.kubernetesVersion !== this.value?.spec?.kubernetesVersion;
|
|
1416
|
-
const hasPspManuallyAdded = !!this.value.spec.rkeConfig?.machineGlobalConfig?.['kube-apiserver-arg'];
|
|
1417
|
-
|
|
1418
|
-
if (isEditVersion && !this.needsPSP && hasPspManuallyAdded) {
|
|
1419
|
-
if (!await this.showPspConfirmation()) {
|
|
1420
|
-
return btnCb('cancelled');
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
1354
|
|
|
1424
1355
|
if (isEditVersion) {
|
|
1425
1356
|
const shouldContinue = await this.showAddonConfirmation();
|
|
@@ -1969,28 +1900,6 @@ export default {
|
|
|
1969
1900
|
}
|
|
1970
1901
|
},
|
|
1971
1902
|
|
|
1972
|
-
/**
|
|
1973
|
-
* Get provisioned RKE2 cluster PSPs in edit mode
|
|
1974
|
-
*/
|
|
1975
|
-
async getPsps() {
|
|
1976
|
-
// As server returns 500 we exclude all the possible cases
|
|
1977
|
-
if (
|
|
1978
|
-
this.mode !== _CREATE &&
|
|
1979
|
-
!this.isK3s &&
|
|
1980
|
-
this.value.state !== 'reconciling' &&
|
|
1981
|
-
this.getNeedsPSP(this.liveValue) // We consider editing only possible PSP cases
|
|
1982
|
-
) {
|
|
1983
|
-
const clusterId = this.value.mgmtClusterId;
|
|
1984
|
-
const url = `/k8s/clusters/${ clusterId }/v1/${ PSPS }`;
|
|
1985
|
-
|
|
1986
|
-
try {
|
|
1987
|
-
return await this.$store.dispatch('cluster/request', { url });
|
|
1988
|
-
} catch (error) {
|
|
1989
|
-
// PSP may not exists for this cluster and an error is returned without need to handle
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
},
|
|
1993
|
-
|
|
1994
1903
|
/**
|
|
1995
1904
|
* Reset PSA on several input changes for given conditions
|
|
1996
1905
|
*/
|
|
@@ -2000,11 +1909,9 @@ export default {
|
|
|
2000
1909
|
const cisValue = this.agentConfig?.profile || this.serverConfig?.profile;
|
|
2001
1910
|
|
|
2002
1911
|
if (!this.cisOverride) {
|
|
2003
|
-
if (
|
|
1912
|
+
if (cisValue) {
|
|
2004
1913
|
set(this.value.spec, 'defaultPodSecurityAdmissionConfigurationTemplateName', hardcodedTemplate);
|
|
2005
1914
|
}
|
|
2006
|
-
|
|
2007
|
-
this.cisPsaChangeBanner = this.hasPsaTemplates;
|
|
2008
1915
|
}
|
|
2009
1916
|
},
|
|
2010
1917
|
|
|
@@ -2027,28 +1934,11 @@ export default {
|
|
|
2027
1934
|
},
|
|
2028
1935
|
|
|
2029
1936
|
/**
|
|
2030
|
-
* Handle k8s changes side effects, like
|
|
1937
|
+
* Handle k8s changes side effects, like PSA resets
|
|
2031
1938
|
*/
|
|
2032
1939
|
handleKubernetesChange(value) {
|
|
2033
1940
|
if (value) {
|
|
2034
1941
|
this.togglePsaDefault();
|
|
2035
|
-
const version = VERSION.parse(value);
|
|
2036
|
-
const major = parseInt(version?.[0] || 0);
|
|
2037
|
-
const minor = parseInt(version?.[1] || 0);
|
|
2038
|
-
|
|
2039
|
-
// Reset PSA if not RKE2
|
|
2040
|
-
if (!value.includes('rke2')) {
|
|
2041
|
-
set(this.value.spec, 'defaultPodSecurityPolicyTemplateName', '');
|
|
2042
|
-
} else {
|
|
2043
|
-
// Reset PSP if it's legacy due k8s version 1.25+
|
|
2044
|
-
if (major === 1 && minor >= 25) {
|
|
2045
|
-
set(this.value.spec, 'defaultPodSecurityPolicyTemplateName', '');
|
|
2046
|
-
} else {
|
|
2047
|
-
set(this.value.spec, 'defaultPodSecurityPolicyTemplateName', this.lastDefaultPodSecurityPolicyTemplateName);
|
|
2048
|
-
}
|
|
2049
|
-
|
|
2050
|
-
this.previousKubernetesVersion = value;
|
|
2051
|
-
}
|
|
2052
1942
|
|
|
2053
1943
|
// If Harvester driver, reset cloud provider if not compatible
|
|
2054
1944
|
if (this.isHarvesterDriver && this.mode === _CREATE && this.isHarvesterIncompatible) {
|
|
@@ -2069,13 +1959,6 @@ export default {
|
|
|
2069
1959
|
}
|
|
2070
1960
|
},
|
|
2071
1961
|
|
|
2072
|
-
/**
|
|
2073
|
-
* Keep last PSP value
|
|
2074
|
-
*/
|
|
2075
|
-
handlePspChange(value) {
|
|
2076
|
-
this.lastDefaultPodSecurityPolicyTemplateName = value;
|
|
2077
|
-
},
|
|
2078
|
-
|
|
2079
1962
|
handleShowDeprecatedPatchVersionsChanged(value) {
|
|
2080
1963
|
this.showDeprecatedPatchVersions = value;
|
|
2081
1964
|
},
|
|
@@ -2110,9 +1993,7 @@ export default {
|
|
|
2110
1993
|
}
|
|
2111
1994
|
});
|
|
2112
1995
|
},
|
|
2113
|
-
|
|
2114
|
-
this.handlePspChange(neu);
|
|
2115
|
-
},
|
|
1996
|
+
|
|
2116
1997
|
handleCisChanged() {
|
|
2117
1998
|
this.handleCisChange();
|
|
2118
1999
|
},
|
|
@@ -2317,23 +2198,18 @@ export default {
|
|
|
2317
2198
|
:live-value="liveValue"
|
|
2318
2199
|
:mode="mode"
|
|
2319
2200
|
:provider="provider"
|
|
2320
|
-
:psps="psps"
|
|
2321
2201
|
:user-chart-values="userChartValues"
|
|
2322
2202
|
:credential="credential"
|
|
2323
2203
|
:cis-override="cisOverride"
|
|
2324
|
-
:cis-psa-change-banner="cisPsaChangeBanner"
|
|
2325
|
-
:all-psps="allPSPs"
|
|
2326
2204
|
:all-psas="allPSAs"
|
|
2327
2205
|
:addon-versions="addonVersions"
|
|
2328
2206
|
:show-deprecated-patch-versions="showDeprecatedPatchVersions"
|
|
2329
|
-
:needs-psp="needsPSP"
|
|
2330
2207
|
:selected-version="selectedVersion"
|
|
2331
2208
|
:is-harvester-driver="isHarvesterDriver"
|
|
2332
2209
|
:is-harvester-incompatible="isHarvesterIncompatible"
|
|
2333
2210
|
:version-options="versionOptions"
|
|
2334
2211
|
:cluster-is-already-created="clusterIsAlreadyCreated"
|
|
2335
2212
|
:is-elemental-cluster="isElementalCluster"
|
|
2336
|
-
:has-psa-templates="hasPsaTemplates"
|
|
2337
2213
|
:is-k3s="isK3s"
|
|
2338
2214
|
:have-arg-info="haveArgInfo"
|
|
2339
2215
|
:show-cni="showCni"
|
|
@@ -2343,7 +2219,6 @@ export default {
|
|
|
2343
2219
|
@cilium-ipv6-changed="handleCiliumIpv6Changed"
|
|
2344
2220
|
@enabled-system-services-changed="handleEnabledSystemServicesChanged"
|
|
2345
2221
|
@kubernetes-changed="handleKubernetesChange"
|
|
2346
|
-
@psp-changed="handlePspChanged"
|
|
2347
2222
|
@cis-changed="handleCisChanged"
|
|
2348
2223
|
@psa-default-changed="handlePsaDefaultChanged"
|
|
2349
2224
|
@show-deprecated-patch-versions-changed="handleShowDeprecatedPatchVersionsChanged"
|
|
@@ -146,10 +146,20 @@ export default {
|
|
|
146
146
|
|
|
147
147
|
async fetch() {
|
|
148
148
|
// TODO Should remove these lines
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
149
|
+
// ? The results aren't stored, so don't know why we fetch?
|
|
150
|
+
|
|
151
|
+
// User might not have access to these resources - so check before trying to fetch
|
|
152
|
+
const fetches = {};
|
|
153
|
+
|
|
154
|
+
if (this.$store.getters[`management/canList`](CAPI.RANCHER_CLUSTER)) {
|
|
155
|
+
fetches.rancherClusters = this.$store.dispatch('management/findAll', { type: CAPI.RANCHER_CLUSTER });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (this.$store.getters[`management/canList`](HCI.HARVESTER_CONFIG)) {
|
|
159
|
+
fetches.harvesterConfigs = this.$store.dispatch('management/findAll', { type: HCI.HARVESTER_CONFIG });
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
await allHash(fetches);
|
|
153
163
|
|
|
154
164
|
// don't block UI for these resources
|
|
155
165
|
this.resourceManagerFetchSecondaryResources(this.secondaryResourceData);
|
|
@@ -8,7 +8,7 @@ import { MANAGEMENT, NORMAN, DEFAULT_WORKSPACE } from '@shell/config/types';
|
|
|
8
8
|
import { _ALL_IF_AUTHED } from '@shell/plugins/dashboard-store/actions';
|
|
9
9
|
import { applyProducts } from '@shell/store/type-map';
|
|
10
10
|
import { findBy } from '@shell/utils/array';
|
|
11
|
-
import { ClusterNotFoundError } from '@shell/utils/error';
|
|
11
|
+
import { ClusterNotFoundError, RedirectToError } from '@shell/utils/error';
|
|
12
12
|
import { get } from '@shell/utils/object';
|
|
13
13
|
import { setFavIcon, haveSetFavIcon } from '@shell/utils/favicon';
|
|
14
14
|
import dynamicPluginLoader from '@shell/pkg/dynamic-plugin-loader';
|
|
@@ -502,8 +502,10 @@ export default async function({
|
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
504
|
} catch (e) {
|
|
505
|
-
if ( e
|
|
505
|
+
if ( e.name === ClusterNotFoundError.name ) {
|
|
506
506
|
return redirect(302, '/home');
|
|
507
|
+
} if ( e.name === RedirectToError.name ) {
|
|
508
|
+
return redirect(302, e.url);
|
|
507
509
|
} else {
|
|
508
510
|
// Sets error 500 if lost connection to API
|
|
509
511
|
store.commit('setError', { error: e, locationError: new Error(store.getters['i18n/t']('nav.failWhale.authMiddleware')) });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import MgmtCluster from '@shell/models/management.cattle.io.cluster';
|
|
2
|
+
|
|
3
|
+
describe('class MgmtCluster', () => {
|
|
4
|
+
describe('provisioner', () => {
|
|
5
|
+
const testCases = [
|
|
6
|
+
[{ provider: 'rke', driver: 'imported' }, 'rke'],
|
|
7
|
+
[{ provider: 'k3s', driver: 'K3S' }, 'k3s'],
|
|
8
|
+
[{ provider: 'aks', driver: 'AKS' }, 'aks'],
|
|
9
|
+
[{}, 'imported'],
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
it.each(testCases)('should return provisioner value properly based on the props data', (clusterData: Object, expected: String) => {
|
|
13
|
+
const cluster = new MgmtCluster({ status: clusterData });
|
|
14
|
+
|
|
15
|
+
expect(cluster.provisioner).toBe(expected);
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import ProvCluster from '@shell/models/provisioning.cattle.io.cluster';
|
|
2
|
+
|
|
3
|
+
describe('class ProvCluster', () => {
|
|
4
|
+
const importedClusterInfo = {
|
|
5
|
+
clusterName: 'test', provisioner: 'imported', mgmt: { spec: { gkeConfig: {} } }, spec: {}
|
|
6
|
+
};
|
|
7
|
+
const importedGkeClusterInfo = {
|
|
8
|
+
clusterName: 'test', provisioner: 'rke2', mgmt: { spec: { gkeConfig: { imported: true } } }
|
|
9
|
+
};
|
|
10
|
+
const importedAksClusterInfo = {
|
|
11
|
+
clusterName: 'test', provisioner: 'rke2', mgmt: { spec: { aksConfig: { imported: true } } }
|
|
12
|
+
};
|
|
13
|
+
const importedEksClusterInfo = {
|
|
14
|
+
clusterName: 'test', provisioner: 'rke2', mgmt: { spec: { eksConfig: { imported: true } } }
|
|
15
|
+
};
|
|
16
|
+
const notImportedGkeClusterInfo = {
|
|
17
|
+
clusterName: 'test', provisioner: 'rke2', mgmt: { spec: { gkeConfig: { imported: false } }, rkeConfig: {} }
|
|
18
|
+
};
|
|
19
|
+
const importedClusterInfoWithProviderForEmberParam = {
|
|
20
|
+
clusterName: 'test', provisioner: 'rke2', mgmt: { providerForEmberParam: 'import' }
|
|
21
|
+
};
|
|
22
|
+
const localClusterInfo = {
|
|
23
|
+
clusterName: 'test', provisioner: 'imported', mgmt: { isLocal: true, spec: { gkeConfig: {} } }, spec: {}
|
|
24
|
+
};
|
|
25
|
+
const doRke2Info = {
|
|
26
|
+
clusterName: 'test', provisioner: 'rke2', mgmt: { isLocal: false, providerForEmberParam: 'import' }, spec: { rkeConfig: {} }
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
describe('isImported', () => {
|
|
30
|
+
const testCases = [
|
|
31
|
+
[importedClusterInfo, true],
|
|
32
|
+
[importedGkeClusterInfo, true],
|
|
33
|
+
[importedAksClusterInfo, true],
|
|
34
|
+
[importedEksClusterInfo, true],
|
|
35
|
+
[notImportedGkeClusterInfo, false],
|
|
36
|
+
[importedClusterInfoWithProviderForEmberParam, true],
|
|
37
|
+
[localClusterInfo, false],
|
|
38
|
+
[doRke2Info, false],
|
|
39
|
+
[{}, false],
|
|
40
|
+
];
|
|
41
|
+
const resetMocks = () => {
|
|
42
|
+
// Clear all mock function calls:
|
|
43
|
+
jest.clearAllMocks();
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
it.each(testCases)('should return the isImported value properly based on the props data', (clusterData: Object, expected: Boolean) => {
|
|
47
|
+
const cluster = new ProvCluster({ spec: clusterData.spec });
|
|
48
|
+
|
|
49
|
+
jest.spyOn(cluster, 'mgmt', 'get').mockReturnValue(
|
|
50
|
+
clusterData.mgmt
|
|
51
|
+
);
|
|
52
|
+
jest.spyOn(cluster, 'provisioner', 'get').mockReturnValue(
|
|
53
|
+
clusterData.provisioner
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(cluster.isImported).toBe(expected);
|
|
57
|
+
resetMocks();
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('mgmt', () => {
|
|
63
|
+
const testCases = [
|
|
64
|
+
[importedClusterInfo, importedClusterInfo.mgmt],
|
|
65
|
+
[importedGkeClusterInfo, importedGkeClusterInfo.mgmt],
|
|
66
|
+
[importedAksClusterInfo, importedAksClusterInfo.mgmt],
|
|
67
|
+
[importedEksClusterInfo, importedEksClusterInfo.mgmt],
|
|
68
|
+
[notImportedGkeClusterInfo, notImportedGkeClusterInfo.mgmt],
|
|
69
|
+
[importedClusterInfoWithProviderForEmberParam, importedClusterInfoWithProviderForEmberParam.mgmt],
|
|
70
|
+
[localClusterInfo, localClusterInfo.mgmt],
|
|
71
|
+
[doRke2Info, doRke2Info.mgmt],
|
|
72
|
+
[{}, null],
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const resetMocks = () => {
|
|
76
|
+
// Clear all mock function calls:
|
|
77
|
+
jest.clearAllMocks();
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
it.each(testCases)('should return the isImported value properly based on the props data', (clusterData: Object, expected: Object) => {
|
|
81
|
+
const clusterMock = jest.fn(() => clusterData.mgmt);
|
|
82
|
+
const ctx = { rootGetters: { 'management/byId': clusterMock } };
|
|
83
|
+
const cluster = new ProvCluster({ status: { clusterName: clusterData.clusterName } }, ctx);
|
|
84
|
+
|
|
85
|
+
expect(cluster.mgmt).toBe(expected);
|
|
86
|
+
resetMocks();
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -5,6 +5,7 @@ import SteveModel from '@shell/plugins/steve/steve-class';
|
|
|
5
5
|
import { escapeHtml } from '@shell/utils/string';
|
|
6
6
|
import { insertAt } from '@shell/utils/array';
|
|
7
7
|
import jsyaml from 'js-yaml';
|
|
8
|
+
import { FLEET_WORKSPACE_BACK } from '@shell/store/features';
|
|
8
9
|
|
|
9
10
|
export default class FleetCluster extends SteveModel {
|
|
10
11
|
get _availableActions() {
|
|
@@ -80,7 +81,16 @@ export default class FleetCluster extends SteveModel {
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
get canChangeWorkspace() {
|
|
83
|
-
|
|
84
|
+
// https://github.com/rancher/dashboard/issues/7745
|
|
85
|
+
if (this.isLocal) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
// https://github.com/rancher/dashboard/issues/9730
|
|
89
|
+
if (this.isRke2) {
|
|
90
|
+
return this.$rootGetters['features/get'](FLEET_WORKSPACE_BACK);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return true;
|
|
84
94
|
}
|
|
85
95
|
|
|
86
96
|
get isLocal() {
|
|
@@ -88,6 +88,10 @@ export default class MgmtCluster extends HybridModel {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
get provisioner() {
|
|
91
|
+
if (this.status?.provider ) {
|
|
92
|
+
return this.status.provider;
|
|
93
|
+
}
|
|
94
|
+
|
|
91
95
|
// For imported K3s clusters, this.status.driver is 'k3s.'
|
|
92
96
|
return this.status?.driver ? this.status.driver : 'imported';
|
|
93
97
|
}
|
|
@@ -99,42 +99,6 @@ export default class Project extends HybridModel {
|
|
|
99
99
|
// and the PUT request should have a query param _replace=true.
|
|
100
100
|
const newValue = await norman.save({ replace: forceReplaceOnReq });
|
|
101
101
|
|
|
102
|
-
let retryCount = 0;
|
|
103
|
-
|
|
104
|
-
const finishProjectCreation = async() => {
|
|
105
|
-
try {
|
|
106
|
-
await newValue.doAction('setpodsecuritypolicytemplate', { podSecurityPolicyTemplateId: this.spec.podSecurityPolicyTemplateId || null });
|
|
107
|
-
} catch (err) {
|
|
108
|
-
if ( err.status === 409 || err.status === 403 ) {
|
|
109
|
-
// The backend updates each new project soon after it is created,
|
|
110
|
-
// so there is a chance of a 409 resource conflict or forbidden error. If that happens,
|
|
111
|
-
// retry the action.
|
|
112
|
-
|
|
113
|
-
// The 403 permission error can happen due to the user requesting
|
|
114
|
-
// the project before the project is fully created and the project
|
|
115
|
-
// permissions are assigned to the user so we allow some
|
|
116
|
-
// time for that process to complete.
|
|
117
|
-
|
|
118
|
-
if (retryCount < 3) {
|
|
119
|
-
retryCount++;
|
|
120
|
-
await setTimeout(() => {
|
|
121
|
-
// Delay for three seconds to avoid another failure due to latency.
|
|
122
|
-
finishProjectCreation();
|
|
123
|
-
}, '3000');
|
|
124
|
-
} else {
|
|
125
|
-
throw err;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// Only update PSP template if the value changed
|
|
132
|
-
const newPSPTemplateID = this.spec.podSecurityPolicyTemplateId || null;
|
|
133
|
-
|
|
134
|
-
if (norman.podSecurityPolicyTemplateId !== newPSPTemplateID) {
|
|
135
|
-
await finishProjectCreation();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
102
|
return newValue;
|
|
139
103
|
}
|
|
140
104
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ALLOWED_SETTINGS } from '@shell/config/settings';
|
|
2
2
|
import HybridModel from '@shell/plugins/steve/hybrid-class';
|
|
3
|
+
import { isServerUrl } from '@shell/utils/validators/setting';
|
|
3
4
|
|
|
4
5
|
export default class Setting extends HybridModel {
|
|
5
6
|
get fromEnv() {
|
|
@@ -31,12 +32,15 @@ export default class Setting extends HybridModel {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
get customValidationRules() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
const out = [];
|
|
36
|
+
|
|
37
|
+
if (isServerUrl(this.metadata.name)) {
|
|
38
|
+
out.push({
|
|
39
|
+
path: 'value',
|
|
40
|
+
validators: ['required', 'https', 'url', 'trailingForwardSlash']
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return out;
|
|
41
45
|
}
|
|
42
46
|
}
|
|
@@ -239,10 +239,24 @@ export default class ProvCluster extends SteveModel {
|
|
|
239
239
|
return providers.includes(this.provisioner);
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
+
get isLocal() {
|
|
243
|
+
return this.mgmt?.isLocal;
|
|
244
|
+
}
|
|
245
|
+
|
|
242
246
|
get isImported() {
|
|
243
247
|
// As of Rancher v2.6.7, this returns false for imported K3s clusters,
|
|
244
248
|
// in which this.provisioner is `k3s`.
|
|
245
|
-
|
|
249
|
+
|
|
250
|
+
const isImportedProvisioner = this.provisioner === 'imported';
|
|
251
|
+
const isImportedSpecialCases = this.mgmt?.providerForEmberParam === 'import' ||
|
|
252
|
+
// when imported cluster is GKE
|
|
253
|
+
!!this.mgmt?.spec?.gkeConfig?.imported ||
|
|
254
|
+
// or AKS
|
|
255
|
+
!!this.mgmt?.spec?.aksConfig?.imported ||
|
|
256
|
+
// or EKS
|
|
257
|
+
!!this.mgmt?.spec?.eksConfig?.imported;
|
|
258
|
+
|
|
259
|
+
return !this.isLocal && (isImportedProvisioner || (!this.isRke2 && !this.mgmt?.machineProvider && isImportedSpecialCases));
|
|
246
260
|
}
|
|
247
261
|
|
|
248
262
|
get isCustom() {
|
|
@@ -262,8 +276,6 @@ export default class ProvCluster extends SteveModel {
|
|
|
262
276
|
}
|
|
263
277
|
|
|
264
278
|
get isImportedK3s() {
|
|
265
|
-
// As of Rancher v2.6.7, this returns false for imported K3s clusters,
|
|
266
|
-
// in which this.provisioner is `k3s`.
|
|
267
279
|
return this.isImported && this.isK3s;
|
|
268
280
|
}
|
|
269
281
|
|
|
@@ -280,7 +292,7 @@ export default class ProvCluster extends SteveModel {
|
|
|
280
292
|
}
|
|
281
293
|
|
|
282
294
|
get isRke1() {
|
|
283
|
-
return !!this.mgmt?.spec?.rancherKubernetesEngineConfig;
|
|
295
|
+
return !!this.mgmt?.spec?.rancherKubernetesEngineConfig || this.labels['provider.cattle.io'] === 'rke';
|
|
284
296
|
}
|
|
285
297
|
|
|
286
298
|
get isHarvester() {
|