remove class store since we donot update it in controller
This commit is contained in:
@@ -1042,7 +1042,6 @@ func runSyncTests(t *testing.T, tests []controllerTest, snapshotClasses []*crdv1
|
|||||||
// Inject classes into controller via a custom lister.
|
// Inject classes into controller via a custom lister.
|
||||||
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
|
indexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
|
||||||
for _, class := range snapshotClasses {
|
for _, class := range snapshotClasses {
|
||||||
ctrl.classStore.Add(class)
|
|
||||||
indexer.Add(class)
|
indexer.Add(class)
|
||||||
}
|
}
|
||||||
ctrl.classLister = storagelisters.NewVolumeSnapshotClassLister(indexer)
|
ctrl.classLister = storagelisters.NewVolumeSnapshotClassLister(indexer)
|
||||||
|
@@ -299,10 +299,6 @@ func (ctrl *csiSnapshotController) storeContentUpdate(content interface{}) (bool
|
|||||||
return storeObjectUpdate(ctrl.contentStore, content, "content")
|
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
|
// createSnapshot starts new asynchronous operation to create snapshot
|
||||||
func (ctrl *csiSnapshotController) createSnapshot(snapshot *crdv1.VolumeSnapshot) error {
|
func (ctrl *csiSnapshotController) createSnapshot(snapshot *crdv1.VolumeSnapshot) error {
|
||||||
glog.V(5).Infof("createSnapshot[%s]: started", snapshotKey(snapshot))
|
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) {
|
func (ctrl *csiSnapshotController) GetSnapshotClass(className string) (*crdv1.VolumeSnapshotClass, error) {
|
||||||
glog.V(5).Infof("getSnapshotClass: VolumeSnapshotClassName [%s]", className)
|
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)
|
class, err := ctrl.classLister.Get(className)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("failed to retrieve snapshot class %s from the API server: %q", className, err)
|
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)
|
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
|
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
|
// 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)
|
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
|
return defaultClasses[0], newSnapshot, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,7 +56,6 @@ type csiSnapshotController struct {
|
|||||||
|
|
||||||
snapshotStore cache.Store
|
snapshotStore cache.Store
|
||||||
contentStore cache.Store
|
contentStore cache.Store
|
||||||
classStore cache.Store
|
|
||||||
|
|
||||||
handler Handler
|
handler Handler
|
||||||
// Map of scheduled/running operations.
|
// Map of scheduled/running operations.
|
||||||
@@ -100,7 +99,6 @@ func NewCSISnapshotController(
|
|||||||
resyncPeriod: resyncPeriod,
|
resyncPeriod: resyncPeriod,
|
||||||
snapshotStore: cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc),
|
snapshotStore: cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc),
|
||||||
contentStore: cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc),
|
contentStore: cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc),
|
||||||
classStore: cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc),
|
|
||||||
snapshotQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "csi-snapshotter-snapshot"),
|
snapshotQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "csi-snapshotter-snapshot"),
|
||||||
contentQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "csi-snapshotter-content"),
|
contentQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "csi-snapshotter-content"),
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user