gke project id not set before fetching cluster resources

this issue cropped up after a large dependency upgrade and I believe it has to do with some underlying ember changes. Basically we'd hit a race condition where we'd click next before the observer has had a chance to update the project id.
Found an additional issue where the observer on zone change would cause all the fetchs to fire again after the cluster has saved because we merge the results, I added checks to see if we'd saved as saving was already set false but we hadn't started destroying yet.

rancher/rancher#29646
This commit is contained in:
Westly Wright 2020-10-22 08:55:12 -07:00
parent 046f203b41
commit 8906dd18cd
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
1 changed files with 42 additions and 12 deletions

View File

@ -325,6 +325,9 @@ export default Component.extend(ClusterDriver, {
actions: { actions: {
clickNext() { clickNext() {
if (isEmpty(get(this, 'config.projectId'))) {
this.parseProjectId();
}
$('BUTTON[type="submit"]').click(); $('BUTTON[type="submit"]').click();
}, },
@ -380,18 +383,7 @@ export default Component.extend(ClusterDriver, {
return; return;
} }
const str = get(this, 'config.credential'); this.parseProjectId();
if ( str ) {
try {
const obj = JSON.parse(str);
// Note: this is a Google project id, not ours.
const projectId = obj.project_id;
set(this, 'config.projectId', projectId);
} catch (e) {
}
}
}), }),
zoneChanged: observer('config.zone', 'zones.[]', function() { zoneChanged: observer('config.zone', 'zones.[]', function() {
@ -668,6 +660,10 @@ export default Component.extend(ClusterDriver, {
}), }),
fetchZones() { fetchZones() {
if (this.saved) {
return;
}
return get(this, 'globalStore').rawRequest({ return get(this, 'globalStore').rawRequest({
url: '/meta/gkeZones', url: '/meta/gkeZones',
method: 'POST', method: 'POST',
@ -697,6 +693,10 @@ export default Component.extend(ClusterDriver, {
}, },
fetchVersions() { fetchVersions() {
if (this.saved) {
return;
}
return get(this, 'globalStore').rawRequest({ return get(this, 'globalStore').rawRequest({
url: '/meta/gkeVersions', url: '/meta/gkeVersions',
method: 'POST', method: 'POST',
@ -720,6 +720,10 @@ export default Component.extend(ClusterDriver, {
}, },
fetchMachineTypes() { fetchMachineTypes() {
if (this.saved) {
return;
}
return get(this, 'globalStore').rawRequest({ return get(this, 'globalStore').rawRequest({
url: '/meta/gkeMachineTypes', url: '/meta/gkeMachineTypes',
method: 'POST', method: 'POST',
@ -742,6 +746,10 @@ export default Component.extend(ClusterDriver, {
}, },
fetchNetworks() { fetchNetworks() {
if (this.saved) {
return;
}
return get(this, 'globalStore').rawRequest({ return get(this, 'globalStore').rawRequest({
url: '/meta/gkeNetworks', url: '/meta/gkeNetworks',
method: 'POST', method: 'POST',
@ -768,6 +776,10 @@ export default Component.extend(ClusterDriver, {
}, },
fetchSubnetworks() { fetchSubnetworks() {
if (this.saved) {
return;
}
const zone = get(this, 'config.zone') const zone = get(this, 'config.zone')
const locationType = get(this, 'locationType'); const locationType = get(this, 'locationType');
@ -793,6 +805,10 @@ export default Component.extend(ClusterDriver, {
}, },
fetchServiceAccounts() { fetchServiceAccounts() {
if (this.saved) {
return;
}
return get(this, 'globalStore').rawRequest({ return get(this, 'globalStore').rawRequest({
url: '/meta/gkeServiceAccounts', url: '/meta/gkeServiceAccounts',
method: 'POST', method: 'POST',
@ -936,4 +952,18 @@ export default Component.extend(ClusterDriver, {
return this._super(...arguments); return this._super(...arguments);
}, },
parseProjectId() {
const str = get(this, 'config.credential');
if ( str ) {
try {
const obj = JSON.parse(str);
// Note: this is a Google project id, not ours.
const projectId = obj.project_id;
set(this, 'config.projectId', projectId);
} catch (e) {
}
}
},
}); });