fix(apps): don't delete the 'kubernetes' service or duplicate service names [r8s-124] (#90)

pull/12292/merge
Ali 2 weeks ago committed by GitHub
parent e9fc6d5598
commit cd8c6d1ce0

@ -341,7 +341,7 @@ func updateApplicationWithService(application *models.K8sApplication, services [
for _, service := range services {
serviceSelector := labels.SelectorFromSet(service.Spec.Selector)
if service.Namespace == application.ResourcePool && serviceSelector.Matches(labels.Set(application.MatchLabels)) {
if service.Namespace == application.ResourcePool && !serviceSelector.Empty() && serviceSelector.Matches(labels.Set(application.MatchLabels)) {
application.ServiceType = string(service.Spec.Type)
application.Services = append(application.Services, service)
}

@ -151,20 +151,16 @@ function getServicesFromApplications(
(namespaceServicesMap, application) => {
const serviceNames =
application.Services?.map((service) => service.metadata?.name).filter(
(name): name is string => !!name
(name) => name !== undefined
) || [];
if (namespaceServicesMap[application.ResourcePool]) {
return {
...namespaceServicesMap,
[application.ResourcePool]: [
...namespaceServicesMap[application.ResourcePool],
...serviceNames,
],
};
}
const existingServices =
namespaceServicesMap[application.ResourcePool] || [];
const uniqueServicesForNamespace = Array.from(
new Set([...existingServices, ...serviceNames])
);
return {
...namespaceServicesMap,
[application.ResourcePool]: serviceNames,
[application.ResourcePool]: uniqueServicesForNamespace,
};
},
{}

Loading…
Cancel
Save