Merge pull request #515 from mauriciopoppe/remove-volumesnapshots-request

Update volumesnapshots request to list across all namespaces
This commit is contained in:
Kubernetes Prow Robot
2021-05-11 11:04:37 -07:00
committed by GitHub

View File

@@ -64,18 +64,17 @@ var (
) )
// Checks that the VolumeSnapshot v1 CRDs exist. // Checks that the VolumeSnapshot v1 CRDs exist.
func ensureCustomResourceDefinitionsExist(kubeClient *kubernetes.Clientset, client *clientset.Clientset) error { func ensureCustomResourceDefinitionsExist(client *clientset.Clientset) error {
condition := func() (bool, error) { condition := func() (bool, error) {
var err error var err error
_, err = kubeClient.CoreV1().Namespaces().Get(context.TODO(), "kube-system", metav1.GetOptions{})
if err == nil { // scoping to an empty namespace makes `List` work across all namespaces
// only execute list VolumeSnapshots if the kube-system namespace exists _, err = client.SnapshotV1().VolumeSnapshots("").List(context.TODO(), metav1.ListOptions{})
_, err = client.SnapshotV1().VolumeSnapshots("kube-system").List(context.TODO(), metav1.ListOptions{}) if err != nil {
if err != nil { klog.Errorf("Failed to list v1 volumesnapshots with error=%+v", err)
klog.Errorf("Failed to list v1 volumesnapshots with error=%+v", err) return false, nil
return false, nil
}
} }
_, err = client.SnapshotV1().VolumeSnapshotClasses().List(context.TODO(), metav1.ListOptions{}) _, err = client.SnapshotV1().VolumeSnapshotClasses().List(context.TODO(), metav1.ListOptions{})
if err != nil { if err != nil {
klog.Errorf("Failed to list v1 volumesnapshotclasses with error=%+v", err) klog.Errorf("Failed to list v1 volumesnapshotclasses with error=%+v", err)
@@ -173,7 +172,7 @@ func main() {
*resyncPeriod, *resyncPeriod,
) )
if err := ensureCustomResourceDefinitionsExist(kubeClient, snapClient); err != nil { if err := ensureCustomResourceDefinitionsExist(snapClient); err != nil {
klog.Errorf("Exiting due to failure to ensure CRDs exist during startup: %+v", err) klog.Errorf("Exiting due to failure to ensure CRDs exist during startup: %+v", err)
os.Exit(1) os.Exit(1)
} }