@@ -30,6 +30,7 @@ import (
3030 kerrors "k8s.io/apimachinery/pkg/api/errors"
3131 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232 "k8s.io/apimachinery/pkg/labels"
33+ "k8s.io/apimachinery/pkg/runtime"
3334 "k8s.io/apimachinery/pkg/runtime/schema"
3435 "k8s.io/apimachinery/pkg/types"
3536 ctrl "sigs.k8s.io/controller-runtime"
@@ -311,11 +312,19 @@ func (_ *migrationsComponent) findOwners(ctx *cu.Context, obj cu.Object) ([]cu.O
311312 gvk := schema .FromAPIVersionAndKind (ref .APIVersion , ref .Kind )
312313 ownerObj , err := ctx .Scheme .New (gvk )
313314 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+ }
314320 return nil , errors .Wrapf (err , "error finding object type for owner reference %v" , ref )
315321 }
316322 err = ctx .Client .Get (ctx , types.NamespacedName {Name : ref .Name , Namespace : namespace }, ownerObj )
317323 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+ }
319328 return nil , errors .Wrapf (err , "error finding object type for owner reference %v" , ref )
320329 }
321330 obj = ownerObj .(cu.Object )
0 commit comments