diff --git a/controllers/storagepolicyquota/storagepolicyquota_controller.go b/controllers/storagepolicyquota/storagepolicyquota_controller.go index e528d9757..2bc98dbf1 100644 --- a/controllers/storagepolicyquota/storagepolicyquota_controller.go +++ b/controllers/storagepolicyquota/storagepolicyquota_controller.go @@ -5,6 +5,7 @@ package storagepolicyquota import ( "context" + "errors" "fmt" "reflect" "strings" @@ -135,6 +136,7 @@ func (r *Reconciler) ReconcileNormal( } // Create the StoragePolicyUsage resources. + var errs []error for i := range objs { dst := spqv1.StoragePolicyUsage{ ObjectMeta: metav1.ObjectMeta{ @@ -167,9 +169,9 @@ func (r *Reconciler) ReconcileNormal( &dst, fn); err != nil { - return err + errs = append(errs, err) } } - return err + return errors.Join(errs...) } diff --git a/controllers/storagepolicyquota/storagepolicyquota_controller_unit_test.go b/controllers/storagepolicyquota/storagepolicyquota_controller_unit_test.go index aaf858695..9c4aca31f 100644 --- a/controllers/storagepolicyquota/storagepolicyquota_controller_unit_test.go +++ b/controllers/storagepolicyquota/storagepolicyquota_controller_unit_test.go @@ -44,6 +44,7 @@ func unitTestsReconcile() { storageQuotaName = "my-storage-quota" storageClassName = "my-storage-class" storagePolicyID = "my-storage-policy" + caBundle = "fake-ca-bundle" ) var ( @@ -75,7 +76,7 @@ func unitTestsReconcile() { Webhooks: []admissionv1.ValidatingWebhook{ { ClientConfig: admissionv1.WebhookClientConfig{ - CABundle: []byte("fake-ca-bundle"), + CABundle: []byte(caBundle), }, }, }, @@ -173,6 +174,7 @@ func unitTestsReconcile() { ExpectWithOffset(1, obj.Spec.ResourceKind).To(Equal("VirtualMachine")) ExpectWithOffset(1, obj.Spec.StorageClassName).To(Equal(storageClassName)) ExpectWithOffset(1, obj.Spec.StoragePolicyId).To(Equal(storagePolicyID)) + ExpectWithOffset(1, obj.Spec.CABundle).To(Equal([]byte(caBundle))) } When("a StoragePolicyUsage resource does not exist", func() {