Skip to content

Commit e52a183

Browse files
committed
fixed error handling code
1 parent 3660c88 commit e52a183

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

cns/middlewares/k8sSwiftV2_windows.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,32 @@ func (k *K8sSWIFTv2Middleware) addDefaultRoute(podIPInfo *cns.PodIpInfo, gwIP st
6565
}
6666

6767
func addDefaultDenyACL(podIPInfo *cns.PodIpInfo) error {
68+
valueOut, err := getDefaultDenyACLPolicy(hcn.DirectionTypeOut)
69+
if err != nil {
70+
fmt.Printf("Failed to get default deny ACL policy egress: %v\n", err)
71+
return err
72+
}
73+
74+
valueIn, err := getDefaultDenyACLPolicy(hcn.DirectionTypeOut)
75+
if err != nil {
76+
fmt.Printf("Failed to get default deny ACL policy ingress: %v\n", err)
77+
return err
78+
}
6879
additionalArgs := []cni.KVPair{
6980
{
7081
Name: "EndpointPolicy",
71-
Value: getDefaultDenyACLPolicy(hcn.DirectionTypeOut),
82+
Value: valueOut,
7283
},
7384
{
7485
Name: "EndpointPolicy",
75-
Value: getDefaultDenyACLPolicy(hcn.DirectionTypeIn),
86+
Value: valueIn,
7687
},
7788
}
7889
podIPInfo.DefaultDenyACL = append(podIPInfo.DefaultDenyACL, additionalArgs...)
7990
return nil
8091
}
8192

82-
func getDefaultDenyACLPolicy(direction hcn.DirectionType) []byte {
93+
func getDefaultDenyACLPolicy(direction hcn.DirectionType) ([]byte, error) {
8394
denyACL := map[string]interface{}{
8495
"Type": "ACL",
8596
"Action": hcn.ActionTypeBlock,
@@ -89,7 +100,7 @@ func getDefaultDenyACLPolicy(direction hcn.DirectionType) []byte {
89100
denyACLJSON, err := json.Marshal(denyACL)
90101
if err != nil {
91102
fmt.Println("Error marshaling default deny policy:", err)
92-
return nil
103+
return nil, nil
93104
}
94-
return denyACLJSON
105+
return denyACLJSON, nil
95106
}

0 commit comments

Comments
 (0)