@@ -146,12 +146,18 @@ func (b *bridgeConfiguration) delNetworkBridgeConfig(nInfo util.NetInfo) {
146146 delete (b .netConfig , nInfo .GetNetworkName ())
147147}
148148
149- // getActiveNetworkBridgeConfig returns a shallow copy of the network configuration corresponding to the
149+ func (b * bridgeConfiguration ) getNetworkBridgeConfig (networkName string ) * bridgeUDNConfiguration {
150+ b .Lock ()
151+ defer b .Unlock ()
152+ return b .netConfig [networkName ]
153+ }
154+
155+ // getActiveNetworkBridgeConfigCopy returns a shallow copy of the network configuration corresponding to the
150156// provided netInfo.
151157//
152158// NOTE: if the network configuration can't be found or if the network is not patched by OVN
153159// yet this returns nil.
154- func (b * bridgeConfiguration ) getActiveNetworkBridgeConfig (networkName string ) * bridgeUDNConfiguration {
160+ func (b * bridgeConfiguration ) getActiveNetworkBridgeConfigCopy (networkName string ) * bridgeUDNConfiguration {
155161 b .Lock ()
156162 defer b .Unlock ()
157163
@@ -917,9 +923,18 @@ func (udng *UserDefinedNetworkGateway) Reconcile() {
917923func (udng * UserDefinedNetworkGateway ) doReconcile () error {
918924 klog .Infof ("Reconciling gateway with updates for UDN %s" , udng .GetNetworkName ())
919925
926+ // shouldn't happen
927+ if udng .openflowManager == nil || udng .openflowManager .defaultBridge == nil {
928+ return fmt .Errorf ("openflow manager with default bridge configuration has not been provided for network %s" , udng .GetNetworkName ())
929+ }
930+
920931 // update bridge configuration
921932 isNetworkAdvertised := util .IsPodNetworkAdvertisedAtNode (udng .NetInfo , udng .node .Name )
922- udng .openflowManager .defaultBridge .netConfig [udng .GetNetworkName ()].advertised .Store (isNetworkAdvertised )
933+ netConfig := udng .openflowManager .defaultBridge .getNetworkBridgeConfig (udng .GetNetworkName ())
934+ if netConfig == nil {
935+ return fmt .Errorf ("missing bridge configuration for network %s" , udng .GetNetworkName ())
936+ }
937+ netConfig .advertised .Store (isNetworkAdvertised )
923938
924939 if err := udng .updateUDNVRFIPRules (isNetworkAdvertised ); err != nil {
925940 return fmt .Errorf ("error while updating ip rule for UDN %s: %s" , udng .GetNetworkName (), err )
0 commit comments