mirror of https://github.com/portainer/portainer
fix(apps): don't delete the 'kubernetes' service or duplicate service names [r8s-124] (#90)
parent
e9fc6d5598
commit
cd8c6d1ce0
|
@ -341,7 +341,7 @@ func updateApplicationWithService(application *models.K8sApplication, services [
|
||||||
for _, service := range services {
|
for _, service := range services {
|
||||||
serviceSelector := labels.SelectorFromSet(service.Spec.Selector)
|
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.ServiceType = string(service.Spec.Type)
|
||||||
application.Services = append(application.Services, service)
|
application.Services = append(application.Services, service)
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,20 +151,16 @@ function getServicesFromApplications(
|
||||||
(namespaceServicesMap, application) => {
|
(namespaceServicesMap, application) => {
|
||||||
const serviceNames =
|
const serviceNames =
|
||||||
application.Services?.map((service) => service.metadata?.name).filter(
|
application.Services?.map((service) => service.metadata?.name).filter(
|
||||||
(name): name is string => !!name
|
(name) => name !== undefined
|
||||||
) || [];
|
) || [];
|
||||||
if (namespaceServicesMap[application.ResourcePool]) {
|
const existingServices =
|
||||||
return {
|
namespaceServicesMap[application.ResourcePool] || [];
|
||||||
...namespaceServicesMap,
|
const uniqueServicesForNamespace = Array.from(
|
||||||
[application.ResourcePool]: [
|
new Set([...existingServices, ...serviceNames])
|
||||||
...namespaceServicesMap[application.ResourcePool],
|
);
|
||||||
...serviceNames,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
...namespaceServicesMap,
|
...namespaceServicesMap,
|
||||||
[application.ResourcePool]: serviceNames,
|
[application.ResourcePool]: uniqueServicesForNamespace,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{}
|
{}
|
||||||
|
|
Loading…
Reference in New Issue