Repository navigation
✨ CE explicitly signals source #3095
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
Open
grokspawn
wants to merge
4
commits into
operator-framework:main
Choose a base branch
from
grokspawn:unwind-catalog-source-expectations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
798b8fe
CE explicitly signals source
grokspawn 03e732a
Segregate deprecation evidence into optional source interfaces
grokspawn 56d81f3
Merge upstream main; migrate PR-owned files to operator-registry v2
grokspawn d3a0b7d
update for 3183 and 3205 changes
grokspawn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /* | ||
| Copyright 2026. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package controllers | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "reflect" | ||
|
|
||
| ocv1 "github.com/operator-framework/operator-controller/api/v1" | ||
| ) | ||
|
|
||
| // Resolver is the mandatory behavior of an object that can resolve a bundle | ||
| // from a source. The shared reconciliation steps own engagement policy: | ||
| // ValidateSource runs before rollout continuation and resolution, Resolve is | ||
| // called only at steady state with no rollout in progress, | ||
| // RecoverFromResolutionError is invoked only when Resolve fails, and | ||
| // CanMaintainWithoutContent is consulted only when bundle content cannot be | ||
| // pulled. Implementations must not hide preconditions or fallbacks inside | ||
| // Resolve. | ||
| // | ||
| // Deprecation evidence is deliberately not part of this contract: sources | ||
| // that can provide it implement the optional deprecation interfaces in the | ||
| // resolve package (see resolve.PackageDeprecationSource), and consumers use | ||
| // type assertions against those interfaces to collect evidence on every | ||
| // reconcile. A source without deprecation data is reported exactly like a | ||
| // source whose evaluation found no deprecations. | ||
| type Resolver interface { | ||
| // ValidateSource verifies the extension's source payload is complete | ||
| // enough to reconcile. It runs before rollout continuation and | ||
| // resolution, so malformed payloads fail closed without backend calls. | ||
| ValidateSource(ext *ocv1.ClusterExtension) error | ||
|
|
||
| // Resolve selects the bundle to install or upgrade to. It is called only | ||
| // at steady state, with no rollout in progress. | ||
| Resolve(ctx context.Context, ext *ocv1.ClusterExtension, installedBundle *ocv1.BundleMetadata) (*RevisionMetadata, error) | ||
|
|
||
| // RecoverFromResolutionError is invoked only when Resolve returned an | ||
| // error. Returning a nil error with a non-nil result authorizes | ||
| // maintaining the installed bundle (see maintainInstalled); returning an | ||
| // error classifies the failure for retry. | ||
| RecoverFromResolutionError(ctx context.Context, ext *ocv1.ClusterExtension, revisions *RevisionStates, resolveErr error) (*RevisionMetadata, error) | ||
|
|
||
| // CanMaintainWithoutContent authorizes maintaining the current | ||
| // installation when bundle content cannot be pulled. | ||
| CanMaintainWithoutContent(ext *ocv1.ClusterExtension, revisions *RevisionStates, resolved *RevisionMetadata) bool | ||
|
|
||
| // ReconcileOnCatalogChange reports whether a ClusterCatalog event should | ||
| // enqueue reconciles for extensions served by this source. | ||
| ReconcileOnCatalogChange(ext *ocv1.ClusterExtension, catalog *ocv1.ClusterCatalog) bool | ||
| } | ||
|
|
||
| // Resolvers selects a source policy using spec.source.sourceType. | ||
| type Resolvers map[string]Resolver | ||
|
|
||
| // For returns the configured policy or an error before any source is invoked. | ||
| func (sources Resolvers) For(ext *ocv1.ClusterExtension) (Resolver, error) { | ||
| source := sources[ext.Spec.Source.SourceType] | ||
| if source == nil || nilResolver(source) { | ||
| return nil, fmt.Errorf("unsupported sourceType %q: bundle source is not configured", ext.Spec.Source.SourceType) | ||
| } | ||
| return source, nil | ||
| } | ||
|
|
||
| // maintainInstalled is the general installed-bundle fallback action: it | ||
| // targets the installed revision so the shared unpack and apply pipeline | ||
| // maintains the existing installation. | ||
| func maintainInstalled(revisions *RevisionStates) *RevisionMetadata { | ||
| return revisions.Installed | ||
| } | ||
|
|
||
| // Interfaces can contain typed nil implementations; reject these at lookup too. | ||
| func nilResolver(source Resolver) bool { | ||
| v := reflect.ValueOf(source) | ||
| switch v.Kind() { | ||
| case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Slice: | ||
| return v.IsNil() | ||
| default: | ||
| return false | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not quite right. It might be reasonable to generify as
ReconcileOnSourcesChange, so that the reconciler can indicate if it should re-reconcile based on source availability.