Skip to content

Commit

Permalink
Remove redundant wait for pvc
Browse files Browse the repository at this point in the history
Virtctl is not using any caching, so once create is called on a PVC
and error is not returned then the PVC object is already created
hence wait for get to return the object is redundant

Signed-off-by: Shelly Kagan <[email protected]>
  • Loading branch information
ShellyKa13 committed Jul 14, 2022
1 parent 4c8eeb4 commit e95cd11
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 19 deletions.
1 change: 0 additions & 1 deletion pkg/virtctl/vm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
],
)
Expand Down
18 changes: 0 additions & 18 deletions pkg/virtctl/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ import (
"encoding/json"
"fmt"
"strings"
"time"

k8sv1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"

v1 "kubevirt.io/api/core/v1"

Expand Down Expand Up @@ -484,22 +482,6 @@ func createPVCforMemoryDump(namespace, vmName, claimName string, virtClient kube
return err
}

err = wait.PollImmediate(time.Second*2, time.Second*60, func() (bool, error) {
_, err := virtClient.CoreV1().PersistentVolumeClaims(namespace).Get(context.Background(), claimName, metav1.GetOptions{})
if err != nil {
if k8serrors.IsNotFound(err) {
return false, nil
}

return false, err
}

return true, nil
})
if err != nil {
return fmt.Errorf("Failed creating PVC %s/%s for memory dump\n", namespace, claimName)
}

fmt.Printf("PVC %s/%s created\n", namespace, claimName)

return nil
Expand Down

0 comments on commit e95cd11

Please sign in to comment.