Skip to content

Commit

Permalink
operators/v1alpha1: expose CSV copied logic
Browse files Browse the repository at this point in the history
We want to use a partial object metadata query for CSVs to reduce
resource utilization. We still want to ask questions about whether these
CSVs are copied, so we need to refactor this method to take only object
metadata. While it's not a perfect port of the previous logic, it defies
explanation how an object would have all the other markings of being
copied but the wrong status.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
  • Loading branch information
stevekuznetsov committed Aug 2, 2023
1 parent 92e4341 commit 04edc4f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/operators/v1alpha1/clusterserviceversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,16 @@ func (c *ClusterServiceVersion) IsObsolete() bool {

// IsCopied returns true if the CSV has been copied and false otherwise.
func (c *ClusterServiceVersion) IsCopied() bool {
operatorNamespace, ok := c.GetAnnotations()[OperatorGroupNamespaceAnnotationKey]
if c.Status.Reason == CSVReasonCopied || ok && c.GetNamespace() != operatorNamespace {
return c.Status.Reason == CSVReasonCopied || IsCopied(c)
}

func IsCopied(o metav1.Object) bool {
operatorNamespace, ok := o.GetAnnotations()[OperatorGroupNamespaceAnnotationKey]
if ok && o.GetNamespace() != operatorNamespace {
return true
}

if labels := c.GetLabels(); labels != nil {
if labels := o.GetLabels(); labels != nil {
if _, ok := labels[CopiedLabelKey]; ok {
return true
}
Expand Down

0 comments on commit 04edc4f

Please sign in to comment.