Skip to content

Commit

Permalink
Merge pull request #85 from RaunakShah/full_sync_fix
Browse files Browse the repository at this point in the history
Defer closing wait groups in full sync to cover all exit points
  • Loading branch information
k8s-ci-robot authored Oct 15, 2019
2 parents ba1e705 + 13c399a commit ffccb8a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/syncer/fullsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func getPVsInBoundAvailableOrReleased(k8sclient clientset.Interface) ([]*v1.Pers
// Before creating a volume, all current K8s volumes are retrieved
// If the volume is successfully created, it is removed from cnsCreationMap
func fullSyncCreateVolumes(createSpecArray []cnstypes.CnsVolumeCreateSpec, metadataSyncer *MetadataSyncInformer, k8sclient clientset.Interface, wg *sync.WaitGroup) {
defer wg.Done()
currentK8sPVMap := make(map[string]bool)
volumeOperationsLock.Lock()
defer volumeOperationsLock.Unlock()
Expand Down Expand Up @@ -148,14 +149,13 @@ func fullSyncCreateVolumes(createSpecArray []cnstypes.CnsVolumeCreateSpec, metad
}
delete(cnsCreationMap, (createSpec.BackingObjectDetails).(*cnstypes.CnsBlockBackingDetails).BackingDiskId)
}

wg.Done()
}

// fullSyncDeleteVolumes delete volumes with given array of volumeId
// Before deleting a volume, all current K8s volumes are retrieved
// If the volume is successfully deleted, it is removed from cnsDeletionMap
func fullSyncDeleteVolumes(volumeIDDeleteArray []cnstypes.CnsVolumeId, metadataSyncer *MetadataSyncInformer, k8sclient clientset.Interface, wg *sync.WaitGroup) {
defer wg.Done()
deleteDisk := false
currentK8sPVMap := make(map[string]bool)
volumeOperationsLock.Lock()
Expand All @@ -182,18 +182,17 @@ func fullSyncDeleteVolumes(volumeIDDeleteArray []cnstypes.CnsVolumeId, metadataS
}
delete(cnsDeletionMap, volID.Id)
}
wg.Done()
}

// fullSyncUpdateVolumes update metadata for volumes with given array of createSpec
func fullSyncUpdateVolumes(updateSpecArray []cnstypes.CnsVolumeMetadataUpdateSpec, metadataSyncer *MetadataSyncInformer, wg *sync.WaitGroup) {
defer wg.Done()
for _, updateSpec := range updateSpecArray {
klog.V(4).Infof("FullSync: Calling UpdateVolumeMetadata for volume %s with updateSpec: %+v", updateSpec.VolumeId.Id, spew.Sdump(updateSpec))
if err := volumes.GetManager(metadataSyncer.vcenter).UpdateVolumeMetadata(&updateSpec); err != nil {
klog.Warningf("FullSync:UpdateVolumeMetadata failed with err %v", err)
}
}
wg.Done()
}

// buildCnsUpdateMetadataList build metadata list for given PV
Expand Down

0 comments on commit ffccb8a

Please sign in to comment.