@@ -240,7 +240,7 @@ type edged struct {
240
240
dockerLegacyService dockershim.DockerLegacyService
241
241
// Optional, defaults to simple Docker implementation
242
242
runner kubecontainer.ContainerCommandRunner
243
- podLastSyncTime map [types. UID ]time. Time
243
+ podLastSyncTime sync. Map
244
244
}
245
245
246
246
// Register register edged
@@ -420,7 +420,6 @@ func newEdged(enable bool) (*edged, error) {
420
420
nodeIP : net .ParseIP (edgedconfig .Config .NodeIP ),
421
421
recorder : recorder ,
422
422
enable : enable ,
423
- podLastSyncTime : make (map [types.UID ]time.Time ),
424
423
}
425
424
426
425
err := ed .makePodDir ()
@@ -913,13 +912,17 @@ func (e *edged) consumePodAddition(namespacedName *types.NamespacedName) error {
913
912
}
914
913
915
914
podUID := pod .GetUID ()
916
- curPodStatus , err := e .podCache .GetNewerThan (podUID , e .podLastSyncTime [podUID ])
915
+ t , ok := e .podLastSyncTime .Load (podUID )
916
+ if ! ok {
917
+ t = time.Time {}
918
+ }
919
+ curPodStatus , err := e .podCache .GetNewerThan (podUID , t .(time.Time ))
917
920
if err != nil {
918
921
klog .Errorf ("pod %s cache newer failed: %v" , podName , err )
919
922
return err
920
923
}
921
924
result := e .containerRuntime .SyncPod (pod , curPodStatus , secrets , e .podAdditionBackoff )
922
- e .podLastSyncTime [ podUID ] = time .Now ()
925
+ e .podLastSyncTime . Store ( podUID , time .Now () )
923
926
if err := result .Error (); err != nil {
924
927
// Do not return error if the only failures were pods in backoff
925
928
for _ , r := range result .SyncResults {
@@ -952,7 +955,7 @@ func (e *edged) consumePodDeletion(namespacedName *types.NamespacedName) error {
952
955
return err
953
956
}
954
957
955
- delete ( e .podLastSyncTime , pod .GetUID ())
958
+ e .podLastSyncTime . Delete ( pod .GetUID ())
956
959
err = e .containerRuntime .KillPod (pod , kubecontainer .ConvertPodStatusToRunningPod (e .containerRuntimeName , podStatus ), nil )
957
960
if err != nil {
958
961
if err == apis .ErrContainerNotFound {
0 commit comments