From 8906dd18cd72a00d1be0845fa805aff6ccab5abe Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Thu, 22 Oct 2020 08:55:12 -0700 Subject: [PATCH] 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 --- .../driver-googlegke/component.js | 54 ++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/lib/shared/addon/components/cluster-driver/driver-googlegke/component.js b/lib/shared/addon/components/cluster-driver/driver-googlegke/component.js index cc1dd1ec1..41be41691 100644 --- a/lib/shared/addon/components/cluster-driver/driver-googlegke/component.js +++ b/lib/shared/addon/components/cluster-driver/driver-googlegke/component.js @@ -325,6 +325,9 @@ export default Component.extend(ClusterDriver, { actions: { clickNext() { + if (isEmpty(get(this, 'config.projectId'))) { + this.parseProjectId(); + } $('BUTTON[type="submit"]').click(); }, @@ -380,18 +383,7 @@ export default Component.extend(ClusterDriver, { return; } - 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) { - } - } + this.parseProjectId(); }), zoneChanged: observer('config.zone', 'zones.[]', function() { @@ -668,6 +660,10 @@ export default Component.extend(ClusterDriver, { }), fetchZones() { + if (this.saved) { + return; + } + return get(this, 'globalStore').rawRequest({ url: '/meta/gkeZones', method: 'POST', @@ -697,6 +693,10 @@ export default Component.extend(ClusterDriver, { }, fetchVersions() { + if (this.saved) { + return; + } + return get(this, 'globalStore').rawRequest({ url: '/meta/gkeVersions', method: 'POST', @@ -720,6 +720,10 @@ export default Component.extend(ClusterDriver, { }, fetchMachineTypes() { + if (this.saved) { + return; + } + return get(this, 'globalStore').rawRequest({ url: '/meta/gkeMachineTypes', method: 'POST', @@ -742,6 +746,10 @@ export default Component.extend(ClusterDriver, { }, fetchNetworks() { + if (this.saved) { + return; + } + return get(this, 'globalStore').rawRequest({ url: '/meta/gkeNetworks', method: 'POST', @@ -768,6 +776,10 @@ export default Component.extend(ClusterDriver, { }, fetchSubnetworks() { + if (this.saved) { + return; + } + const zone = get(this, 'config.zone') const locationType = get(this, 'locationType'); @@ -793,6 +805,10 @@ export default Component.extend(ClusterDriver, { }, fetchServiceAccounts() { + if (this.saved) { + return; + } + return get(this, 'globalStore').rawRequest({ url: '/meta/gkeServiceAccounts', method: 'POST', @@ -936,4 +952,18 @@ export default Component.extend(ClusterDriver, { 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) { + } + } + }, });