Skip to content

Commit 80d8ced

Browse files
authored
Merge pull request #517 from mauriciopoppe/automated-cherry-pick-of-#515-upstream-release-4.1
Automated cherry pick of #515: remove volumesnapshots requests
2 parents 72ddd5f + 8dc3ce6 commit 80d8ced

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

cmd/snapshot-controller/main.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,17 @@ var (
6464
)
6565

6666
// Checks that the VolumeSnapshot v1 CRDs exist.
67-
func ensureCustomResourceDefinitionsExist(kubeClient *kubernetes.Clientset, client *clientset.Clientset) error {
67+
func ensureCustomResourceDefinitionsExist(client *clientset.Clientset) error {
6868
condition := func() (bool, error) {
6969
var err error
70-
_, err = kubeClient.CoreV1().Namespaces().Get(context.TODO(), "kube-system", metav1.GetOptions{})
71-
if err == nil {
72-
// only execute list VolumeSnapshots if the kube-system namespace exists
73-
_, err = client.SnapshotV1().VolumeSnapshots("kube-system").List(context.TODO(), metav1.ListOptions{})
74-
if err != nil {
75-
klog.Errorf("Failed to list v1 volumesnapshots with error=%+v", err)
76-
return false, nil
77-
}
70+
71+
// scoping to an empty namespace makes `List` work across all namespaces
72+
_, err = client.SnapshotV1().VolumeSnapshots("").List(context.TODO(), metav1.ListOptions{})
73+
if err != nil {
74+
klog.Errorf("Failed to list v1 volumesnapshots with error=%+v", err)
75+
return false, nil
7876
}
77+
7978
_, err = client.SnapshotV1().VolumeSnapshotClasses().List(context.TODO(), metav1.ListOptions{})
8079
if err != nil {
8180
klog.Errorf("Failed to list v1 volumesnapshotclasses with error=%+v", err)
@@ -173,7 +172,7 @@ func main() {
173172
*resyncPeriod,
174173
)
175174

176-
if err := ensureCustomResourceDefinitionsExist(kubeClient, snapClient); err != nil {
175+
if err := ensureCustomResourceDefinitionsExist(snapClient); err != nil {
177176
klog.Errorf("Exiting due to failure to ensure CRDs exist during startup: %+v", err)
178177
os.Exit(1)
179178
}

0 commit comments

Comments
 (0)