From ae2be6651ead793401f4bfe65b68dd977835f1d3 Mon Sep 17 00:00:00 2001 From: xushiwei 00425595 Date: Thu, 6 Sep 2018 11:08:58 +0800 Subject: [PATCH] remove class store since we donot update it in controller --- pkg/controller/framework_test.go | 1 - pkg/controller/snapshot_controller.go | 21 ++------------------- pkg/controller/snapshot_controller_base.go | 2 -- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/pkg/controller/framework_test.go b/pkg/controller/framework_test.go index 5d9311d6..57a5cf4e 100644 --- a/pkg/controller/framework_test.go +++ b/pkg/controller/framework_test.go @@ -1042,7 +1042,6 @@ func runSyncTests(t *testing.T, tests []controllerTest, snapshotClasses []*crdv1 // Inject classes into controller via a custom lister. indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{}) for _, class := range snapshotClasses { - ctrl.classStore.Add(class) indexer.Add(class) } ctrl.classLister = storagelisters.NewVolumeSnapshotClassLister(indexer) diff --git a/pkg/controller/snapshot_controller.go b/pkg/controller/snapshot_controller.go index 2401eda6..4c3b8f8f 100644 --- a/pkg/controller/snapshot_controller.go +++ b/pkg/controller/snapshot_controller.go @@ -299,10 +299,6 @@ func (ctrl *csiSnapshotController) storeContentUpdate(content interface{}) (bool return storeObjectUpdate(ctrl.contentStore, content, "content") } -func (ctrl *csiSnapshotController) storeClassUpdate(content interface{}) (bool, error) { - return storeObjectUpdate(ctrl.classStore, content, "class") -} - // createSnapshot starts new asynchronous operation to create snapshot func (ctrl *csiSnapshotController) createSnapshot(snapshot *crdv1.VolumeSnapshot) error { glog.V(5).Infof("createSnapshot[%s]: started", snapshotKey(snapshot)) @@ -744,22 +740,12 @@ func (ctrl *csiSnapshotController) getStorageClassFromVolumeSnapshot(snapshot *c func (ctrl *csiSnapshotController) GetSnapshotClass(className string) (*crdv1.VolumeSnapshotClass, error) { glog.V(5).Infof("getSnapshotClass: VolumeSnapshotClassName [%s]", className) - obj, found, err := ctrl.classStore.GetByKey(className) - if found { - class, ok := obj.(*crdv1.VolumeSnapshotClass) - if ok { - return class, nil - } - } class, err := ctrl.classLister.Get(className) if err != nil { glog.Errorf("failed to retrieve snapshot class %s from the API server: %q", className, err) return nil, fmt.Errorf("failed to retrieve snapshot class %s from the API server: %q", className, err) } - _, updateErr := ctrl.storeClassUpdate(class) - if updateErr != nil { - glog.V(4).Infof("getSnapshotClass [%s]: cannot update internal cache: %v", class.Name, updateErr) - } + return class, nil } @@ -804,10 +790,7 @@ func (ctrl *csiSnapshotController) SetDefaultSnapshotClass(snapshot *crdv1.Volum // We will get an "snapshot update" event soon, this is not a big error glog.V(4).Infof("setDefaultSnapshotClass [%s]: cannot update internal cache: %v", snapshotKey(snapshot), updateErr) } - _, updateErr = ctrl.storeClassUpdate(defaultClasses[0]) - if updateErr != nil { - glog.V(4).Infof("setDefaultSnapshotClass [%s]: cannot update internal cache: %v", defaultClasses[0].Name, updateErr) - } + return defaultClasses[0], newSnapshot, nil } diff --git a/pkg/controller/snapshot_controller_base.go b/pkg/controller/snapshot_controller_base.go index 9a5c519a..dca53eb0 100644 --- a/pkg/controller/snapshot_controller_base.go +++ b/pkg/controller/snapshot_controller_base.go @@ -56,7 +56,6 @@ type csiSnapshotController struct { snapshotStore cache.Store contentStore cache.Store - classStore cache.Store handler Handler // Map of scheduled/running operations. @@ -100,7 +99,6 @@ func NewCSISnapshotController( resyncPeriod: resyncPeriod, snapshotStore: cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc), contentStore: cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc), - classStore: cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc), snapshotQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "csi-snapshotter-snapshot"), contentQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "csi-snapshotter-content"), }