Skip to content

Commit

Permalink
DRA: remove redundant IsPVCUsedByPods from ClusterSnapshot
Browse files Browse the repository at this point in the history
The method is already accessible via StorageInfos(), it's
redundant.
  • Loading branch information
towca committed Nov 7, 2024
1 parent 0a1bdc1 commit b808ee3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ type ClusterSnapshot interface {
AddPod(pod *apiv1.Pod, nodeName string) error
// RemovePod removes pod from the snapshot.
RemovePod(namespace string, podName string, nodeName string) error
// IsPVCUsedByPods returns if the pvc is used by any pod, key = <namespace>/<pvc_name>
IsPVCUsedByPods(key string) bool

// AddNodeInfo adds the given NodeInfo to the snapshot. The Node and the Pods are added, as well as
// any DRA objects passed along them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,14 @@ func TestPVCUsedByPods(t *testing.T) {
err := snapshot.AddNodeInfo(framework.NewTestNodeInfo(tc.node, tc.pods...))
assert.NoError(t, err)

volumeExists := snapshot.IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", tc.claimName))
volumeExists := snapshot.StorageInfos().IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", tc.claimName))
assert.Equal(t, tc.exists, volumeExists)

if tc.removePod != "" {
err = snapshot.RemovePod("default", tc.removePod, "node")
assert.NoError(t, err)

volumeExists = snapshot.IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", tc.claimName))
volumeExists = snapshot.StorageInfos().IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", tc.claimName))
assert.Equal(t, tc.existsAfterRemove, volumeExists)
}
})
Expand Down Expand Up @@ -693,23 +693,23 @@ func TestPVCClearAndFork(t *testing.T) {
snapshot := snapshotFactory()
err := snapshot.AddNodeInfo(framework.NewTestNodeInfo(node, pod1))
assert.NoError(t, err)
volumeExists := snapshot.IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim1"))
volumeExists := snapshot.StorageInfos().IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim1"))
assert.Equal(t, true, volumeExists)

snapshot.Fork()
assert.NoError(t, err)
volumeExists = snapshot.IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim1"))
volumeExists = snapshot.StorageInfos().IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim1"))
assert.Equal(t, true, volumeExists)

err = snapshot.AddPod(pod2, "node")
assert.NoError(t, err)

volumeExists = snapshot.IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim2"))
volumeExists = snapshot.StorageInfos().IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim2"))
assert.Equal(t, true, volumeExists)

snapshot.Revert()

volumeExists = snapshot.IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim2"))
volumeExists = snapshot.StorageInfos().IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim2"))
assert.Equal(t, false, volumeExists)

})
Expand All @@ -718,11 +718,11 @@ func TestPVCClearAndFork(t *testing.T) {
snapshot := snapshotFactory()
err := snapshot.AddNodeInfo(framework.NewTestNodeInfo(node, pod1))
assert.NoError(t, err)
volumeExists := snapshot.IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim1"))
volumeExists := snapshot.StorageInfos().IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim1"))
assert.Equal(t, true, volumeExists)

snapshot.Clear()
volumeExists = snapshot.IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim1"))
volumeExists = snapshot.StorageInfos().IsPVCUsedByPods(schedulerframework.GetNamespacedName("default", "claim1"))
assert.Equal(t, false, volumeExists)

})
Expand Down

0 comments on commit b808ee3

Please sign in to comment.