mirror of https://github.com/rancher/ui.git
Added extra logic for excluding docker cluster from edit/upgrade
k3s clusters that do not have a config should not allow editing of items on the config. A null k3s config indicates a docker installed cluster so I've added extra logic to check if the config exists and if it does not we don't show the manage import cluster info component. I also added logic to the final save method in cru cluster to only show the registration step if the cluster is pending and not a null k3s config. rancher/rancher#30977
This commit is contained in:
parent
d0aa82857b
commit
075a6f49f9
|
|
@ -321,7 +321,7 @@ export default Resource.extend(Grafana, ResourceUsage, {
|
||||||
|
|
||||||
return firstPool.driver || get(firstPool, 'nodeTemplate.driver') || null;
|
return firstPool.driver || get(firstPool, 'nodeTemplate.driver') || null;
|
||||||
default:
|
default:
|
||||||
if (get(this, 'driver') && get(this, 'configName')) {
|
if (get(this, 'driver') && get(this, 'configName') && !isEmpty(get(this, this.configName))) {
|
||||||
return get(this, 'driver');
|
return get(this, 'driver');
|
||||||
} else {
|
} else {
|
||||||
return 'import';
|
return 'import';
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,10 @@ export default Component.extend(ClusterDriver, {
|
||||||
intl: service(),
|
intl: service(),
|
||||||
|
|
||||||
layout,
|
layout,
|
||||||
configField: 'importedConfig',
|
configField: 'importedConfig',
|
||||||
step: 1,
|
step: 1,
|
||||||
nodeForInfo: null,
|
nodeForInfo: null,
|
||||||
|
isDockerCluster: false,
|
||||||
|
|
||||||
isEdit: equal('mode', 'edit'),
|
isEdit: equal('mode', 'edit'),
|
||||||
isView: equal('mode', 'view'),
|
isView: equal('mode', 'view'),
|
||||||
|
|
@ -36,10 +37,7 @@ export default Component.extend(ClusterDriver, {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(this.model.cluster.k3sConfig)) {
|
if (isEmpty(this.model.cluster.k3sConfig)) {
|
||||||
set(this, 'model.cluster.k3sConfig', this.globalStore.createRecord({
|
set(this, 'isDockerCluster', true);
|
||||||
type: 'k3sConfig',
|
|
||||||
kubernetesVersion: this.cluster.version.gitVersion
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
} else if (this.isRke2Cluster) {
|
} else if (this.isRke2Cluster) {
|
||||||
set(this, 'configField', 'rke2Config');
|
set(this, 'configField', 'rke2Config');
|
||||||
|
|
@ -114,7 +112,7 @@ export default Component.extend(ClusterDriver, {
|
||||||
} = this;
|
} = this;
|
||||||
let errors = [];
|
let errors = [];
|
||||||
|
|
||||||
if (field === 'k3sConfig' || field === 'rke2Config' ) {
|
if (field === 'k3sConfig' && !isEmpty(config)) {
|
||||||
if (config.k3supgradeStrategy) {
|
if (config.k3supgradeStrategy) {
|
||||||
// doesn't work because missing deep validation
|
// doesn't work because missing deep validation
|
||||||
// errors = config.k3supgradeStrategy.validationErrors();
|
// errors = config.k3supgradeStrategy.validationErrors();
|
||||||
|
|
@ -122,9 +120,6 @@ export default Component.extend(ClusterDriver, {
|
||||||
errors.push(this.intl.t('clusterNew.k3simport.errors.concurrency.negative'))
|
errors.push(this.intl.t('clusterNew.k3simport.errors.concurrency.negative'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.rke2upgradeStrategy) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEmpty(errors)) {
|
if (!isEmpty(errors)) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{{#if (and (eq step 1) (or isK3sCluster isRke2Cluster))}}
|
{{#if (and (eq step 1) (and (or isK3sCluster isRke2Cluster) (not isDockerCluster)))}}
|
||||||
<AccordionList @showExpandAll={{false}} as |al expandFn|>
|
<AccordionList @showExpandAll={{false}} as |al expandFn|>
|
||||||
<AccordionListItem
|
<AccordionListItem
|
||||||
@title={{t "managedImportClusterInfo.title" provider=cluster.displayProvider}}
|
@title={{t "managedImportClusterInfo.title" provider=cluster.displayProvider}}
|
||||||
|
|
|
||||||
|
|
@ -438,10 +438,22 @@ export default Component.extend(ViewNewEdit, ChildHook, {
|
||||||
|
|
||||||
doneSaving(saved) {
|
doneSaving(saved) {
|
||||||
if ( get(this, 'step') === 1 && get(this, 'driverInfo.preSave') && !get(this, 'driverInfo.postSave') ) {
|
if ( get(this, 'step') === 1 && get(this, 'driverInfo.preSave') && !get(this, 'driverInfo.postSave') ) {
|
||||||
setProperties(this, {
|
const skipK3sImport = !isEmpty(saved?.provider) && saved.provider === 'k3s' && isEmpty(saved?.k3sConfig);
|
||||||
step: 2,
|
|
||||||
initialProvider: get(this, 'provider')
|
if (skipK3sImport && this.originalCluster?.state !== 'pending') {
|
||||||
});
|
if (this.close) {
|
||||||
|
this.close(saved);
|
||||||
|
}
|
||||||
|
} else if (this.originalCluster?.state === 'pending') {
|
||||||
|
setProperties(this, {
|
||||||
|
step: 2,
|
||||||
|
initialProvider: get(this, 'provider')
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (this.close) {
|
||||||
|
this.close(saved);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (get(this, 'driverInfo.postSave')) {
|
} else if (get(this, 'driverInfo.postSave')) {
|
||||||
setProperties(this, {
|
setProperties(this, {
|
||||||
initialProvider: get(this, 'provider'),
|
initialProvider: get(this, 'provider'),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue