@@ -121,10 +121,7 @@ func (c *Controller) handleUpdateNp(key string) error {
121121 }
122122 logRate := parseACLLogRate (np .Annotations )
123123
124- providers , err := parsePolicyFor (np )
125- if err != nil {
126- return err
127- }
124+ providers := parsePolicyFor (np )
128125
129126 npName := np .Name
130127 nameArray := []rune (np .Name )
@@ -536,14 +533,14 @@ func (c *Controller) handleDeleteNp(key string) error {
536533 return nil
537534}
538535
539- func parsePolicyFor (np * netv1.NetworkPolicy ) ( set.Set [string ], error ) {
536+ func parsePolicyFor (np * netv1.NetworkPolicy ) set.Set [string ] {
540537 raw := strings .TrimSpace (np .Annotations [util .NetworkPolicyForAnnotation ])
541538 if raw == "" {
542- return nil , nil
539+ return nil
543540 }
544541
545542 providers := set .New [string ]()
546- invalidMsg := `ignore invalid network_policy_for entry %q, expect "ovn" or "<namespace>/<net-attach-def>"`
543+ invalidMsg := `ignore invalid network_policy_for annotation %q for netpol %s/%s , expect "ovn" or "<namespace>/<net-attach-def>"`
547544
548545 for _ , token := range strings .Split (raw , "," ) {
549546 t := strings .TrimSpace (token )
@@ -558,21 +555,21 @@ func parsePolicyFor(np *netv1.NetworkPolicy) (set.Set[string], error) {
558555 if strings .Contains (t , "/" ) {
559556 parts := strings .SplitN (t , "/" , 2 )
560557 if len (parts ) != 2 || parts [0 ] == "" || parts [1 ] == "" {
561- klog .Warningf (invalidMsg , t )
558+ klog .Warningf (invalidMsg , t , np . Namespace , np . Name )
562559 continue
563560 }
564561 provider := fmt .Sprintf ("%s.%s.%s" , parts [1 ], parts [0 ], util .OvnProvider )
565562 providers .Insert (provider )
566563 continue
567564 }
568- klog .Warningf (invalidMsg , t )
565+ klog .Warningf (invalidMsg , t , np . Namespace , np . Name )
569566 }
570567
571568 if len (providers ) == 0 {
572- klog .Warning ("network_policy_for annotation has no valid entries; policy selects no pods" )
573- return providers , nil
569+ klog .Warningf ("network_policy_for annotation has no valid entries; policy %s/%s selects no pods" , np . Namespace , np . Name )
570+ return providers
574571 }
575- return providers , nil
572+ return providers
576573}
577574
578575func netpolAppliesToProvider (provider string , providers set.Set [string ]) bool {
@@ -609,8 +606,7 @@ func (c *Controller) fetchSelectedPorts(namespace string, selector *metav1.Label
609606 if ! isOvnSubnet (podNet .Subnet ) {
610607 continue
611608 }
612- provider := podNet .ProviderName
613- if ! netpolAppliesToProvider (provider , providers ) {
609+ if ! netpolAppliesToProvider (podNet .ProviderName , providers ) {
614610 continue
615611 }
616612 matchedProvider = true
0 commit comments