@@ -22,25 +22,23 @@ func (endpoint *EndpointInfo) HotAttachEndpoint(containerID string) error {
2222
2323// ConstructEndpointID constructs endpoint name from netNsPath.
2424func ConstructEndpointID (containerID string , netNsPath string , ifName string ) (string , string ) {
25- infraEpName , workloadEpName := "" , ""
26-
2725 if len (containerID ) > 8 {
2826 containerID = containerID [:8 ]
2927 }
3028
31- if netNsPath != "" {
32- splits := strings .Split (netNsPath , ":" )
29+ infraEpName , workloadEpName := "" , ""
30+
31+ splits := strings .Split (netNsPath , ":" )
32+ if len (splits ) == 2 {
3333 // For workload containers, we extract its linking infrastructure container ID.
34- if len (splits ) == 2 {
35- if len (splits [1 ]) > 8 {
36- splits [1 ] = splits [1 ][:8 ]
37- }
38- infraEpName = splits [1 ] + "-" + ifName
39- workloadEpName = containerID + "-" + ifName
40- } else {
41- // For infrastructure containers, we just use its container ID.
42- infraEpName = containerID + "-" + ifName
34+ if len (splits [1 ]) > 8 {
35+ splits [1 ] = splits [1 ][:8 ]
4336 }
37+ infraEpName = splits [1 ] + "-" + ifName
38+ workloadEpName = containerID + "-" + ifName
39+ } else {
40+ // For infrastructure containers, we use its container ID directly.
41+ infraEpName = containerID + "-" + ifName
4442 }
4543
4644 return infraEpName , workloadEpName
0 commit comments