fix(frontend): When a docker endpoint is selected, configuring a newly added k8s agent fails EE-821 (#5115)
* fix(frontend): When a docker endpoint is selected, configuring a newly added k8s agent fails EE-821 * fix(frontend): restore endpointID in a finally block EE-821 Co-authored-by: Simon Meng <simon.meng@portainer.io>release/2.5
parent
1d46f2bb35
commit
1f2a90a722
|
@ -139,20 +139,32 @@ class KubernetesConfigureController {
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeIngressesAcrossNamespaces() {
|
async removeIngressesAcrossNamespaces() {
|
||||||
const promises = [];
|
|
||||||
const ingressesToDel = _.filter(this.formValues.IngressClasses, { NeedsDeletion: true });
|
const ingressesToDel = _.filter(this.formValues.IngressClasses, { NeedsDeletion: true });
|
||||||
const allResourcePools = await this.KubernetesResourcePoolService.get();
|
|
||||||
const resourcePools = _.filter(
|
|
||||||
allResourcePools,
|
|
||||||
(resourcePool) =>
|
|
||||||
!this.KubernetesNamespaceHelper.isSystemNamespace(resourcePool.Namespace.Name) && !this.KubernetesNamespaceHelper.isDefaultNamespace(resourcePool.Namespace.Name)
|
|
||||||
);
|
|
||||||
|
|
||||||
ingressesToDel.forEach((ingress) => {
|
if (!ingressesToDel.length) {
|
||||||
resourcePools.forEach((resourcePool) => {
|
return;
|
||||||
promises.push(this.KubernetesIngressService.delete(resourcePool.Namespace.Name, ingress.Name));
|
}
|
||||||
|
|
||||||
|
const promises = [];
|
||||||
|
const oldEndpointID = this.EndpointProvider.endpointID();
|
||||||
|
this.EndpointProvider.setEndpointID(this.endpoint.Id);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const allResourcePools = await this.KubernetesResourcePoolService.get();
|
||||||
|
const resourcePools = _.filter(
|
||||||
|
allResourcePools,
|
||||||
|
(resourcePool) =>
|
||||||
|
!this.KubernetesNamespaceHelper.isSystemNamespace(resourcePool.Namespace.Name) && !this.KubernetesNamespaceHelper.isDefaultNamespace(resourcePool.Namespace.Name)
|
||||||
|
);
|
||||||
|
|
||||||
|
ingressesToDel.forEach((ingress) => {
|
||||||
|
resourcePools.forEach((resourcePool) => {
|
||||||
|
promises.push(this.KubernetesIngressService.delete(resourcePool.Namespace.Name, ingress.Name));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} finally {
|
||||||
|
this.EndpointProvider.setEndpointID(oldEndpointID);
|
||||||
|
}
|
||||||
|
|
||||||
const responses = await Promise.allSettled(promises);
|
const responses = await Promise.allSettled(promises);
|
||||||
responses.forEach((respons) => {
|
responses.forEach((respons) => {
|
||||||
|
|
Loading…
Reference in New Issue