mirror of https://github.com/portainer/portainer
fix issue on editing app with persisted folder (#6646)
Co-authored-by: Richard Wei <dgui.wei@gmail.com>pull/6728/head
parent
2059a9e064
commit
7e28b3ca3f
|
@ -281,47 +281,50 @@ class KubernetesApplicationHelper {
|
|||
let services = [];
|
||||
if (app.Services) {
|
||||
app.Services.forEach(function (service) {
|
||||
const svc = new KubernetesService();
|
||||
svc.Namespace = service.metadata.namespace;
|
||||
svc.Name = service.metadata.name;
|
||||
svc.StackName = service.StackName;
|
||||
svc.ApplicationOwner = app.ApplicationOwner;
|
||||
svc.ApplicationName = app.ApplicationName;
|
||||
svc.Type = service.spec.type;
|
||||
if (service.spec.type === KubernetesServiceTypes.CLUSTER_IP) {
|
||||
svc.Type = 1;
|
||||
} else if (service.spec.type === KubernetesServiceTypes.NODE_PORT) {
|
||||
svc.Type = 2;
|
||||
} else if (service.spec.type === KubernetesServiceTypes.LOAD_BALANCER) {
|
||||
svc.Type = 3;
|
||||
}
|
||||
//skip generate formValues if service = headless service ( clusterIp === "None" )
|
||||
if (service.spec.clusterIP !== 'None') {
|
||||
const svc = new KubernetesService();
|
||||
svc.Namespace = service.metadata.namespace;
|
||||
svc.Name = service.metadata.name;
|
||||
svc.StackName = service.StackName;
|
||||
svc.ApplicationOwner = app.ApplicationOwner;
|
||||
svc.ApplicationName = app.ApplicationName;
|
||||
svc.Type = service.spec.type;
|
||||
if (service.spec.type === KubernetesServiceTypes.CLUSTER_IP) {
|
||||
svc.Type = 1;
|
||||
} else if (service.spec.type === KubernetesServiceTypes.NODE_PORT) {
|
||||
svc.Type = 2;
|
||||
} else if (service.spec.type === KubernetesServiceTypes.LOAD_BALANCER) {
|
||||
svc.Type = 3;
|
||||
}
|
||||
|
||||
let ports = [];
|
||||
service.spec.ports.forEach(function (port) {
|
||||
const svcport = new KubernetesServicePort();
|
||||
svcport.name = port.name;
|
||||
svcport.port = port.port;
|
||||
svcport.nodePort = port.nodePort;
|
||||
svcport.protocol = port.protocol;
|
||||
svcport.targetPort = port.targetPort;
|
||||
let ports = [];
|
||||
service.spec.ports.forEach(function (port) {
|
||||
const svcport = new KubernetesServicePort();
|
||||
svcport.name = port.name;
|
||||
svcport.port = port.port;
|
||||
svcport.nodePort = port.nodePort;
|
||||
svcport.protocol = port.protocol;
|
||||
svcport.targetPort = port.targetPort;
|
||||
|
||||
app.Ingresses.value.forEach((ingress) => {
|
||||
const ingressMatched = _.find(ingress.Paths, { ServiceName: service.metadata.name });
|
||||
if (ingressMatched) {
|
||||
svcport.ingress = {
|
||||
IngressName: ingressMatched.IngressName,
|
||||
Host: ingressMatched.Host,
|
||||
Path: ingressMatched.Path,
|
||||
};
|
||||
svc.Ingress = true;
|
||||
}
|
||||
app.Ingresses.value.forEach((ingress) => {
|
||||
const ingressMatched = _.find(ingress.Paths, { ServiceName: service.metadata.name });
|
||||
if (ingressMatched) {
|
||||
svcport.ingress = {
|
||||
IngressName: ingressMatched.IngressName,
|
||||
Host: ingressMatched.Host,
|
||||
Path: ingressMatched.Path,
|
||||
};
|
||||
svc.Ingress = true;
|
||||
}
|
||||
});
|
||||
|
||||
ports.push(svcport);
|
||||
});
|
||||
|
||||
ports.push(svcport);
|
||||
});
|
||||
svc.Ports = ports;
|
||||
svc.Selector = app.Raw.spec.selector.matchLabels;
|
||||
services.push(svc);
|
||||
svc.Ports = ports;
|
||||
svc.Selector = app.Raw.spec.selector.matchLabels;
|
||||
services.push(svc);
|
||||
}
|
||||
});
|
||||
|
||||
return services;
|
||||
|
|
|
@ -429,10 +429,10 @@ class KubernetesApplicationService {
|
|||
if (apiService === this.KubernetesStatefulSetService) {
|
||||
const headlessServicePayload = angular.copy(payload);
|
||||
headlessServicePayload.Name = application instanceof KubernetesStatefulSet ? application.ServiceName : application.HeadlessServiceName;
|
||||
await this.KubernetesServiceService.delete(headlessServicePayload);
|
||||
}
|
||||
|
||||
if (application.ServiceType) {
|
||||
// delete headless service && non-headless service
|
||||
await this.KubernetesServiceService.delete(application.Services);
|
||||
|
||||
if (application.Ingresses.length) {
|
||||
|
|
|
@ -257,7 +257,7 @@
|
|||
This application is not exposing any port.
|
||||
</div>
|
||||
|
||||
<div ng-if="ctrl.application.PublishedPorts.length > 0">
|
||||
<div ng-if="ctrl.application.Services.length !== 0">
|
||||
<!-- Services notice -->
|
||||
<div>
|
||||
<div class="small text-muted">
|
||||
|
|
|
@ -237,37 +237,39 @@ function getVolumeClaimUpdateResourceSummary(oldPVC, newPVC) {
|
|||
// getServiceUpdateResourceSummary replicates KubernetesServiceService.patch
|
||||
function getServiceUpdateResourceSummary(oldServices, newServices) {
|
||||
let summary = [];
|
||||
newServices.forEach((newService) => {
|
||||
const oldServiceMatched = _.find(oldServices, { Name: newService.Name });
|
||||
if (oldServiceMatched) {
|
||||
const payload = KubernetesServiceConverter.patchPayload(oldServiceMatched, newService);
|
||||
if (payload.length) {
|
||||
const serviceUpdate = {
|
||||
action: UPDATE,
|
||||
kind: KubernetesResourceTypes.SERVICE,
|
||||
name: oldServiceMatched.Name,
|
||||
type: oldServiceMatched.Type || KubernetesServiceTypes.CLUSTER_IP,
|
||||
};
|
||||
summary.push(serviceUpdate);
|
||||
// skip update summary when service is headless service
|
||||
if (!oldServices.Headless) {
|
||||
newServices.forEach((newService) => {
|
||||
const oldServiceMatched = _.find(oldServices, { Name: newService.Name });
|
||||
if (oldServiceMatched) {
|
||||
const payload = KubernetesServiceConverter.patchPayload(oldServiceMatched, newService);
|
||||
if (payload.length) {
|
||||
const serviceUpdate = {
|
||||
action: UPDATE,
|
||||
kind: KubernetesResourceTypes.SERVICE,
|
||||
name: oldServiceMatched.Name,
|
||||
type: oldServiceMatched.Type || KubernetesServiceTypes.CLUSTER_IP,
|
||||
};
|
||||
summary.push(serviceUpdate);
|
||||
}
|
||||
} else {
|
||||
const emptyService = new KubernetesService();
|
||||
const payload = KubernetesServiceConverter.patchPayload(emptyService, newService);
|
||||
if (payload.length) {
|
||||
const serviceCreate = { action: CREATE, kind: KubernetesResourceTypes.SERVICE, name: newService.Name, type: newService.Type || KubernetesServiceTypes.CLUSTER_IP };
|
||||
summary.push(serviceCreate);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const emptyService = new KubernetesService();
|
||||
const payload = KubernetesServiceConverter.patchPayload(emptyService, newService);
|
||||
if (payload.length) {
|
||||
const serviceCreate = { action: CREATE, kind: KubernetesResourceTypes.SERVICE, name: newService.Name, type: newService.Type || KubernetesServiceTypes.CLUSTER_IP };
|
||||
summary.push(serviceCreate);
|
||||
});
|
||||
|
||||
oldServices.forEach((oldService) => {
|
||||
const newServiceMatched = _.find(newServices, { Name: oldService.Name });
|
||||
if (!newServiceMatched) {
|
||||
const serviceDelete = { action: DELETE, kind: KubernetesResourceTypes.SERVICE, name: oldService.Name, type: oldService.Type || KubernetesServiceTypes.CLUSTER_IP };
|
||||
summary.push(serviceDelete);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
oldServices.forEach((oldService) => {
|
||||
const newServiceMatched = _.find(newServices, { Name: oldService.Name });
|
||||
if (!newServiceMatched) {
|
||||
const serviceDelete = { action: DELETE, kind: KubernetesResourceTypes.SERVICE, name: oldService.Name, type: oldService.Type || KubernetesServiceTypes.CLUSTER_IP };
|
||||
summary.push(serviceDelete);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
if (summary.length !== 0) {
|
||||
return summary;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue