-
Notifications
You must be signed in to change notification settings - Fork 562
(fix) Resolver: list CatSrc using client, instead of referring to registry-server cache #3349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,11 +91,16 @@ func (c *catalogHealthReconciler) Reconcile(ctx context.Context, in kubestate.St | |
|
||
var healthUpdated, deprecationUpdated bool | ||
next, healthUpdated = s.UpdateHealth(c.now(), catalogHealth...) | ||
if healthUpdated { | ||
if _, err := c.client.OperatorsV1alpha1().Subscriptions(ns).UpdateStatus(ctx, s.Subscription(), metav1.UpdateOptions{}); err != nil { | ||
return nil, err | ||
} | ||
} | ||
deprecationUpdated, err = c.updateDeprecatedStatus(ctx, s.Subscription()) | ||
if err != nil { | ||
return next, err | ||
} | ||
if healthUpdated || deprecationUpdated { | ||
if deprecationUpdated { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this case we don't check for error... but the health case we do now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Daniel and I had a conversation about this here #3349 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you mean to say that this error is unchecked, I noticed it too, but left it alone since it isn't part of the PR. But since I'm in this area I could totally just add that in if that's what you were asking for. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably not clear because the diff cuts off the func definition, but the error is unchecked because this func uses named returns, and this is the last potential error-causing statement, so that error will be returned if there is one. I'm not defending it, I really don't like named returns, just explaining why it looks like that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah no that's sounds fine to me. It's one of those "there's 2 ways of doing this and both are right", but it's not related to this PR. |
||
_, err = c.client.OperatorsV1alpha1().Subscriptions(ns).UpdateStatus(ctx, s.Subscription(), metav1.UpdateOptions{}) | ||
} | ||
case SubscriptionExistsState: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
|
||
"github.com/operator-framework/api/pkg/operators/v1alpha1" | ||
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned" | ||
v1listers "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/listers/operators/v1" | ||
v1alpha1listers "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/listers/operators/v1alpha1" | ||
controllerbundle "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/bundle" | ||
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/cache" | ||
|
@@ -16,10 +17,12 @@ import ( | |
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/labels" | ||
) | ||
|
||
const ( | ||
BundleLookupConditionPacked v1alpha1.BundleLookupConditionType = "BundleLookupNotPersisted" | ||
exclusionAnnotation string = "olm.operatorframework.io/exclude-global-namespace-resolution" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this is now part of the "API"? Is this documented? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's coming from this PR that added the feature (see ref). So it's an existing feature, I'm just moving the usage to a different area in this PR. However, now that you bring it up, fyi I also have an experiment going on here to essentially redo the PR that added this feature, using only the change I made in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoided removing the |
||
) | ||
|
||
// init hooks provides the downstream a way to modify the upstream behavior | ||
|
@@ -32,6 +35,7 @@ type StepResolver interface { | |
type OperatorStepResolver struct { | ||
subLister v1alpha1listers.SubscriptionLister | ||
csvLister v1alpha1listers.ClusterServiceVersionLister | ||
ogLister v1listers.OperatorGroupLister | ||
client versioned.Interface | ||
globalCatalogNamespace string | ||
resolver *Resolver | ||
|
@@ -69,6 +73,7 @@ func NewOperatorStepResolver(lister operatorlister.OperatorLister, client versio | |
stepResolver := &OperatorStepResolver{ | ||
subLister: lister.OperatorsV1alpha1().SubscriptionLister(), | ||
csvLister: lister.OperatorsV1alpha1().ClusterServiceVersionLister(), | ||
ogLister: lister.OperatorsV1().OperatorGroupLister(), | ||
client: client, | ||
globalCatalogNamespace: globalCatalogNamespace, | ||
resolver: NewDefaultResolver(cacheSourceProvider, catsrcPriorityProvider{lister: lister.OperatorsV1alpha1().CatalogSourceLister()}, log), | ||
|
@@ -91,7 +96,22 @@ func (r *OperatorStepResolver) ResolveSteps(namespace string) ([]*v1alpha1.Step, | |
return nil, nil, nil, err | ||
} | ||
|
||
namespaces := []string{namespace, r.globalCatalogNamespace} | ||
namespaces := []string{namespace} | ||
ogs, err := r.ogLister.OperatorGroups(namespace).List(labels.Everything()) | ||
if err != nil { | ||
return nil, nil, nil, fmt.Errorf("listing operatorgroups in namespace %s: %s", namespace, err) | ||
} | ||
if len(ogs) != 1 { | ||
return nil, nil, nil, fmt.Errorf("expected 1 OperatorGroup in the namespace, found %d", len(ogs)) | ||
} | ||
og := ogs[0] | ||
if val, ok := og.Annotations[exclusionAnnotation]; ok && val == "true" { | ||
// Exclusion specified | ||
// Ignore the globalNamespace for the purposes of resolution in this namespace | ||
r.log.Printf("excluding global catalogs from resolution in namespace %s", namespace) | ||
} else { | ||
namespaces = append(namespaces, r.globalCatalogNamespace) | ||
} | ||
operators, err := r.resolver.Resolve(namespaces, subs) | ||
if err != nil { | ||
return nil, nil, nil, err | ||
|
Uh oh!
There was an error while loading. Please reload this page.