pb-3005: Added fix to include the CRDs even if CR is are present.
- With fix, we will include all the CRDs of a group, if one CRDs
of a parrticular group had a CR in the given namespace.
@@ -1025,11 +1025,23 @@ func (a *ApplicationBackupController) uploadCRDResources(backup *stork_api.Appli
}
if v1CrdApiReqrd {
var crds []*apiextensionsv1.CustomResourceDefinition
+ crdsGroups := make(map[string]bool)
+ // First collect the group detail for the CRDs, which has CR
for _, crd := range crdList.Items {
for _, v := range crd.Resources {
if _, ok := resKinds[v.Kind]; !ok {
continue
}
+ crdsGroups[v.Group] = true
+ }
+
+ }
+ // pick up all the CRDs that belongs to the group in the crdsGroups map
+ for _, crd := range crdList.Items {
+ for _, v := range crd.Resources {
+ if _, ok := crdsGroups[v.Group]; !ok {
+ continue
+ }
crdName := ruleset.Pluralize(strings.ToLower(v.Kind)) + "." + v.Group
res, err := apiextensions.Instance().GetCRD(crdName, metav1.GetOptions{})
if err != nil {
@@ -1053,11 +1065,22 @@ func (a *ApplicationBackupController) uploadCRDResources(backup *stork_api.Appli
return nil
}
var crds []*apiextensionsv1beta1.CustomResourceDefinition
+ crdsGroups := make(map[string]bool)
+ // First collect the group detail for the CRDs, which has CR
for _, crd := range crdList.Items {
for _, v := range crd.Resources {
if _, ok := resKinds[v.Kind]; !ok {
continue
}
+ crdsGroups[v.Group] = true
+ }
+ }
+ // pick up all the CRDs that belongs to the group in the crdsGroups map
+ for _, crd := range crdList.Items {
+ for _, v := range crd.Resources {
+ if _, ok := crdsGroups[v.Group]; !ok {
+ continue
+ }
crdName := ruleset.Pluralize(strings.ToLower(v.Kind)) + "." + v.Group
res, err := apiextensions.Instance().GetCRDV1beta1(crdName, metav1.GetOptions{})
if err != nil {
