Skip to content

Commit

Permalink
controller: Avoid unnecessary DeepCopy in EngineImageController list …
Browse files Browse the repository at this point in the history
…functions

Longhorn 8528

Signed-off-by: Shuo Wu <shuo.wu@suse.com>
  • Loading branch information
shuo-wu committed May 9, 2024
1 parent f7e2d53 commit 0153908
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions controller/engine_image_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (ic *EngineImageController) syncNodeDeploymentMap(engineImage *longhorn.Eng
return err
}

eiDaemonSetPods, err := ic.ds.ListEngineImageDaemonSetPodsFromEngineImageName(engineImage.Name)
eiDaemonSetPods, err := ic.ds.ListEngineImageDaemonSetPodsFromEngineImageNameRO(engineImage.Name)
if err != nil {
return err
}
Expand Down Expand Up @@ -565,7 +565,7 @@ func updateEngineImageVersion(ei *longhorn.EngineImage) error {
}

func (ic *EngineImageController) countVolumesUsingEngineImage(image string) (int, error) {
volumes, err := ic.ds.ListVolumes()
volumes, err := ic.ds.ListVolumesRO()
if err != nil {
return 0, err
}
Expand All @@ -580,7 +580,7 @@ func (ic *EngineImageController) countVolumesUsingEngineImage(image string) (int
}

func (ic *EngineImageController) countEnginesUsingEngineImage(image string) (int, error) {
engines, err := ic.ds.ListEngines()
engines, err := ic.ds.ListEnginesRO()
if err != nil {
return 0, err
}
Expand All @@ -595,7 +595,7 @@ func (ic *EngineImageController) countEnginesUsingEngineImage(image string) (int
}

func (ic *EngineImageController) countReplicasUsingEngineImage(image string) (int, error) {
replicas, err := ic.ds.ListReplicas()
replicas, err := ic.ds.ListReplicasRO()
if err != nil {
return 0, err
}
Expand Down
4 changes: 2 additions & 2 deletions datastore/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ func (s *DataStore) GetEngineImageDaemonSet(name string) (*appsv1.DaemonSet, err
return resultRO.DeepCopy(), nil
}

func (s *DataStore) ListEngineImageDaemonSetPodsFromEngineImageName(EIName string) ([]*corev1.Pod, error) {
func (s *DataStore) ListEngineImageDaemonSetPodsFromEngineImageNameRO(EIName string) ([]*corev1.Pod, error) {
selector, err := metav1.LabelSelectorAsSelector(&metav1.LabelSelector{
MatchLabels: types.GetEIDaemonSetLabelSelector(EIName),
})
if err != nil {
return nil, err
}
return s.ListPodsBySelector(selector)
return s.ListPodsBySelectorRO(selector)
}

// CreatePDB creates a PodDisruptionBudget resource for the given PDB object and namespace
Expand Down

0 comments on commit 0153908

Please sign in to comment.