Skip to content

Commit 390aa39

Browse files
authored
Merge pull request #23 from wackxu/rmclassstore
remove class store since we donot update it in controller
2 parents bad4c85 + ae2be66 commit 390aa39

File tree

3 files changed

+2
-22
lines changed

3 files changed

+2
-22
lines changed

pkg/controller/framework_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,6 @@ func runSyncTests(t *testing.T, tests []controllerTest, snapshotClasses []*crdv1
10421042
// Inject classes into controller via a custom lister.
10431043
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
10441044
for _, class := range snapshotClasses {
1045-
ctrl.classStore.Add(class)
10461045
indexer.Add(class)
10471046
}
10481047
ctrl.classLister = storagelisters.NewVolumeSnapshotClassLister(indexer)

pkg/controller/snapshot_controller.go

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,6 @@ func (ctrl *csiSnapshotController) storeContentUpdate(content interface{}) (bool
299299
return storeObjectUpdate(ctrl.contentStore, content, "content")
300300
}
301301

302-
func (ctrl *csiSnapshotController) storeClassUpdate(content interface{}) (bool, error) {
303-
return storeObjectUpdate(ctrl.classStore, content, "class")
304-
}
305-
306302
// createSnapshot starts new asynchronous operation to create snapshot
307303
func (ctrl *csiSnapshotController) createSnapshot(snapshot *crdv1.VolumeSnapshot) error {
308304
glog.V(5).Infof("createSnapshot[%s]: started", snapshotKey(snapshot))
@@ -744,22 +740,12 @@ func (ctrl *csiSnapshotController) getStorageClassFromVolumeSnapshot(snapshot *c
744740
func (ctrl *csiSnapshotController) GetSnapshotClass(className string) (*crdv1.VolumeSnapshotClass, error) {
745741
glog.V(5).Infof("getSnapshotClass: VolumeSnapshotClassName [%s]", className)
746742

747-
obj, found, err := ctrl.classStore.GetByKey(className)
748-
if found {
749-
class, ok := obj.(*crdv1.VolumeSnapshotClass)
750-
if ok {
751-
return class, nil
752-
}
753-
}
754743
class, err := ctrl.classLister.Get(className)
755744
if err != nil {
756745
glog.Errorf("failed to retrieve snapshot class %s from the API server: %q", className, err)
757746
return nil, fmt.Errorf("failed to retrieve snapshot class %s from the API server: %q", className, err)
758747
}
759-
_, updateErr := ctrl.storeClassUpdate(class)
760-
if updateErr != nil {
761-
glog.V(4).Infof("getSnapshotClass [%s]: cannot update internal cache: %v", class.Name, updateErr)
762-
}
748+
763749
return class, nil
764750
}
765751

@@ -804,10 +790,7 @@ func (ctrl *csiSnapshotController) SetDefaultSnapshotClass(snapshot *crdv1.Volum
804790
// We will get an "snapshot update" event soon, this is not a big error
805791
glog.V(4).Infof("setDefaultSnapshotClass [%s]: cannot update internal cache: %v", snapshotKey(snapshot), updateErr)
806792
}
807-
_, updateErr = ctrl.storeClassUpdate(defaultClasses[0])
808-
if updateErr != nil {
809-
glog.V(4).Infof("setDefaultSnapshotClass [%s]: cannot update internal cache: %v", defaultClasses[0].Name, updateErr)
810-
}
793+
811794
return defaultClasses[0], newSnapshot, nil
812795
}
813796

pkg/controller/snapshot_controller_base.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ type csiSnapshotController struct {
5656

5757
snapshotStore cache.Store
5858
contentStore cache.Store
59-
classStore cache.Store
6059

6160
handler Handler
6261
// Map of scheduled/running operations.
@@ -100,7 +99,6 @@ func NewCSISnapshotController(
10099
resyncPeriod: resyncPeriod,
101100
snapshotStore: cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc),
102101
contentStore: cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc),
103-
classStore: cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc),
104102
snapshotQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "csi-snapshotter-snapshot"),
105103
contentQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "csi-snapshotter-content"),
106104
}

0 commit comments

Comments
 (0)