CA: remove redundant IsPVCUsedByPods from ClusterSnapshot

The method is already accessible via StorageInfos(), it's
redundant.
This commit is contained in:
Kuba Tużnik 2024-09-30 20:20:09 +02:00
parent 517ecb992f
commit 38603883db
2 changed files with 8 additions and 10 deletions

View File

@ -42,8 +42,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.

View File

@ -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)
}
})
@ -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)
})
@ -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)
})