@@ -649,30 +649,27 @@ func deletePodSNATOps(nbClient libovsdbclient.Client, ops []ovsdb.Operation, gwR
649649// addOrUpdatePodSNAT adds or updates per pod SNAT rules towards the nodeIP that are applied to the GR where the pod resides
650650// used when disableSNATMultipleGWs=true
651651func addOrUpdatePodSNAT (nbClient libovsdbclient.Client , gwRouterName string , extIPs , podIfAddrs []* net.IPNet ) error {
652- nats , err := buildPodSNAT ( extIPs , podIfAddrs , "" )
652+ ops , err := addOrUpdatePodSNATOps ( nbClient , gwRouterName , extIPs , podIfAddrs , nil )
653653 if err != nil {
654654 return err
655655 }
656- logicalRouter := nbdb.LogicalRouter {
657- Name : gwRouterName ,
658- }
659- if err := libovsdbops .CreateOrUpdateNATs (nbClient , & logicalRouter , nats ... ); err != nil {
660- return fmt .Errorf ("failed to update SNAT for pods of router %s: %v" , logicalRouter .Name , err )
656+ if _ , err = libovsdbops .TransactAndCheck (nbClient , ops ); err != nil {
657+ return fmt .Errorf ("failed to update SNAT for pods of router %s: %v" , gwRouterName , err )
661658 }
662659 return nil
663660}
664661
665662// addOrUpdatePodSNATOps returns the operation that adds or updates per pod SNAT rules towards the nodeIP that are
666663// applied to the GR where the pod resides
667664// used when disableSNATMultipleGWs=true
668- func addOrUpdatePodSNATOps (nbClient libovsdbclient.Client , gwRouterName string , extIPs , podIfAddrs []* net.IPNet , match string , ops []ovsdb.Operation ) ([]ovsdb.Operation , error ) {
669- router := & nbdb.LogicalRouter {Name : gwRouterName }
670- nats , err := buildPodSNAT (extIPs , podIfAddrs , match )
665+ func addOrUpdatePodSNATOps (nbClient libovsdbclient.Client , gwRouterName string , extIPs , podIfAddrs []* net.IPNet , ops []ovsdb.Operation ) ([]ovsdb.Operation , error ) {
666+ gwRouter := & nbdb.LogicalRouter {Name : gwRouterName }
667+ nats , err := buildPodSNAT (extIPs , podIfAddrs , "" )
671668 if err != nil {
672669 return nil , err
673670 }
674- if ops , err = libovsdbops .CreateOrUpdateNATsOps (nbClient , ops , router , nats ... ); err != nil {
675- return nil , fmt .Errorf ("failed to update SNAT for pods of router: %s, error: %v" , gwRouterName , err )
671+ if ops , err = libovsdbops .CreateOrUpdateNATsOps (nbClient , ops , gwRouter , nats ... ); err != nil {
672+ return nil , fmt .Errorf ("failed to create ops to update SNAT for pods of router: %s, error: %v" , gwRouterName , err )
676673 }
677674 return ops , nil
678675}
0 commit comments