@@ -30,6 +30,7 @@ import (
30
30
kerrors "k8s.io/apimachinery/pkg/api/errors"
31
31
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32
32
"k8s.io/apimachinery/pkg/labels"
33
+ "k8s.io/apimachinery/pkg/runtime"
33
34
"k8s.io/apimachinery/pkg/runtime/schema"
34
35
"k8s.io/apimachinery/pkg/types"
35
36
ctrl "sigs.k8s.io/controller-runtime"
@@ -311,11 +312,19 @@ func (_ *migrationsComponent) findOwners(ctx *cu.Context, obj cu.Object) ([]cu.O
311
312
gvk := schema .FromAPIVersionAndKind (ref .APIVersion , ref .Kind )
312
313
ownerObj , err := ctx .Scheme .New (gvk )
313
314
if err != nil {
315
+ // Gracefully handle kinds that we haven't registered. Useful when a Rollout or Deployment is
316
+ // owned by someone's in-house operator
317
+ if runtime .IsNotRegisteredError (err ) {
318
+ break
319
+ }
314
320
return nil , errors .Wrapf (err , "error finding object type for owner reference %v" , ref )
315
321
}
316
322
err = ctx .Client .Get (ctx , types.NamespacedName {Name : ref .Name , Namespace : namespace }, ownerObj )
317
323
if err != nil {
318
- // TODO IMPORTANT If this is a 403, don't bubble up the error. Probably a custom type we don't have access to, just pretend it's not there.
324
+ // Gracefully handle objects we don't have access to
325
+ if kerrors .IsForbidden (err ) {
326
+ break
327
+ }
319
328
return nil , errors .Wrapf (err , "error finding object type for owner reference %v" , ref )
320
329
}
321
330
obj = ownerObj .(cu.Object )
0 commit comments