mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-02 19:57:42 +08:00
[FIX] Fixed a bug that caused the label length to exceed the limit when opening multiple tcp ports.
This commit is contained in:
parent
d59eb73709
commit
0524c613f2
@ -116,18 +116,32 @@ func (m *Manager) podSource(pods *v1.Pod, method core.EventMethod) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
ppInfo := pods.Labels["protocols"]
|
||||
if ppInfo == "" {
|
||||
ppInfo = "1234_._ptth"
|
||||
}
|
||||
mapPP := make(map[string]string)
|
||||
infoList := strings.Split(ppInfo, "-.-")
|
||||
if len(infoList) > 0 {
|
||||
for _, pps := range infoList {
|
||||
portInfo := strings.Split(pps, "_._")
|
||||
ppInfo, ok := pods.Labels["protocols"]
|
||||
if ok {
|
||||
if ppInfo == "" {
|
||||
ppInfo = "1234_._ptth"
|
||||
}
|
||||
infoList := strings.Split(ppInfo, "-.-")
|
||||
if len(infoList) > 0 {
|
||||
for _, pps := range infoList {
|
||||
portInfo := strings.Split(pps, "_._")
|
||||
mapPP[portInfo[0]] = portInfo[1]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
protocolsNumber := pods.Labels["protocols_number"]
|
||||
number, err := strconv.Atoi(protocolsNumber);
|
||||
if err != nil {
|
||||
logrus.Errorf("ports number converted to int failed:", err.Error())
|
||||
}
|
||||
for i := 0; i < number; i++ {
|
||||
protocol := pods.Labels[fmt.Sprintf("%s_%d", "protocol", i)]
|
||||
portInfo := strings.Split(protocol,"_._")
|
||||
mapPP[portInfo[0]] = portInfo[1]
|
||||
}
|
||||
}
|
||||
|
||||
//protocols: 5000_._http-.-8080_._stream
|
||||
s := &config.SourceBranch{
|
||||
Tenant: pods.Labels["tenant_name"],
|
||||
|
@ -206,14 +206,11 @@ func (p *PodTemplateSpecBuild) Build(creatorID string) (*v1.PodTemplateSpec, err
|
||||
outPorts, err = p.CreateUpstreamPluginMappingPort(outPorts, pluginPorts)
|
||||
}
|
||||
labels["service_type"] = "outer"
|
||||
var pStr string
|
||||
for _, p := range outPorts {
|
||||
if pStr != "" {
|
||||
pStr += "-.-"
|
||||
}
|
||||
pStr += fmt.Sprintf("%d_._%s", p.ContainerPort, p.Protocol)
|
||||
labels["protocols_number"] = string(len(outPorts))
|
||||
for i, p := range outPorts {
|
||||
key := fmt.Sprintf("%s_%d", "protocol", i)
|
||||
labels[key] = fmt.Sprintf("%d_._%s", p.ContainerPort, p.Protocol)
|
||||
}
|
||||
labels["protocols"] = pStr
|
||||
}
|
||||
//step7: set hostname
|
||||
if p.hostName != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user