mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-06 13:26:26 +00:00
Check whether the API resource exists before creating the informer cache
Check whether the API resource exists before creating the informer cache Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
This commit is contained in:
@@ -593,6 +593,11 @@ func (ctx *restoreContext) execute() (results.Result, results.Result) {
|
||||
break
|
||||
}
|
||||
gvr := schema.ParseGroupResource(informerResource.resource).WithVersion(version)
|
||||
_, _, err := ctx.discoveryHelper.ResourceFor(gvr)
|
||||
if err != nil {
|
||||
ctx.log.Infof("failed to create informer for %s: %v", gvr, err)
|
||||
continue
|
||||
}
|
||||
ctx.dynamicInformerFactory.factory.ForResource(gvr)
|
||||
}
|
||||
ctx.dynamicInformerFactory.factory.Start(ctx.dynamicInformerFactory.context.Done())
|
||||
@@ -1059,11 +1064,7 @@ func (ctx *restoreContext) getResourceClient(groupResource schema.GroupResource,
|
||||
}
|
||||
|
||||
func (ctx *restoreContext) getResourceLister(groupResource schema.GroupResource, obj *unstructured.Unstructured, namespace string) (cache.GenericNamespaceLister, error) {
|
||||
_, _, err := ctx.discoveryHelper.KindFor(schema.GroupVersionKind{
|
||||
Group: obj.GroupVersionKind().Group,
|
||||
Version: obj.GetAPIVersion(),
|
||||
Kind: obj.GetKind(),
|
||||
})
|
||||
_, _, err := ctx.discoveryHelper.KindFor(obj.GroupVersionKind())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user