Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions pkg/controller/webhooks/deletionprotection.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@ func checkManagedObject(ctx context.Context, obj client.Object, c client.Client,
ownerKind, ok := obj.GetLabels()[runtime.OwnerKindAnnotation]
if !ok || ownerKind == "" {
l.Info(runtime.OwnerKindAnnotation + " label not set, skipping evaluation")
return compositeInfo{Exists: false}, nil
return compositeInfo{Exists: true}, nil
}

ownerVersion, ok := obj.GetLabels()[runtime.OwnerVersionAnnotation]
if !ok || ownerVersion == "" {
l.Info(runtime.OwnerVersionAnnotation + " label not found, skipping evaluation")
return compositeInfo{Exists: false}, nil
return compositeInfo{Exists: true}, nil
}

onwerGroup, ok := obj.GetLabels()[runtime.OwnerGroupAnnotation]
if !ok || onwerGroup == "" {
l.Info(runtime.OwnerGroupAnnotation + " label not found, skipping evaluation")
return compositeInfo{Exists: false}, nil
return compositeInfo{Exists: true}, nil
}

ownerName, ok := obj.GetLabels()["crossplane.io/composite"]
if !ok || ownerName == "" {
l.Info("crossplane.io/composite label not found, skipping evaluation")
return compositeInfo{Exists: false}, nil
return compositeInfo{Exists: true}, nil
}

gvk := schema.GroupVersionKind{
Expand Down Expand Up @@ -104,13 +104,7 @@ func checkManagedObject(ctx context.Context, obj client.Object, c client.Client,
return compositeInfo{Exists: true, Name: ownerName}, fmt.Errorf("cannot get composite: %w", err)
}

// Check if the composite is already being deleted, then we disengage the
// protection.
if comp.GetDeletionTimestamp() != nil {
return compositeInfo{Exists: false, Name: ownerName}, nil
}

return compositeInfo{Exists: isDeletionProtected(obj), Name: ownerName}, nil
return compositeInfo{Exists: true, Name: ownerName}, nil
}

// checkUnmanagedObject tries to get the composite information about objects that are not directly managed by Crossplane.
Expand Down
7 changes: 5 additions & 2 deletions pkg/controller/webhooks/generic_deletionprotection_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ func (p *GenericDeletionProtectionHandler) ValidateDelete(ctx context.Context, o
return nil, fmt.Errorf(protectedMessage, "release", compInfo.Name)
}

l.Info("Allowing deletion of resource "+resource.GetName(), "parent", compInfo.Name)
l.Info("Blocking deletion of resource "+resource.GetName(), "parent", compInfo.Name)
return nil, fmt.Errorf(protectedMessage, "release", compInfo.Name)

return nil, nil
// l.Info("Allowing deletion of resource "+resource.GetName(), "parent", compInfo.Name)

// return nil, nil
}
Loading