@@ -25,6 +25,8 @@ import (
25
25
"github.com/containernetworking/cni/pkg/version"
26
26
corev1 "k8s.io/api/core/v1"
27
27
"k8s.io/apimachinery/pkg/util/sets"
28
+ clientset "k8s.io/client-go/kubernetes"
29
+ v1 "k8s.io/client-go/listers/core/v1"
28
30
"k8s.io/klog/v2"
29
31
30
32
"antrea.io/antrea/pkg/agent/cniserver/ipam"
@@ -76,9 +78,11 @@ type podConfigurator struct {
76
78
// isSecondaryNetwork is true if this instance of podConfigurator is used to configure
77
79
// Pod secondary network interfaces.
78
80
isSecondaryNetwork bool
81
+ podIfMonitor * podIfaceMonitor
79
82
}
80
83
81
84
func newPodConfigurator (
85
+ kubeClient clientset.Interface ,
82
86
ovsBridgeClient ovsconfig.OVSBridgeClient ,
83
87
ofClient openflow.Client ,
84
88
routeClient route.Interface ,
@@ -88,11 +92,13 @@ func newPodConfigurator(
88
92
isOvsHardwareOffloadEnabled bool ,
89
93
disableTXChecksumOffload bool ,
90
94
podUpdateNotifier channel.Notifier ,
95
+ podLister v1.PodLister ,
91
96
) (* podConfigurator , error ) {
92
97
ifConfigurator , err := newInterfaceConfigurator (ovsDatapathType , isOvsHardwareOffloadEnabled , disableTXChecksumOffload )
93
98
if err != nil {
94
99
return nil , err
95
100
}
101
+ ifMonitor := newPodInterfaceMonitor (kubeClient , podLister , ofClient , ifaceStore , podUpdateNotifier )
96
102
return & podConfigurator {
97
103
ovsBridgeClient : ovsBridgeClient ,
98
104
ofClient : ofClient ,
@@ -101,6 +107,7 @@ func newPodConfigurator(
101
107
gatewayMAC : gatewayMAC ,
102
108
ifConfigurator : ifConfigurator ,
103
109
podUpdateNotifier : podUpdateNotifier ,
110
+ podIfMonitor : ifMonitor ,
104
111
}, nil
105
112
}
106
113
@@ -166,13 +173,13 @@ func getContainerIPsString(ips []net.IP) string {
166
173
// not created for a Pod interface.
167
174
func ParseOVSPortInterfaceConfig (portData * ovsconfig.OVSPortData , portConfig * interfacestore.OVSPortConfig ) * interfacestore.InterfaceConfig {
168
175
if portData .ExternalIDs == nil {
169
- klog .V (2 ).Infof ("OVS port %s has no external_ids" , portData .Name )
176
+ klog .V (2 ).InfoS ("OVS port has no external_ids" , "port " , portData .Name )
170
177
return nil
171
178
}
172
179
173
180
containerID , found := portData .ExternalIDs [ovsExternalIDContainerID ]
174
181
if ! found {
175
- klog .V (2 ).Infof ("OVS port %s has no %s in external_ids" , portData .Name , ovsExternalIDContainerID )
182
+ klog .V (2 ).InfoS ("OVS port has no containerID in external_ids" , "port" , portData .Name )
176
183
return nil
177
184
}
178
185
@@ -187,8 +194,7 @@ func ParseOVSPortInterfaceConfig(portData *ovsconfig.OVSPortData, portConfig *in
187
194
188
195
containerMAC , err := net .ParseMAC (portData .ExternalIDs [ovsExternalIDMAC ])
189
196
if err != nil {
190
- klog .Errorf ("Failed to parse MAC address from OVS external config %s: %v" ,
191
- portData .ExternalIDs [ovsExternalIDMAC ], err )
197
+ klog .ErrorS (err , "Failed to parse MAC address from OVS external config" )
192
198
}
193
199
podName , _ := portData .ExternalIDs [ovsExternalIDPodName ]
194
200
podNamespace , _ := portData .ExternalIDs [ovsExternalIDPodNamespace ]
@@ -279,7 +285,7 @@ func (pc *podConfigurator) createOVSPort(ovsPortName string, ovsAttachInfo map[s
279
285
func (pc * podConfigurator ) removeInterfaces (containerID string ) error {
280
286
containerConfig , found := pc .ifaceStore .GetContainerInterface (containerID )
281
287
if ! found {
282
- klog .V (2 ).Infof ("Did not find the port for container %s in local cache" , containerID )
288
+ klog .V (2 ).InfoS ("Did not find the port for container in local cache" , "container " , containerID )
283
289
return nil
284
290
}
285
291
@@ -498,7 +504,7 @@ func (pc *podConfigurator) reconcile(pods []corev1.Pod, containerAccess *contain
498
504
// disconnectInterfaceFromOVS disconnects an existing interface from ovs br-int.
499
505
func (pc * podConfigurator ) disconnectInterfaceFromOVS (containerConfig * interfacestore.InterfaceConfig ) error {
500
506
containerID := containerConfig .ContainerID
501
- klog .V (2 ).Infof ("Deleting Openflow entries for container %s " , containerID )
507
+ klog .V (2 ).InfoS ("Deleting Openflow entries for container" , "container " , containerID )
502
508
if ! pc .isSecondaryNetwork {
503
509
if err := pc .ofClient .UninstallPodFlows (containerConfig .InterfaceName ); err != nil {
504
510
return fmt .Errorf ("failed to delete Openflow entries for container %s: %v" , containerID , err )
@@ -513,6 +519,12 @@ func (pc *podConfigurator) disconnectInterfaceFromOVS(containerConfig *interface
513
519
if err := pc .ovsBridgeClient .DeletePort (containerConfig .PortUUID ); err != nil {
514
520
return fmt .Errorf ("failed to delete OVS port for container %s interface %s: %v" , containerID , containerConfig .InterfaceName , err )
515
521
}
522
+
523
+ // Remove unready Pod info from local cache when Pod is deleted. This is called only on Windows.
524
+ if pc .podIfMonitor != nil {
525
+ pc .podIfMonitor .deleteUnreadyPod (containerConfig .InterfaceName )
526
+ }
527
+
516
528
// Remove container configuration from cache.
517
529
pc .ifaceStore .DeleteInterface (containerConfig )
518
530
if ! pc .isSecondaryNetwork {
@@ -558,7 +570,7 @@ func (pc *podConfigurator) connectInterceptedInterface(
558
570
func (pc * podConfigurator ) disconnectInterceptedInterface (podName , podNamespace , containerID string ) error {
559
571
containerConfig , found := pc .ifaceStore .GetContainerInterface (containerID )
560
572
if ! found {
561
- klog .V (2 ).Infof ("Did not find the port for container %s in local cache" , containerID )
573
+ klog .V (2 ).InfoS ("Did not find the port for container in local cache" , "container " , containerID )
562
574
return nil
563
575
}
564
576
for _ , ip := range containerConfig .IPs {
0 commit comments