Skip to content

Commit

Permalink
[pkg/volume] Changed to use sets.Set[string] instead of sets.String
Browse files Browse the repository at this point in the history
  • Loading branch information
bells17 committed May 11, 2024
1 parent 925cb2b commit ef1d3a1
Show file tree
Hide file tree
Showing 11 changed files with 1,227 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func (dswp *desiredStateOfWorldPopulator) deleteProcessedPod(
// specified volume. It dereference any PVC to get PV objects, if needed.
// Returns an error if unable to obtain the volume at this time.
func (dswp *desiredStateOfWorldPopulator) createVolumeSpec(
podVolume v1.Volume, pod *v1.Pod, mounts, devices sets.String) (*v1.PersistentVolumeClaim, *volume.Spec, string, error) {
podVolume v1.Volume, pod *v1.Pod, mounts, devices sets.Set[string]) (*v1.PersistentVolumeClaim, *volume.Spec, string, error) {
pvcSource := podVolume.VolumeSource.PersistentVolumeClaim
isEphemeral := pvcSource == nil && podVolume.VolumeSource.Ephemeral != nil
if isEphemeral {
Expand Down
16 changes: 8 additions & 8 deletions pkg/volume/csi/nodeinfomanager/nodeinfomanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,16 @@ func setMigrationAnnotation(migratedPlugins map[string](func() bool), nodeInfo *
nodeInfoAnnotations = map[string]string{}
}

var oldAnnotationSet sets.String
var oldAnnotationSet sets.Set[string]
mpa := nodeInfoAnnotations[v1.MigratedPluginsAnnotationKey]
tok := strings.Split(mpa, ",")
if len(mpa) == 0 {
oldAnnotationSet = sets.NewString()
oldAnnotationSet = sets.New[string]()
} else {
oldAnnotationSet = sets.NewString(tok...)
oldAnnotationSet = sets.New[string](tok...)
}

newAnnotationSet := sets.NewString()
newAnnotationSet := sets.New[string]()
for pluginName, migratedFunc := range migratedPlugins {
if migratedFunc() {
newAnnotationSet.Insert(pluginName)
Expand All @@ -494,7 +494,7 @@ func setMigrationAnnotation(migratedPlugins map[string](func() bool), nodeInfo *
return false
}

nas := strings.Join(newAnnotationSet.List(), ",")
nas := strings.Join(sets.List[string](newAnnotationSet), ",")
if len(nas) != 0 {
nodeInfoAnnotations[v1.MigratedPluginsAnnotationKey] = nas
} else {
Expand Down Expand Up @@ -526,15 +526,15 @@ func (nim *nodeInfoManager) installDriverToCSINode(
return fmt.Errorf("error getting CSI client")
}

topologyKeys := sets.StringKeySet(topology)
topologyKeys := sets.KeySet[string, string](topology)

specModified := true
// Clone driver list, omitting the driver that matches the given driverName
newDriverSpecs := []storagev1.CSINodeDriver{}
for _, driverInfoSpec := range nodeInfo.Spec.Drivers {
if driverInfoSpec.Name == driverName {
if driverInfoSpec.NodeID == driverNodeID &&
sets.NewString(driverInfoSpec.TopologyKeys...).Equal(topologyKeys) &&
sets.New[string](driverInfoSpec.TopologyKeys...).Equal(topologyKeys) &&
keepAllocatableCount(driverInfoSpec, maxAttachLimit) {
specModified = false
}
Expand All @@ -554,7 +554,7 @@ func (nim *nodeInfoManager) installDriverToCSINode(
driverSpec := storagev1.CSINodeDriver{
Name: driverName,
NodeID: driverNodeID,
TopologyKeys: topologyKeys.List(),
TopologyKeys: sets.List[string](topologyKeys),
}

if maxAttachLimit > 0 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/volume/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ type VolumePluginMgr struct {
plugins map[string]VolumePlugin
prober DynamicPluginProber
probedPlugins map[string]VolumePlugin
loggedDeprecationWarnings sets.String
loggedDeprecationWarnings sets.Set[string]
Host VolumeHost
}

Expand Down Expand Up @@ -567,7 +567,7 @@ func (pm *VolumePluginMgr) InitPlugins(plugins []VolumePlugin, prober DynamicPlu
defer pm.mutex.Unlock()

pm.Host = host
pm.loggedDeprecationWarnings = sets.NewString()
pm.loggedDeprecationWarnings = sets.New[string]()

if prober == nil {
// Use a dummy prober to prevent nil deference.
Expand Down

0 comments on commit ef1d3a1

Please sign in to comment.