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:
Westly Wright 2021-04-07 08:50:17 -07:00
parent d0aa82857b
commit 075a6f49f9
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
4 changed files with 24 additions and 17 deletions

View File

@ -321,7 +321,7 @@ export default Resource.extend(Grafana, ResourceUsage, {
return firstPool.driver || get(firstPool, 'nodeTemplate.driver') || null;
default:
if (get(this, 'driver') && get(this, 'configName')) {
if (get(this, 'driver') && get(this, 'configName') && !isEmpty(get(this, this.configName))) {
return get(this, 'driver');
} else {
return 'import';

View File

@ -14,9 +14,10 @@ export default Component.extend(ClusterDriver, {
intl: service(),
layout,
configField: 'importedConfig',
step: 1,
nodeForInfo: null,
configField: 'importedConfig',
step: 1,
nodeForInfo: null,
isDockerCluster: false,
isEdit: equal('mode', 'edit'),
isView: equal('mode', 'view'),
@ -36,10 +37,7 @@ export default Component.extend(ClusterDriver, {
}
if (isEmpty(this.model.cluster.k3sConfig)) {
set(this, 'model.cluster.k3sConfig', this.globalStore.createRecord({
type: 'k3sConfig',
kubernetesVersion: this.cluster.version.gitVersion
}));
set(this, 'isDockerCluster', true);
}
} else if (this.isRke2Cluster) {
set(this, 'configField', 'rke2Config');
@ -114,7 +112,7 @@ export default Component.extend(ClusterDriver, {
} = this;
let errors = [];
if (field === 'k3sConfig' || field === 'rke2Config' ) {
if (field === 'k3sConfig' && !isEmpty(config)) {
if (config.k3supgradeStrategy) {
// doesn't work because missing deep validation
// errors = config.k3supgradeStrategy.validationErrors();
@ -122,9 +120,6 @@ export default Component.extend(ClusterDriver, {
errors.push(this.intl.t('clusterNew.k3simport.errors.concurrency.negative'))
}
}
if (config.rke2upgradeStrategy) {
}
}
if (!isEmpty(errors)) {

View File

@ -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|>
<AccordionListItem
@title={{t "managedImportClusterInfo.title" provider=cluster.displayProvider}}

View File

@ -438,10 +438,22 @@ export default Component.extend(ViewNewEdit, ChildHook, {
doneSaving(saved) {
if ( get(this, 'step') === 1 && get(this, 'driverInfo.preSave') && !get(this, 'driverInfo.postSave') ) {
setProperties(this, {
step: 2,
initialProvider: get(this, 'provider')
});
const skipK3sImport = !isEmpty(saved?.provider) && saved.provider === 'k3s' && isEmpty(saved?.k3sConfig);
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')) {
setProperties(this, {
initialProvider: get(this, 'provider'),