mirror of https://github.com/rancher/ui.git
Syncing node version with cluster version (#5099)
* make node version synced with cluster version + minor refactor * update naming of controlPlaneVersion to clusterVersion --------- Co-authored-by: Mo Mesgin <mmesgin@Mos-M2-MacBook-Pro.local>
This commit is contained in:
parent
131e11ae56
commit
714f2be4d5
|
|
@ -659,7 +659,7 @@
|
||||||
@nodePool={{nodePool}}
|
@nodePool={{nodePool}}
|
||||||
@removeNodePool={{action "removeNodePool"}}
|
@removeNodePool={{action "removeNodePool"}}
|
||||||
@nodeVersions={{versions.validNodeVersions}}
|
@nodeVersions={{versions.validNodeVersions}}
|
||||||
@controlPlaneVersion={{config.kubernetesVersion}}
|
@clusterVersion={{config.kubernetesVersion}}
|
||||||
@cluster={{cluster}}
|
@cluster={{cluster}}
|
||||||
@versionChoices={{versionChoices}}
|
@versionChoices={{versionChoices}}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ import { on } from '@ember/object/evented';
|
||||||
import { next } from '@ember/runloop';
|
import { next } from '@ember/runloop';
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
import { isEmpty } from '@ember/utils';
|
import { isEmpty } from '@ember/utils';
|
||||||
import Semver/* , { coerce, minor } */ from 'semver';
|
import Semver from 'semver';
|
||||||
// import { coerceVersion } from 'shared/utils/parse-version';
|
|
||||||
import { sortableNumericSuffix } from 'shared/utils/util';
|
import { sortableNumericSuffix } from 'shared/utils/util';
|
||||||
import layout from './template';
|
import layout from './template';
|
||||||
|
|
||||||
|
|
@ -26,13 +25,17 @@ export default Component.extend({
|
||||||
imageTypeContent: null,
|
imageTypeContent: null,
|
||||||
machineTypes: null,
|
machineTypes: null,
|
||||||
nodeVersions: null,
|
nodeVersions: null,
|
||||||
controlPlaneVersion: null,
|
clusterVersion: null,
|
||||||
upgradeVersion: false,
|
upgradeVersion: false,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
const { nodePool, maxVersion } = this;
|
const {
|
||||||
|
nodePool,
|
||||||
|
clusterVersion,
|
||||||
|
defaultClusterVersion
|
||||||
|
} = this;
|
||||||
|
|
||||||
setProperties(this, {
|
setProperties(this, {
|
||||||
scopeConfig: {},
|
scopeConfig: {},
|
||||||
|
|
@ -51,8 +54,8 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(nodePool?.version) && !isEmpty(maxVersion)) {
|
if (isEmpty(nodePool?.version) && !isEmpty(clusterVersion)) {
|
||||||
set(this, 'nodePool.version', maxVersion);
|
set(this, 'nodePool.version', defaultClusterVersion);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setProperties(this, {
|
setProperties(this, {
|
||||||
|
|
@ -84,12 +87,11 @@ export default Component.extend({
|
||||||
this.send('updateScopes');
|
this.send('updateScopes');
|
||||||
}),
|
}),
|
||||||
|
|
||||||
editingUpdateNodeVersion: observer('isNewNodePool', 'clusterVersionIsLessThanMax', 'controlPlaneVersion', function() {
|
editingUpdateNodeVersion: observer('isNewNodePool', 'clusterVersion', function() {
|
||||||
const { isNewNodePool, clusterVersionIsLessThanMax } = this;
|
const { isNewNodePool, clusterVersion } = this;
|
||||||
const clusterVersion = get(this, 'controlPlaneVersion');
|
|
||||||
const nodeVersion = get(this, 'nodePool.version');
|
const nodeVersion = get(this, 'nodePool.version');
|
||||||
|
|
||||||
if (isNewNodePool && clusterVersion !== nodeVersion && clusterVersionIsLessThanMax) {
|
if (isNewNodePool && clusterVersion !== nodeVersion) {
|
||||||
set(this, 'nodePool.version', clusterVersion);
|
set(this, 'nodePool.version', clusterVersion);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
@ -130,6 +132,18 @@ export default Component.extend({
|
||||||
set(this.nodePool.config, 'oauthScopes', this.google.mapOauthScopes(this.oauthScopesSelection, this.scopeConfig));
|
set(this.nodePool.config, 'oauthScopes', this.google.mapOauthScopes(this.oauthScopesSelection, this.scopeConfig));
|
||||||
})),
|
})),
|
||||||
|
|
||||||
|
// In create mode, the cluster version can fallback to the first item in the versionChoices array.
|
||||||
|
// Similarly, defaultClusterVersion is used to synchronize the node version.
|
||||||
|
defaultClusterVersion: computed('versionChoices', 'clusterVersion', function() {
|
||||||
|
const { clusterVersion, versionChoices } = this;
|
||||||
|
|
||||||
|
if (versionChoices.some((v) => v?.value === clusterVersion)) {
|
||||||
|
return clusterVersion;
|
||||||
|
} else {
|
||||||
|
return versionChoices[0]?.value;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
regionalTotalNodeCounts: computed('locationType', 'nodePool.initialNodeCount', 'locationContent.@each.checked', function() {
|
regionalTotalNodeCounts: computed('locationType', 'nodePool.initialNodeCount', 'locationContent.@each.checked', function() {
|
||||||
const { locationType } = this;
|
const { locationType } = this;
|
||||||
let totalLocations = this.locationContent.filterBy('checked').length;
|
let totalLocations = this.locationContent.filterBy('checked').length;
|
||||||
|
|
@ -167,32 +181,18 @@ export default Component.extend({
|
||||||
return '';
|
return '';
|
||||||
}),
|
}),
|
||||||
|
|
||||||
maxVersion: computed('versionChoices', 'controlPlaneVersion', function() {
|
upgradeAvailable: computed('clusterVersion', 'mode', 'nodePool.version', 'defaultClusterVersion', function() {
|
||||||
const clusterVersion = get(this, 'controlPlaneVersion');
|
const { clusterVersion, defaultClusterVersion } = this;
|
||||||
const versionChoices = get(this, 'versionChoices');
|
|
||||||
|
|
||||||
return versionChoices?.[0]?.value || clusterVersion;
|
|
||||||
}),
|
|
||||||
|
|
||||||
clusterVersionIsLessThanMax: computed('maxVersion', 'controlPlaneVersion', function() {
|
|
||||||
const clusterVersion = get(this, 'controlPlaneVersion');
|
|
||||||
const maxVersion = get(this, 'maxVersion');
|
|
||||||
|
|
||||||
return Semver.lte(clusterVersion, maxVersion, { includePrerelease: true });
|
|
||||||
}),
|
|
||||||
|
|
||||||
upgradeAvailable: computed('controlPlaneVersion', 'clusterVersionIsLessThanMax', 'mode', 'nodePool.version', 'originalClusterVersion', function() {
|
|
||||||
const clusterVersion = get(this, 'controlPlaneVersion');
|
|
||||||
const nodeVersion = get(this, 'nodePool.version');
|
const nodeVersion = get(this, 'nodePool.version');
|
||||||
const clusterVersionIsLessThanMax = get(this, 'clusterVersionIsLessThanMax');
|
|
||||||
|
|
||||||
if (isEmpty(clusterVersion) || isEmpty(nodeVersion)) {
|
if (isEmpty(clusterVersion) || isEmpty(nodeVersion)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nodeIsLess = Semver.lt(nodeVersion, clusterVersion, { includePrerelease: true });
|
const nodeIsLess = Semver.lt(nodeVersion, clusterVersion, { includePrerelease: true });
|
||||||
|
const clusterVersionIsAlsoTheMaxVersion = clusterVersion === defaultClusterVersion;
|
||||||
|
|
||||||
if (nodeIsLess && clusterVersionIsLessThanMax) {
|
if (nodeIsLess && clusterVersionIsAlsoTheMaxVersion) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -221,44 +221,12 @@ export default Component.extend({
|
||||||
return out.sortBy('sortName')
|
return out.sortBy('sortName')
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// versionChoices: computed('nodeVersions.[]', 'controlPlaneVersion', 'mode', function() {
|
|
||||||
// // google gke console allows the node version to be anything less than master version
|
|
||||||
// const {
|
|
||||||
// nodeVersions,
|
|
||||||
// controlPlaneVersion,
|
|
||||||
// mode,
|
|
||||||
// } = this;
|
|
||||||
|
|
||||||
// const coerceedVersion = coerceVersion(controlPlaneVersion);
|
shouldUpgradeVersion: on('init', observer('upgradeVersion', 'clusterVersion', function() {
|
||||||
// const maxVersionRange = `<= ${ coerceedVersion }`;
|
const { upgradeVersion, clusterVersion } = this;
|
||||||
// let newVersions = this.serviceVersions.parseCloudProviderVersionChoices(nodeVersions, controlPlaneVersion, mode, maxVersionRange);
|
|
||||||
|
|
||||||
// const controlPlaneVersionMatch = newVersions.findBy('value', controlPlaneVersion);
|
|
||||||
|
|
||||||
// if (!isEmpty(controlPlaneVersionMatch)) {
|
|
||||||
// set(controlPlaneVersionMatch, 'label', `${ controlPlaneVersionMatch.label } (control plane version)`);
|
|
||||||
|
|
||||||
// set(this, 'nodePool.version', controlPlaneVersionMatch.value);
|
|
||||||
|
|
||||||
// const indexOfMatch = newVersions.indexOf(controlPlaneVersionMatch);
|
|
||||||
|
|
||||||
// if (indexOfMatch > 0) {
|
|
||||||
// // gke returns a semver like 1.17.17-gke.2800, 1.17.17-gke.3000
|
|
||||||
// // semver logic sorts these correctly but because we have to coerce the version, all versions in the 1.17.17 comebace
|
|
||||||
// // since they are sorted lets just find our CP master match index and cut everything off before that
|
|
||||||
// newVersions = newVersions.slice(indexOfMatch);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return newVersions;
|
|
||||||
// }),
|
|
||||||
|
|
||||||
shouldUpgradeVersion: on('init', observer('upgradeVersion', 'clusterVersionIsLessThanMax', 'controlPlaneVersion', function() {
|
|
||||||
const { upgradeVersion, clusterVersionIsLessThanMax } = this;
|
|
||||||
const clusterVersion = get(this, 'controlPlaneVersion');
|
|
||||||
const nodeVersion = get(this, 'nodePool.version');
|
const nodeVersion = get(this, 'nodePool.version');
|
||||||
|
|
||||||
if (upgradeVersion && clusterVersion !== nodeVersion && clusterVersionIsLessThanMax) {
|
if (upgradeVersion && clusterVersion !== nodeVersion) {
|
||||||
set(this, 'nodePool.version', clusterVersion);
|
set(this, 'nodePool.version', clusterVersion);
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
{{t
|
{{t
|
||||||
"nodeGroupRow.version.upgrade"
|
"nodeGroupRow.version.upgrade"
|
||||||
from=nodePool.version
|
from=nodePool.version
|
||||||
version=controlPlaneVersion
|
version=clusterVersion
|
||||||
}}
|
}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue