-
Notifications
You must be signed in to change notification settings - Fork 68
✨ Propagate ClusterExtensionRevision conditions to ClusterExtension status #2281
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,7 @@ import ( | |||||||||||
| apimeta "k8s.io/apimachinery/pkg/api/meta" | ||||||||||||
| ctrl "sigs.k8s.io/controller-runtime" | ||||||||||||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||||||||||||
| "sigs.k8s.io/controller-runtime/pkg/log" | ||||||||||||
|
|
||||||||||||
| ocv1 "github.com/operator-framework/operator-controller/api/v1" | ||||||||||||
| "github.com/operator-framework/operator-controller/internal/operator-controller/labels" | ||||||||||||
|
|
@@ -58,8 +59,10 @@ func (d *BoxcutterRevisionStatesGetter) GetRevisionStates(ctx context.Context, e | |||||||||||
| // is fairly decoupled from this code where we get the annotations back out. We may want to co-locate | ||||||||||||
| // the set/get logic a bit better to make it more maintainable and less likely to get out of sync. | ||||||||||||
| rm := &RevisionMetadata{ | ||||||||||||
| Package: rev.Annotations[labels.PackageNameKey], | ||||||||||||
| Image: rev.Annotations[labels.BundleReferenceKey], | ||||||||||||
| RevisionName: rev.Name, | ||||||||||||
| Package: rev.Annotations[labels.PackageNameKey], | ||||||||||||
| Image: rev.Annotations[labels.BundleReferenceKey], | ||||||||||||
| Conditions: rev.Status.Conditions, | ||||||||||||
| BundleMetadata: ocv1.BundleMetadata{ | ||||||||||||
| Name: rev.Annotations[labels.BundleNameKey], | ||||||||||||
| Version: rev.Annotations[labels.BundleVersionKey], | ||||||||||||
|
|
@@ -89,3 +92,61 @@ func MigrateStorage(m StorageMigrator) ReconcileStepFunc { | |||||||||||
| return nil, nil | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| func ApplyBundleWithBoxcutter(a Applier) ReconcileStepFunc { | ||||||||||||
| return func(ctx context.Context, state *reconcileState, ext *ocv1.ClusterExtension) (*ctrl.Result, error) { | ||||||||||||
| l := log.FromContext(ctx) | ||||||||||||
| revisionAnnotations := map[string]string{ | ||||||||||||
| labels.BundleNameKey: state.resolvedRevisionMetadata.Name, | ||||||||||||
| labels.PackageNameKey: state.resolvedRevisionMetadata.Package, | ||||||||||||
| labels.BundleVersionKey: state.resolvedRevisionMetadata.Version, | ||||||||||||
| labels.BundleReferenceKey: state.resolvedRevisionMetadata.Image, | ||||||||||||
| } | ||||||||||||
| objLbls := map[string]string{ | ||||||||||||
| labels.OwnerKindKey: ocv1.ClusterExtensionKind, | ||||||||||||
| labels.OwnerNameKey: ext.GetName(), | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| l.Info("applying bundle contents") | ||||||||||||
| if _, _, err := a.Apply(ctx, state.imageFS, ext, objLbls, revisionAnnotations); err != nil { | ||||||||||||
| // If there was an error applying the resolved bundle, | ||||||||||||
| // report the error via the Progressing condition. | ||||||||||||
| setStatusProgressing(ext, wrapErrorWithResolutionInfo(state.resolvedRevisionMetadata.BundleMetadata, err)) | ||||||||||||
| return nil, err | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Mirror Available/Progressing conditions from the installed revision | ||||||||||||
| if i := state.revisionStates.Installed; i != nil { | ||||||||||||
| for _, cndType := range []string{ocv1.ClusterExtensionRevisionTypeAvailable, ocv1.ClusterExtensionRevisionTypeProgressing} { | ||||||||||||
| if cnd := apimeta.FindStatusCondition(i.Conditions, cndType); cnd != nil { | ||||||||||||
| cnd.ObservedGeneration = ext.GetGeneration() | ||||||||||||
|
Contributor
Author
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. Not for this PR, but I wonder if we should carry the CE generation as an annotation on the CER... |
||||||||||||
| apimeta.SetStatusCondition(&ext.Status.Conditions, *cnd) | ||||||||||||
pedjak marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+122
to
+123
|
||||||||||||
| cnd.ObservedGeneration = ext.GetGeneration() | |
| apimeta.SetStatusCondition(&ext.Status.Conditions, *cnd) | |
| cndCopy := cnd.DeepCopy() | |
| cndCopy.ObservedGeneration = ext.GetGeneration() | |
| apimeta.SetStatusCondition(&ext.Status.Conditions, *cndCopy) |
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.
From yesterday's discussion, should we stick to annotations?