Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove class store since we donot update it in controller #23

Merged
merged 1 commit into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/controller/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 2 additions & 19 deletions pkg/controller/snapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/snapshot_controller_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ type csiSnapshotController struct {

snapshotStore cache.Store
contentStore cache.Store
classStore cache.Store

handler Handler
// Map of scheduled/running operations.
Expand Down Expand Up @@ -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"),
}
Expand Down