Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 40fb834

Browse files
author
Harry Zhang
committed
Randomize service container name
1 parent 841d883 commit 40fb834

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

daemon/list.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package daemon
22

33
import (
44
"fmt"
5+
"strings"
56

67
"github.com/hyperhq/runv/hypervisor"
78
"github.com/hyperhq/runv/hypervisor/types"
@@ -104,10 +105,10 @@ func filterPodContainers(pod *hypervisor.PodStatus, aux bool) []*hypervisor.Cont
104105
results := make([]*hypervisor.ContainerStatus, 0)
105106

106107
filterServiceDiscovery := !aux && (pod.Type == "service-discovery")
107-
proxyName := "/" + ServiceDiscoveryContainerName(pod.Name)
108108

109109
for _, c := range pod.Containers {
110-
if filterServiceDiscovery && c.Name == proxyName {
110+
// NOTE(harry) filter out containers ended with "service-discovery" which is for internal usage
111+
if filterServiceDiscovery && strings.HasSuffix(c.Name, "service-discovery") {
111112
continue
112113
}
113114
results = append(results, c)

daemon/servicediscovery.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,5 @@ func ParseServiceDiscovery(id string, spec *pod.UserPod) error {
165165
}
166166

167167
func ServiceDiscoveryContainerName(podName string) string {
168-
return podName + "-service-discovery"
168+
return podName + "-" + utils.RandStr(10, "alpha") + "-service-discovery"
169169
}

0 commit comments

Comments
 (0)