mirror of https://github.com/portainer/portainer
fix(k8s): check if app has stack before removing. (#5919)
parent
85a6a80722
commit
ebfabe6c47
|
@ -4,7 +4,7 @@ import KubernetesStackHelper from 'Kubernetes/helpers/stackHelper';
|
|||
import KubernetesApplicationHelper from 'Kubernetes/helpers/application';
|
||||
import KubernetesConfigurationHelper from 'Kubernetes/helpers/configurationHelper';
|
||||
import { KubernetesApplicationTypes } from 'Kubernetes/models/application/models';
|
||||
|
||||
import { KubernetesPortainerApplicationStackNameLabel } from 'Kubernetes/models/application/models';
|
||||
class KubernetesApplicationsController {
|
||||
/* @ngInject */
|
||||
constructor($async, $state, Notifications, KubernetesApplicationService, HelmService, KubernetesConfigurationService, Authentication, ModalService, LocalStorage, StackService) {
|
||||
|
@ -81,13 +81,17 @@ class KubernetesApplicationsController {
|
|||
await this.HelmService.uninstall(this.endpoint.Id, application);
|
||||
} else {
|
||||
await this.KubernetesApplicationService.delete(application);
|
||||
// Update applications in stack
|
||||
const stack = this.state.stacks.find((x) => x.Name === application.StackName);
|
||||
const index = stack.Applications.indexOf(application);
|
||||
stack.Applications.splice(index, 1);
|
||||
// remove stack if no app left in the stack
|
||||
if (stack.Applications.length === 0 && application.StackId) {
|
||||
await this.StackService.remove({ Id: application.StackId }, false, this.endpoint.Id);
|
||||
|
||||
if (application.Metadata.labels[KubernetesPortainerApplicationStackNameLabel]) {
|
||||
// Update applications in stack
|
||||
const stack = this.state.stacks.find((x) => x.Name === application.StackName);
|
||||
const index = stack.Applications.indexOf(application);
|
||||
stack.Applications.splice(index, 1);
|
||||
|
||||
// remove stack if no app left in the stack
|
||||
if (stack.Applications.length === 0 && application.StackId) {
|
||||
await this.StackService.remove({ Id: application.StackId }, false, this.endpoint.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.Notifications.success('Application successfully removed', application.Name);
|
||||
|
|
Loading…
Reference in New Issue