Merge pull request #4527 from westlywright/bugs.gke

GKE Bugs
This commit is contained in:
Westly Wright 2021-04-12 17:05:12 -07:00 committed by GitHub
commit cfd4dfa03f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 58 additions and 44 deletions

View File

@ -102,7 +102,7 @@ export const DEFAULT_GKE_CONFIG = {
clusterAddons: { clusterAddons: {
horizontalPodAutoscaling: true, horizontalPodAutoscaling: true,
httpLoadBalancing: true, httpLoadBalancing: true,
networkPolicyConfig: true networkPolicyConfig: false
}, },
clusterIpv4Cidr: null, clusterIpv4Cidr: null,
clusterName: null, clusterName: null,

View File

@ -365,9 +365,17 @@ export default Component.extend(ViewNewEdit, {
}, },
fetchZones() { fetchZones() {
const credentials = get(this, 'config.authEncodedJson'); let credentials = null;
const config = JSON.parse(credentials || '{}'); let config = null;
const { project_id: projectId } = config; let projectId = null;
try {
credentials = get(this, 'config.authEncodedJson');
config = JSON.parse(credentials || '{}');
projectId = get(config, 'project_id');
} catch (error) {
return Promise.reject({ message: 'Invalid JSON' });
}
return get(this, 'globalStore').rawRequest({ return get(this, 'globalStore').rawRequest({
url: '/meta/gkeZones', url: '/meta/gkeZones',

View File

@ -227,7 +227,7 @@ export default Component.extend(ClusterDriver, {
} }
}), }),
clusterSecondaryRangeNameChanged: observer('config.ipAllocationPolicy.clusterSecondaryRangeName', function() { clusterSecondaryRangeNameChanged: observer('config.ipAllocationPolicy.clusterSecondaryRangeName', 'secondaryIpRangeContent.[]', function() {
if (this.isDestroyed || this.isDestroying || this.saving) { if (this.isDestroyed || this.isDestroying || this.saving) {
return; return;
} }
@ -277,22 +277,6 @@ export default Component.extend(ClusterDriver, {
'config.ipAllocationPolicy.subnetworkName': null, 'config.ipAllocationPolicy.subnetworkName': null,
'config.ipAllocationPolicy.nodeIpv4CidrBlock': null, 'config.ipAllocationPolicy.nodeIpv4CidrBlock': null,
}); });
const secondaryIpRangeContent = get(this, 'secondaryIpRangeContent') || []
if (secondaryIpRangeContent.length > 0) {
const value = secondaryIpRangeContent[0] && secondaryIpRangeContent[0].value
setProperties(this, {
'config.ipAllocationPolicy.clusterSecondaryRangeName': value,
'config.ipAllocationPolicy.servicesSecondaryRangeName': value,
});
} else {
setProperties(this, {
'config.ipAllocationPolicy.clusterSecondaryRangeName': null,
'config.ipAllocationPolicy.servicesSecondaryRangeName': null,
});
}
} else { } else {
setProperties(this, { setProperties(this, {
'config.subnetwork': '', 'config.subnetwork': '',
@ -303,7 +287,7 @@ export default Component.extend(ClusterDriver, {
} }
}), }),
servicesSecondaryRangeNameChanged: observer('config.ipAllocationPolicy.servicesSecondaryRangeName', function() { servicesSecondaryRangeNameChanged: observer('config.ipAllocationPolicy.servicesSecondaryRangeName', 'secondaryIpRangeContent.[]', function() {
if (this.isDestroyed || this.isDestroying || this.saving) { if (this.isDestroyed || this.isDestroying || this.saving) {
return; return;
} }
@ -321,7 +305,7 @@ export default Component.extend(ClusterDriver, {
} }
}), }),
secondaryIpRangeContentChange: observer('secondaryIpRangeContent.[]', 'config.ipAllocationPolicy.useIpAliases', function() { secondaryIpRangeContentChange: observer('secondaryIpRangeContent.[]', 'config.ipAllocationPolicy.useIpAliases', 'config.{network,subnetwork}', function() {
if (this.isDestroyed || this.isDestroying || this.saving) { if (this.isDestroyed || this.isDestroying || this.saving) {
return; return;
} }
@ -476,12 +460,12 @@ export default Component.extend(ClusterDriver, {
return merged; return merged;
}), }),
secondaryIpRangeContent: computed('subNetworkContent.[]', 'config.network', function() { secondaryIpRangeContent: computed('subNetworkContent.[]', 'config.{network,subnetwork}', function() {
const { subNetworkContent = [], config: { network } } = this; const { subNetworkContent = [], config: { subnetwork } } = this;
const subNetwork = subNetworkContent.findBy('networkDisplayName', network); const subnetworkMatch = subNetworkContent.findBy('value', subnetwork);
if (subNetwork) { if (subnetworkMatch) {
const { secondaryIpRanges = [] } = subNetwork; const { secondaryIpRanges = [] } = subnetworkMatch;
return secondaryIpRanges.map((s) => { return secondaryIpRanges.map((s) => {
return { return {
@ -598,8 +582,26 @@ export default Component.extend(ClusterDriver, {
return neu; return neu;
}, },
validatePrivateConfig() {
const config = get(this, 'config') || {}
const { privateClusterConfig } = config;
if (isEmpty(privateClusterConfig)) {
return true;
}
if (privateClusterConfig?.enablePrivateNodes && isEmpty(privateClusterConfig?.masterIpv4CidrBlock)) {
this.send('errorHandler', this.intl.t('clusterNew.googlegke.masterIpv4CidrBlock.error'));
return false;
}
return true;
},
willSave() { willSave() {
this.validateNodePools(); this.validateNodePools();
this.validatePrivateConfig();
if (!isEmpty(this.errors)) { if (!isEmpty(this.errors)) {
return false; return false;

View File

@ -456,12 +456,12 @@ export default Component.extend(ClusterDriver, {
return [...defaultSubnetAry, ...mappedSubnets]; return [...defaultSubnetAry, ...mappedSubnets];
}), }),
secondaryIpRangeContent: computed('subNetworkContent.[]', 'config.network', function() { secondaryIpRangeContent: computed('subNetworkContent.[]', 'config.{network,subNetwork}', function() {
const { subNetworkContent = [], config: { network } } = this; const { subNetworkContent = [], config: { subNetwork } } = this;
const subNetwork = subNetworkContent.findBy('networkDisplayName', network); const subNetworkMatch = subNetworkContent.findBy('value', subNetwork);
if (subNetwork) { if (subNetworkMatch) {
const { secondaryIpRanges = [] } = subNetwork; const { secondaryIpRanges = [] } = subNetworkMatch;
return secondaryIpRanges.map((s) => { return secondaryIpRanges.map((s) => {
return { return {

View File

@ -158,7 +158,15 @@ export default Component.extend(ClusterDriver, {
}, },
}, },
locationOrZoneChanged: observer('locationType', 'config.{region,zone}', function() { regionOrZoneChanged: observer('config.{region,zone}', function() {
next(this, () => {
if (this.step > 2) {
this.send('loadClusters');
}
});
}),
locationTypeChanged: observer('locationType', function() {
const { config, locationType } = this; const { config, locationType } = this;
if (locationType === 'zonal') { if (locationType === 'zonal') {
@ -167,20 +175,12 @@ export default Component.extend(ClusterDriver, {
} }
set(this, 'config.zone', 'us-west2-a'); set(this, 'config.zone', 'us-west2-a');
if (!isEmpty(config?.zone)) {
this.send('loadClusters');
}
} else { } else {
if (!isEmpty(get(config, 'zone'))) { if (!isEmpty(get(config, 'zone'))) {
delete this.config.zone; delete this.config.zone;
} }
set(this, 'config.region', 'us-west2'); set(this, 'config.region', 'us-west2');
if (!isEmpty(config?.region)) {
this.send('loadClusters');
}
} }
}), }),

View File

@ -91,7 +91,7 @@
@optionLabelPath="name" @optionLabelPath="name"
@optionValuePath="name" @optionValuePath="name"
@prompt="clusterNew.googlegke.zone.prompt" @prompt="clusterNew.googlegke.zone.prompt"
@value={{config.zone}} @value={{mut config.zone}}
/> />
</div> </div>
{{/if}} {{/if}}

View File

@ -49,6 +49,9 @@
<div class="col span-6"> <div class="col span-6">
<label class="acc-label"> <label class="acc-label">
{{t "clusterNew.googlegke.masterIpv4CidrBlock.label"}} {{t "clusterNew.googlegke.masterIpv4CidrBlock.label"}}
{{#if config.enablePrivateNodes}}
<FieldRequired />
{{/if}}
</label> </label>
{{input {{input
value=config.masterIpv4CidrBlock value=config.masterIpv4CidrBlock

View File

@ -3841,9 +3841,10 @@ clusterNew:
label: Master Authorized Network CIDR Blocks label: Master Authorized Network CIDR Blocks
placeholder: Your Master Authorized Network CIDR Blocks placeholder: Your Master Authorized Network CIDR Blocks
masterIpv4CidrBlock: masterIpv4CidrBlock:
label: Master IP CIDR Block label: Master IPV4 CIDR Block
placeholder: e.g. 10.42.0.0/28 placeholder: e.g. 10.42.0.0/28
help: Master CIDR block size must be /28 help: Master CIDR block size must be /28
error: A Master IPV4 CIDR block is required when creating a private cluster
masterVersion: masterVersion:
label: Kubernetes Version label: Kubernetes Version
prompt: Choose a Version... prompt: Choose a Version...