fix(app): don't attach all ingresses to app [EE-5686] (#10537)

pull/10448/head
Ali 2023-10-27 04:59:45 +01:00 committed by GitHub
parent 26036c05f2
commit 47fa1626c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 9 deletions

View File

@ -284,7 +284,7 @@ class KubernetesApplicationConverter {
res.ApplicationType = app.ApplicationType;
res.ResourcePool = _.find(resourcePools, ['Namespace.Name', app.ResourcePool]);
res.Name = app.Name;
res.Services = KubernetesApplicationHelper.generateServicesFormValuesFromServices(app);
res.Services = KubernetesApplicationHelper.generateServicesFormValuesFromServices(app, ingresses);
res.Selector = KubernetesApplicationHelper.generateSelectorFromService(app);
res.StackName = app.StackName;
res.ApplicationOwner = app.ApplicationOwner;

View File

@ -271,7 +271,7 @@ class KubernetesApplicationHelper {
/* #endregion */
/* #region SERVICES -> SERVICES FORM VALUES */
static generateServicesFormValuesFromServices(app) {
static generateServicesFormValuesFromServices(app, ingresses) {
let services = [];
if (app.Services) {
app.Services.forEach(function (service) {
@ -303,7 +303,7 @@ class KubernetesApplicationHelper {
svcport.serviceName = service.metadata.name;
svcport.ingressPaths = [];
app.Ingresses.value.forEach((ingress) => {
ingresses.forEach((ingress) => {
const matchingIngressPaths = ingress.Paths.filter((ingPath) => ingPath.ServiceName === service.metadata.name && ingPath.Port === port.port);
// only add ingress info to the port if the ingress serviceport and name matches
const newPaths = matchingIngressPaths.map((ingPath) => ({

View File

@ -125,7 +125,6 @@ class KubernetesApplicationService {
const boundScaler = KubernetesHorizontalPodAutoScalerHelper.findApplicationBoundScaler(autoScalers.value, application);
const scaler = boundScaler ? await this.KubernetesHorizontalPodAutoScalerService.get(namespace, boundScaler.Name) : undefined;
application.AutoScaler = scaler;
application.Ingresses = ingresses;
if (service.Yaml) {
application.Yaml += '---\n' + service.Yaml;
@ -183,7 +182,6 @@ class KubernetesApplicationService {
const boundScaler = KubernetesHorizontalPodAutoScalerHelper.findApplicationBoundScaler(autoScalers, application);
const scaler = boundScaler ? await this.KubernetesHorizontalPodAutoScalerService.get(ns, boundScaler.Name) : undefined;
application.AutoScaler = scaler;
application.Ingresses = await this.KubernetesIngressService.get(ns);
})
);
return applications;
@ -451,7 +449,8 @@ class KubernetesApplicationService {
if (application.ServiceType) {
// delete headless service && non-headless service
await this.KubernetesServiceService.delete(application.Services);
if (application.Ingresses.length) {
const appHasIngressPath = application.PublishedPorts && application.PublishedPorts.flatMap((pp) => pp.IngressRules).length >= 1;
if (appHasIngressPath) {
const originalIngresses = await this.KubernetesIngressService.get(payload.Namespace);
const formValues = {
OriginalIngresses: originalIngresses,

View File

@ -54,9 +54,10 @@ export function AppIngressPathsForm({
?.filter((ic) => ic.Availability)
.map((ic) => ic.ClassName) || [];
const allowedIngresses =
ingresses?.filter((ing) =>
allowedIngressClasses.includes(ing.ClassName)
) || [];
ingresses?.filter((ing) => {
const className = ing.ClassName || 'none';
return allowedIngressClasses.includes(className);
}) || [];
return allowedIngresses.flatMap((ing) =>
ing.Hosts?.length
? ing.Hosts.map((host) => ({