mirror of https://github.com/portainer/portainer
fix(app): restrict ns fix create app [EE-5123] (#8633)
Co-authored-by: testa113 <testa113>pull/8648/head
parent
c609f6912f
commit
17517d7521
|
@ -1213,17 +1213,23 @@ class KubernetesCreateApplicationController {
|
||||||
this.allNamespaces = resourcePools.map(({ Namespace }) => Namespace.Name);
|
this.allNamespaces = resourcePools.map(({ Namespace }) => Namespace.Name);
|
||||||
this.resourcePools = _.sortBy(nonSystemNamespaces, ({ Namespace }) => (Namespace.Name === 'default' ? 0 : 1));
|
this.resourcePools = _.sortBy(nonSystemNamespaces, ({ Namespace }) => (Namespace.Name === 'default' ? 0 : 1));
|
||||||
|
|
||||||
const namespaceWithQuota = await this.KubernetesResourcePoolService.get(this.resourcePools[0].Namespace.Name);
|
// this.state.nodes.memory and this.state.nodes.cpu are used to calculate the slider limits, so set them before calling updateSliders()
|
||||||
this.formValues.ResourcePool = this.resourcePools[0];
|
|
||||||
this.formValues.ResourcePool.Quota = namespaceWithQuota.Quota;
|
|
||||||
if (!this.formValues.ResourcePool) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_.forEach(nodes, (item) => {
|
_.forEach(nodes, (item) => {
|
||||||
this.state.nodes.memory += filesizeParser(item.Memory);
|
this.state.nodes.memory += filesizeParser(item.Memory);
|
||||||
this.state.nodes.cpu += item.CPU;
|
this.state.nodes.cpu += item.CPU;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.resourcePools.length) {
|
||||||
|
const namespaceWithQuota = await this.KubernetesResourcePoolService.get(this.resourcePools[0].Namespace.Name);
|
||||||
|
this.formValues.ResourcePool.Quota = namespaceWithQuota.Quota;
|
||||||
|
this.updateNamespaceLimits(namespaceWithQuota);
|
||||||
|
this.updateSliders(namespaceWithQuota);
|
||||||
|
}
|
||||||
|
this.formValues.ResourcePool = this.resourcePools[0];
|
||||||
|
if (!this.formValues.ResourcePool) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.nodesLabels = KubernetesNodeHelper.generateNodeLabelsFromNodes(nodes);
|
this.nodesLabels = KubernetesNodeHelper.generateNodeLabelsFromNodes(nodes);
|
||||||
this.nodeNumber = nodes.length;
|
this.nodeNumber = nodes.length;
|
||||||
|
|
||||||
|
@ -1281,9 +1287,6 @@ class KubernetesCreateApplicationController {
|
||||||
this.formValues.IsPublishingService = this.formValues.PublishedPorts.length > 0;
|
this.formValues.IsPublishingService = this.formValues.PublishedPorts.length > 0;
|
||||||
|
|
||||||
this.oldFormValues = angular.copy(this.formValues);
|
this.oldFormValues = angular.copy(this.formValues);
|
||||||
|
|
||||||
this.updateNamespaceLimits(namespaceWithQuota);
|
|
||||||
this.updateSliders(namespaceWithQuota);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.Notifications.error('Failure', err, 'Unable to load view data');
|
this.Notifications.error('Failure', err, 'Unable to load view data');
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue