mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 05:45:22 +02:00
fix(app): improve resource quota error handling [EE-5933] (#10951)
This commit is contained in:
parent
488fcc7cc5
commit
6d71a28584
9 changed files with 122 additions and 50 deletions
|
@ -1,6 +1,6 @@
|
|||
export const KubernetesApplicationQuotaDefaults = {
|
||||
CpuLimit: 0.1,
|
||||
MemoryLimit: 64, // MB
|
||||
MemoryLimit: 128, // MB
|
||||
};
|
||||
|
||||
export const KubernetesPortainerApplicationStackNameLabel = 'io.portainer.kubernetes.application.stack';
|
||||
|
|
|
@ -7,7 +7,6 @@ import { NamespaceAccessUsersSelector } from '@/react/kubernetes/namespaces/Acce
|
|||
import { RegistriesSelector } from '@/react/kubernetes/namespaces/components/RegistriesFormSection/RegistriesSelector';
|
||||
import { KubeServicesForm } from '@/react/kubernetes/applications/CreateView/application-services/KubeServicesForm';
|
||||
import { kubeServicesValidation } from '@/react/kubernetes/applications/CreateView/application-services/kubeServicesValidation';
|
||||
import { AppDeploymentTypeFormSection } from '@/react/kubernetes/applications/CreateView/AppDeploymentTypeFormSection';
|
||||
import { withReactQuery } from '@/react-tools/withReactQuery';
|
||||
import { withUIRouter } from '@/react-tools/withUIRouter';
|
||||
import {
|
||||
|
@ -56,6 +55,8 @@ import {
|
|||
NameFormSection,
|
||||
appNameValidation,
|
||||
} from '@/react/kubernetes/applications/components/NameFormSection';
|
||||
import { deploymentTypeValidation } from '@/react/kubernetes/applications/components/AppDeploymentTypeFormSection/deploymentTypeValidation';
|
||||
import { AppDeploymentTypeFormSection } from '@/react/kubernetes/applications/components/AppDeploymentTypeFormSection/AppDeploymentTypeFormSection';
|
||||
|
||||
import { EnvironmentVariablesFieldset } from '@@/form-components/EnvironmentVariablesFieldset';
|
||||
|
||||
|
@ -122,14 +123,6 @@ export const ngModule = angular
|
|||
'persistedFoldersUseExistingVolumes',
|
||||
])
|
||||
)
|
||||
.component(
|
||||
'appDeploymentTypeFormSection',
|
||||
r2a(AppDeploymentTypeFormSection, [
|
||||
'value',
|
||||
'onChange',
|
||||
'supportGlobalDeployment',
|
||||
])
|
||||
)
|
||||
.component(
|
||||
'kubeYamlInspector',
|
||||
r2a(withUIRouter(withReactQuery(withCurrentUser(YAMLInspector))), [
|
||||
|
@ -333,3 +326,12 @@ withFormValidation(
|
|||
appNameValidation,
|
||||
true
|
||||
);
|
||||
|
||||
withFormValidation(
|
||||
ngModule,
|
||||
AppDeploymentTypeFormSection,
|
||||
'appDeploymentTypeFormSection',
|
||||
['supportGlobalDeployment'],
|
||||
deploymentTypeValidation,
|
||||
true
|
||||
);
|
||||
|
|
|
@ -294,16 +294,17 @@
|
|||
namespace-has-quota="ctrl.state.resourcePoolHasQuota"
|
||||
max-memory-limit="ctrl.state.sliders.memory.max"
|
||||
max-cpu-limit="ctrl.state.sliders.cpu.max"
|
||||
validation-data="{maxMemoryLimit: ctrl.state.sliders.memory.max, maxCpuLimit: ctrl.state.sliders.cpu.max}"
|
||||
validation-data="{maxMemoryLimit: ctrl.state.sliders.memory.max, maxCpuLimit: ctrl.state.sliders.cpu.max, isEnvironmentAdmin: ctrl.state.isEnvironmentAdmin}"
|
||||
resource-quota-capacity-exceeded="ctrl.resourceQuotaCapacityExceeded()"
|
||||
></resource-reservation-form-section>
|
||||
|
||||
<!-- deployment options -->
|
||||
<app-deployment-type-form-section
|
||||
value="ctrl.formValues.DeploymentType"
|
||||
values="ctrl.formValues.DeploymentType"
|
||||
on-change="(ctrl.onChangeDeploymentType)"
|
||||
support-global-deployment="ctrl.supportGlobalDeployment()"
|
||||
radio-name="'deploymentType'"
|
||||
validation-data="{isQuotaExceeded: ctrl.resourceReservationsOverflow()}"
|
||||
></app-deployment-type-form-section>
|
||||
|
||||
<!-- replica count -->
|
||||
|
|
|
@ -994,13 +994,28 @@ class KubernetesCreateApplicationController {
|
|||
this.state.nodes.cpu += item.CPU;
|
||||
});
|
||||
|
||||
var namespace = '';
|
||||
this.formValues.ResourcePool = this.resourcePools[0];
|
||||
|
||||
if (this.resourcePools.length) {
|
||||
this.namespaceWithQuota = await this.KubernetesResourcePoolService.get(this.resourcePools[0].Namespace.Name);
|
||||
if (this.state.isEdit) {
|
||||
namespace = this.$state.params.namespace;
|
||||
this.formValues.ResourcePool = _.find(this.resourcePools, ['Namespace.Name', namespace]);
|
||||
}
|
||||
|
||||
namespace = this.formValues.ResourcePool.Namespace.Name;
|
||||
this.namespaceWithQuota = await this.KubernetesResourcePoolService.get(namespace);
|
||||
this.formValues.ResourcePool.Quota = this.namespaceWithQuota.Quota;
|
||||
|
||||
// this.savedFormValues is being used in updateNamespaceLimits behind a check to see isEdit
|
||||
if (this.state.isEdit) {
|
||||
this.savedFormValues = angular.copy(this.formValues);
|
||||
}
|
||||
|
||||
this.updateNamespaceLimits(this.namespaceWithQuota);
|
||||
this.updateSliders(this.namespaceWithQuota);
|
||||
}
|
||||
this.formValues.ResourcePool = this.resourcePools[0];
|
||||
|
||||
if (!this.formValues.ResourcePool) {
|
||||
return;
|
||||
}
|
||||
|
@ -1008,7 +1023,6 @@ class KubernetesCreateApplicationController {
|
|||
this.nodesLabels = KubernetesNodeHelper.generateNodeLabelsFromNodes(nodes);
|
||||
this.nodeNumber = nodes.length;
|
||||
|
||||
const namespace = this.state.isEdit ? this.$state.params.namespace : this.formValues.ResourcePool.Namespace.Name;
|
||||
await this.refreshNamespaceData(namespace);
|
||||
|
||||
if (this.state.isEdit) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue