Refactor remove fixup replica code (no semantic change)
@@ -744,26 +744,18 @@ func (s *DataStore) RemoveFinalizerForReplica(obj *longhorn.Replica) error {
// GetReplica gets Replica for the given name and namespace and returns
// a new Replica object
func (s *DataStore) GetReplica(name string) (*longhorn.Replica, error) {
- result, err := s.getReplica(name)
+ resultRO, err := s.getReplicaRO(name)
if err != nil {
return nil, err
}
- return s.fixupReplica(result)
+ // Cannot use cached object from lister
+ return resultRO.DeepCopy(), nil
}
func (s *DataStore) getReplicaRO(name string) (*longhorn.Replica, error) {
return s.rLister.Replicas(s.namespace).Get(name)
}
-func (s *DataStore) getReplica(name string) (*longhorn.Replica, error) {
- resultRO, err := s.rLister.Replicas(s.namespace).Get(name)
- if err != nil {
- return nil, err
- }
- // Cannot use cached object from lister
- return resultRO.DeepCopy(), nil
-}
-
func (s *DataStore) listReplicas(selector labels.Selector) (map[string]*longhorn.Replica, error) {
list, err := s.rLister.Replicas(s.namespace).List(selector)
if err != nil {
@@ -773,10 +765,7 @@ func (s *DataStore) listReplicas(selector labels.Selector) (map[string]*longhorn
itemMap := map[string]*longhorn.Replica{}
for _, itemRO := range list {
// Cannot use cached object from lister
- itemMap[itemRO.Name], err = s.fixupReplica(itemRO.DeepCopy())
- if err != nil {
- return nil, err
- }
+ itemMap[itemRO.Name] = itemRO.DeepCopy()
}
return itemMap, nil
}
@@ -796,10 +785,6 @@ func (s *DataStore) ListVolumeReplicas(volumeName string) (map[string]*longhorn.
return s.listReplicas(selector)
}
-func (s *DataStore) fixupReplica(replica *longhorn.Replica) (*longhorn.Replica, error) {
- return replica, nil
-}
-
// ReplicaAddressToReplicaName will directly return the address if the format
// is invalid or the replica is not found.
func ReplicaAddressToReplicaName(address string, rs []*longhorn.Replica) string {
