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.ApplicationType = app.ApplicationType;
res.ResourcePool = _.find(resourcePools, ['Namespace.Name', app.ResourcePool]); res.ResourcePool = _.find(resourcePools, ['Namespace.Name', app.ResourcePool]);
res.Name = app.Name; res.Name = app.Name;
res.Services = KubernetesApplicationHelper.generateServicesFormValuesFromServices(app); res.Services = KubernetesApplicationHelper.generateServicesFormValuesFromServices(app, ingresses);
res.Selector = KubernetesApplicationHelper.generateSelectorFromService(app); res.Selector = KubernetesApplicationHelper.generateSelectorFromService(app);
res.StackName = app.StackName; res.StackName = app.StackName;
res.ApplicationOwner = app.ApplicationOwner; res.ApplicationOwner = app.ApplicationOwner;

View File

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

View File

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

View File

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