@rancher/shell 0.3.27 → 0.3.29

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.
Files changed (55) hide show
  1. package/assets/translations/en-us.yaml +19 -21
  2. package/assets/translations/zh-hans.yaml +0 -23
  3. package/chart/gatekeeper.vue +2 -11
  4. package/chart/istio.vue +1 -10
  5. package/chart/logging/index.vue +2 -11
  6. package/chart/monitoring/grafana/index.vue +2 -2
  7. package/chart/monitoring/index.vue +1 -9
  8. package/chart/rancher-backup/index.vue +1 -9
  9. package/components/AsyncButton.vue +9 -0
  10. package/components/Carousel.vue +2 -1
  11. package/components/SortableTable/THead.vue +7 -9
  12. package/components/SortableTable/index.vue +1 -2
  13. package/components/fleet/FleetStatus.vue +3 -3
  14. package/components/fleet/FleetSummary.vue +32 -27
  15. package/components/formatter/ClusterProvider.vue +1 -18
  16. package/components/nav/WindowManager/ContainerLogs.vue +22 -19
  17. package/config/product/manager.js +0 -13
  18. package/config/types.js +0 -4
  19. package/detail/provisioning.cattle.io.cluster.vue +2 -1
  20. package/edit/management.cattle.io.project.vue +1 -52
  21. package/edit/management.cattle.io.setting.vue +31 -2
  22. package/edit/provisioning.cattle.io.cluster/Basics.vue +6 -107
  23. package/edit/provisioning.cattle.io.cluster/__tests__/Basics.tests.ts +0 -3
  24. package/edit/provisioning.cattle.io.cluster/rke2.vue +3 -128
  25. package/edit/workload/index.vue +2 -1
  26. package/machine-config/__tests__/vmwarevsphere.test.ts +72 -0
  27. package/machine-config/vmwarevsphere.vue +68 -13
  28. package/middleware/authenticated.js +4 -2
  29. package/models/__tests__/management.cattle.io.cluster.test.ts +19 -0
  30. package/models/__tests__/provisioning.cattle.io.cluster.test.ts +90 -0
  31. package/models/cluster.x-k8s.io.machine.js +1 -1
  32. package/models/management.cattle.io.cluster.js +4 -0
  33. package/models/management.cattle.io.project.js +0 -36
  34. package/models/management.cattle.io.setting.js +11 -7
  35. package/models/provisioning.cattle.io.cluster.js +16 -4
  36. package/package.json +2 -1
  37. package/pages/auth/setup.vue +38 -1
  38. package/pages/c/_cluster/apps/charts/__tests__/install.helper.test.ts +2 -17
  39. package/pages/c/_cluster/apps/charts/index.vue +0 -15
  40. package/pages/c/_cluster/apps/charts/install.helpers.js +2 -13
  41. package/pages/c/_cluster/apps/charts/install.vue +1 -1
  42. package/pages/c/_cluster/explorer/index.vue +0 -47
  43. package/pages/c/_cluster/manager/pages/_page.vue +4 -5
  44. package/rancher-components/components/StringList/StringList.test.ts +270 -0
  45. package/rancher-components/components/StringList/StringList.vue +57 -18
  46. package/store/prefs.js +0 -3
  47. package/types/shell/index.d.ts +13 -7
  48. package/utils/custom-validators.js +0 -2
  49. package/utils/error.js +16 -1
  50. package/utils/validators/formRules/__tests__/index.test.ts +49 -4
  51. package/utils/validators/formRules/index.ts +12 -9
  52. package/utils/validators/setting.js +6 -10
  53. package/components/ChartPsp.vue +0 -76
  54. package/components/__tests__/ChartPsp.test.ts +0 -75
  55. package/components/formatter/__tests__/ClusterProvider.test.ts +0 -28
@@ -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 (this.hasPsaTemplates && cisValue) {
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 PSP and PSA resets
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
- handlePspChanged(neu) {
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"
@@ -235,7 +235,7 @@ export default {
235
235
  <div class="col span-6">
236
236
  <LabeledSelect
237
237
  v-model="imagePullSecrets"
238
- :label="t('workload.container.imagePullSecrets')"
238
+ :label="t('workload.container.imagePullSecrets.label')"
239
239
  :multiple="true"
240
240
  :taggable="true"
241
241
  :options="imagePullNamespacedSecrets"
@@ -243,6 +243,7 @@ export default {
243
243
  option-label="metadata.name"
244
244
  :reduce="service=>service.metadata.name"
245
245
  :create-option="createOption"
246
+ :tooltip="t('workload.container.imagePullSecrets.tooltip')"
246
247
  />
247
248
  </div>
248
249
  </div>
@@ -0,0 +1,72 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import vmwarevsphere, { DEFAULT_VALUES } from '@shell/machine-config/vmwarevsphere.vue';
3
+
4
+ describe('component: vmwarevsphere', () => {
5
+ it('should mount successfully with correct default values', () => {
6
+ const defaultGetters = { 'i18n/t': jest.fn() };
7
+ const wrapper = mount(vmwarevsphere, {
8
+ propsData: {
9
+ poolId: 'poolId',
10
+ credentialId: 'credentialId',
11
+ disabled: false,
12
+ mode: 'create',
13
+ value: {
14
+ initted: false,
15
+ network: [],
16
+ tag: []
17
+ },
18
+ provider: 'vmwarevsphere'
19
+ },
20
+ mocks: {
21
+ $fetchState: { pending: false },
22
+ $store: { getters: defaultGetters },
23
+ },
24
+ stubs: { CodeMirror: true }
25
+ });
26
+
27
+ const dataCenterElement = wrapper.find(`[data-testid="datacenter"]`).element;
28
+ const resourcePoolElement = wrapper.find(`[data-testid="resourcePool"]`).element;
29
+ const dataStoreElement = wrapper.find(`[data-testid="dataStore"]`).element;
30
+ const folderElement = wrapper.find(`[data-testid="folder"]`).element;
31
+ const hostElement = wrapper.find(`[data-testid="host"]`).element;
32
+ const gracefulShutdownTimeoutElement = wrapper.find(`[data-testid="gracefulShutdownTimeout"]`).element;
33
+
34
+ expect(dataCenterElement).toBeDefined();
35
+ expect(resourcePoolElement).toBeDefined();
36
+ expect(dataStoreElement).toBeDefined();
37
+ expect(folderElement).toBeDefined();
38
+ expect(hostElement).toBeDefined();
39
+ expect(gracefulShutdownTimeoutElement).toBeDefined();
40
+
41
+ const {
42
+ cpuCount: defaultCpuCount,
43
+ diskSize: defaultDiskSize,
44
+ memorySize: defaultMemorySize,
45
+ hostsystem: defaultHostsystem,
46
+ cloudConfig: defaultCloudConfig,
47
+ gracefulShutdownTimeout: defaultGracefulShutdownTimeout,
48
+ cfgparam: defaultCfgparam,
49
+ os: defaultOs
50
+ } = DEFAULT_VALUES;
51
+
52
+ const {
53
+ cpuCount,
54
+ diskSize,
55
+ memorySize,
56
+ hostsystem,
57
+ cloudConfig,
58
+ gracefulShutdownTimeout,
59
+ cfgparam,
60
+ os
61
+ } = wrapper.vm.$options.propsData.value;
62
+
63
+ expect(cpuCount).toStrictEqual(defaultCpuCount);
64
+ expect(diskSize).toStrictEqual(defaultDiskSize);
65
+ expect(memorySize).toStrictEqual(defaultMemorySize);
66
+ expect(hostsystem).toStrictEqual(defaultHostsystem);
67
+ expect(cloudConfig).toStrictEqual(defaultCloudConfig);
68
+ expect(gracefulShutdownTimeout).toStrictEqual(defaultGracefulShutdownTimeout);
69
+ expect(cfgparam).toStrictEqual(defaultCfgparam);
70
+ expect(os).toStrictEqual(defaultOs);
71
+ });
72
+ });
@@ -39,7 +39,17 @@ const OS_OPTIONS = [
39
39
  'linux',
40
40
  'windows'
41
41
  ];
42
- const DEFAULT_CFGPARAM = ['disk.enableUUID=TRUE'];
42
+
43
+ export const DEFAULT_VALUES = {
44
+ cpuCount: '2',
45
+ diskSize: '20000',
46
+ memorySize: '4096',
47
+ hostsystem: '',
48
+ cloudConfig: '#cloud-config\n\n',
49
+ gracefulShutdownTimeout: '0',
50
+ cfgparam: ['disk.enableUUID=TRUE'],
51
+ os: OS_OPTIONS[0]
52
+ };
43
53
 
44
54
  const getDefaultVappOptions = (networks) => {
45
55
  return {
@@ -217,15 +227,27 @@ export default {
217
227
  if (this.mode === _CREATE && !this.value.initted) {
218
228
  Object.defineProperty(this.value, 'initted', { value: true, enumerable: false });
219
229
 
230
+ const {
231
+ cpuCount,
232
+ diskSize,
233
+ memorySize,
234
+ hostsystem,
235
+ cloudConfig,
236
+ gracefulShutdownTimeout,
237
+ cfgparam,
238
+ os
239
+ } = DEFAULT_VALUES;
240
+
220
241
  set(this.value, 'creationType', creationMethods[0].value);
221
- set(this.value, 'cpuCount', '2');
222
- set(this.value, 'diskSize', '20000');
223
- set(this.value, 'memorySize', '4096');
224
- set(this.value, 'hostsystem', '');
225
- set(this.value, 'cloudConfig', '#cloud-config\n\n');
226
- set(this.value, 'cfgparam', DEFAULT_CFGPARAM);
242
+ set(this.value, 'cpuCount', cpuCount);
243
+ set(this.value, 'diskSize', diskSize);
244
+ set(this.value, 'memorySize', memorySize);
245
+ set(this.value, 'hostsystem', hostsystem);
246
+ set(this.value, 'gracefulShutdownTimeout', gracefulShutdownTimeout);
247
+ set(this.value, 'cloudConfig', cloudConfig);
248
+ set(this.value, 'cfgparam', cfgparam);
227
249
  set(this.value, 'vappProperty', this.value.vappProperty);
228
- set(this.value, 'os', OS_OPTIONS[0]);
250
+ set(this.value, 'os', os);
229
251
  Object.entries(INITIAL_VAPP_OPTIONS).forEach(([key, value]) => {
230
252
  set(this.value, key, value);
231
253
  });
@@ -326,6 +348,8 @@ export default {
326
348
  memorySize: integerString('value.memorySize'),
327
349
  diskSize: integerString('value.diskSize'),
328
350
 
351
+ gracefulShutdownTimeout: integerString('value.gracefulShutdownTimeout'),
352
+
329
353
  showCloudConfigYaml() {
330
354
  return this.value.creationType !== 'legacy';
331
355
  },
@@ -731,7 +755,10 @@ export default {
731
755
  </p>
732
756
  </h4>
733
757
  <div slot="body">
734
- <div class="row">
758
+ <div
759
+ class="row"
760
+ data-testid="datacenter"
761
+ >
735
762
  <div class="col span-6">
736
763
  <LabeledSelect
737
764
  v-model="value.datacenter"
@@ -742,7 +769,10 @@ export default {
742
769
  :disabled="disabled"
743
770
  />
744
771
  </div>
745
- <div class="col span-6">
772
+ <div
773
+ class="col span-6"
774
+ data-testid="resourcePool"
775
+ >
746
776
  <LabeledSelect
747
777
  v-model="value.pool"
748
778
  :loading="resourcePoolsLoading"
@@ -754,7 +784,10 @@ export default {
754
784
  </div>
755
785
  </div>
756
786
  <div class="row mt-10">
757
- <div class="col span-6">
787
+ <div
788
+ class="col span-6"
789
+ data-testid="dataStore"
790
+ >
758
791
  <LabeledSelect
759
792
  v-model="value.datastore"
760
793
  :loading="dataStoresLoading"
@@ -764,7 +797,10 @@ export default {
764
797
  :disabled="disabled"
765
798
  />
766
799
  </div>
767
- <div class="col span-6">
800
+ <div
801
+ class="col span-6"
802
+ data-testid="folder"
803
+ >
768
804
  <LabeledSelect
769
805
  v-model="value.folder"
770
806
  :loading="foldersLoading"
@@ -776,7 +812,10 @@ export default {
776
812
  </div>
777
813
  </div>
778
814
  <div class="row mt-10">
779
- <div class="col span-12">
815
+ <div
816
+ class="col span-6"
817
+ data-testid="host"
818
+ >
780
819
  <LabeledSelect
781
820
  v-model="host"
782
821
  :loading="hostsLoading"
@@ -789,6 +828,22 @@ export default {
789
828
  {{ t('cluster.machineConfig.vsphere.scheduling.host.note') }}
790
829
  </p>
791
830
  </div>
831
+ <div
832
+ class="col span-6"
833
+ data-testid="gracefulShutdownTimeout"
834
+ >
835
+ <UnitInput
836
+ v-model="gracefulShutdownTimeout"
837
+ :mode="mode"
838
+ :label="t('cluster.machineConfig.vsphere.scheduling.gracefulShutdownTimeout.label')"
839
+ :suffix="t('suffix.seconds', { count: gracefulShutdownTimeout})"
840
+ :disabled="disabled"
841
+ min="0"
842
+ />
843
+ <p class="text-muted mt-5">
844
+ {{ t('cluster.machineConfig.vsphere.scheduling.gracefulShutdownTimeout.note') }}
845
+ </p>
846
+ </div>
792
847
  </div>
793
848
  </div>
794
849
  </Card>
@@ -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 instanceof ClusterNotFoundError ) {
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
+ });
@@ -231,7 +231,7 @@ export default class CapiMachine extends SteveModel {
231
231
  return false;
232
232
  }
233
233
 
234
- return notOnlyOfRole(this, this.cluster.machines);
234
+ return notOnlyOfRole(this, this.cluster?.machines);
235
235
  }
236
236
 
237
237
  get roles() {
@@ -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
  }