Skip to content

Commit b6808a6

Browse files
committed
update summery
1 parent 7251f70 commit b6808a6

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

pkg/ibmvpc/examples/out/explain_out/LBToResIPNode_all_vpcs_explain_debug.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Explaining connectivity from kube-clusterid:1-8fdd1d0a2ce34deba99d0f885451b1ca t
22
=================================================================================================================================================
33

44
No connections from from kube-clusterid:1-8fdd1d0a2ce34deba99d0f885451b1ca[LB private IP][192.168.36.6] to iks-clusterid:1[192.168.32.5];
5-
connection is blocked by Load Balancer
5+
connection can not be initiated by Load Balancer
66

77
Load Balancer: kube-clusterid:1-8fdd1d0a2ce34deba99d0f885451b1ca[LoadBalancer] will not connect to iks-clusterid:1[192.168.32.5], since it is not its pool member
88
Egress: security group kube-r006-d7cfb31a-1d4b-40c8-83df-ce2e6f8f2e57 allows connection; network ACL ky-test-edge-acl allows connection

pkg/vpcmodel/explainabilityPrint.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,37 +204,37 @@ func (g *groupedConnLine) explainPerCaseStr(c *VPCConfig, src, dst EndpointElem,
204204
return fmt.Sprintf("%v\tThe dst is external but there is no Floating IP or Public Gateway connecting to public internet\n",
205205
noConnection)
206206
case ingressBlocking || egressBlocking || loadBalancerBlocking:
207-
return fmt.Sprintf("%vconnection is blocked %s"+tripleNLVars, noConnection,
208-
blockedByString(ingressBlocking, egressBlocking, loadBalancerBlocking),
207+
return fmt.Sprintf("%v%s"+tripleNLVars, noConnection,
208+
blockSummery(ingressBlocking, egressBlocking, loadBalancerBlocking),
209209
headerPlusPath, details)
210210
default: // there is a connection
211211
return existingConnectionStr(c, connQuery, src, dst, conn, path, details)
212212
}
213213
}
214214

215-
// blockedByString() return the block string according to the flags
216-
func blockedByString(ingressBlocking, egressBlocking, loadBalancerBlocking bool) string {
215+
// blockSummery() return a summery of the rules that block the connection, for example:
216+
// "connection connection is blocked by egress, and can not be initiated by Load Balancer"
217+
func blockSummery(ingressBlocking, egressBlocking, loadBalancerBlocking bool) string {
217218
blockedBy := []string{}
218-
if loadBalancerBlocking {
219-
blockedBy = append(blockedBy, "Load Balancer")
220-
}
221219
if ingressBlocking {
222220
blockedBy = append(blockedBy, "ingress")
223221
}
224222
if egressBlocking {
225223
blockedBy = append(blockedBy, "egress")
226224
}
227225
l := len(blockedBy)
228-
var blockedByString string
226+
var blockedByString []string
229227
switch l {
230228
case 1:
231-
blockedByString = fmt.Sprintf("by %s", blockedBy[0])
229+
blockedByString = append(blockedByString, fmt.Sprintf("is blocked by %s", blockedBy[0]))
232230
case 2:
233-
blockedByString = fmt.Sprintf("both by %s and %s", blockedBy[0], blockedBy[1])
234-
default:
235-
blockedByString = fmt.Sprintf("by %s and %s", strings.Join(blockedBy[0:l-1], ", "), blockedBy[l-1])
231+
blockedByString = append(blockedByString, fmt.Sprintf("is blocked both by %s and %s", blockedBy[0], blockedBy[1]))
232+
}
233+
234+
if loadBalancerBlocking {
235+
blockedByString = append(blockedByString, "can not be initiated by Load Balancer")
236236
}
237-
return blockedByString
237+
return "connection " + strings.Join(blockedByString, ", and ")
238238
}
239239

240240
func crossRouterDetails(c *VPCConfig, crossVpcRouter RoutingResource, crossVpcRules []RulesInTable,

0 commit comments

Comments
 (0)