Fix Datastore::GetEngine returning the raw engine object
This engine object is then modified during the sync as well as the monitor
refresh cycles. This in itself is bad but even worse since the sync and
monitoring routine run concurrently.
Longhorn
@@ -574,20 +574,17 @@ func (s *DataStore) getEngineRO(name string) (*longhorn.Engine, error) {
return s.eLister.Engines(s.namespace).Get(name)
}
-func (s *DataStore) getEngine(name string) (*longhorn.Engine, error) {
+// GetEngine returns the Engine for the given name and namespace
+func (s *DataStore) GetEngine(name string) (*longhorn.Engine, error) {
resultRO, err := s.getEngineRO(name)
if err != nil {
return nil, err
}
+
// Cannot use cached object from lister
return resultRO.DeepCopy(), nil
}
-// GetEngine returns the Engine for the given name and namespace
-func (s *DataStore) GetEngine(name string) (*longhorn.Engine, error) {
- return s.eLister.Engines(s.namespace).Get(name)
-}
-
func (s *DataStore) listEngines(selector labels.Selector) (map[string]*longhorn.Engine, error) {
list, err := s.eLister.Engines(s.namespace).List(selector)
if err != nil {
