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: 15 additions & 1 deletion api/v1/clusterextension_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,14 @@ type BundleMetadata struct {
Version string `json:"version"`
}

type RevisionStatus struct {
Name string `json:"name"`
// +listType=map
// +listMapKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// ClusterExtensionStatus defines the observed state of a ClusterExtension.
type ClusterExtensionStatus struct {
// The set of condition types which apply to all spec.source variations are Installed and Progressing.
Expand Down Expand Up @@ -504,6 +512,12 @@ type ClusterExtensionStatus struct {
//
// +optional
Install *ClusterExtensionInstallStatus `json:"install,omitempty"`

// +listType=map
// +listMapKey=name
// +optional
// <opcon:experimental>
ActiveRevisions []RevisionStatus `json:"activeRevisions,omitempty"`
}

// ClusterExtensionInstallStatus is a representation of the status of the identified bundle.
Expand All @@ -522,7 +536,7 @@ type ClusterExtensionInstallStatus struct {
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Installed Bundle",type=string,JSONPath=`.status.install.bundle.name`
// +kubebuilder:printcolumn:name=Version,type=string,JSONPath=`.status.install.bundle.version`
// +kubebuilder:printcolumn:name="Installed",type=string,JSONPath=`.status.conditions[?(@.type=='Installed')].status`
// +kubebuilder:printcolumn:name="Available",type=string,JSONPath=`.status.conditions[?(@.type=='Available')].status`
// +kubebuilder:printcolumn:name="Progressing",type=string,JSONPath=`.status.conditions[?(@.type=='Progressing')].status`
// +kubebuilder:printcolumn:name=Age,type=date,JSONPath=`.metadata.creationTimestamp`

Expand Down
29 changes: 29 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/operator-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ func (c *boxcutterReconcilerConfigurator) Configure(ceReconciler *controllers.Cl
controllers.RetrieveRevisionStates(revisionStatesGetter),
controllers.ResolveBundle(c.resolver),
controllers.UnpackBundle(c.imagePuller, c.imageCache),
controllers.ApplyBundle(appl),
controllers.ApplyBundleWithBoxcutter(appl),
}

baseDiscoveryClient, err := discovery.NewDiscoveryClientForConfig(c.mgr.GetConfig())
Expand Down
18 changes: 18 additions & 0 deletions docs/api-reference/olmv1-api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ _Appears in:_
| --- | --- | --- | --- |
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#condition-v1-meta) array_ | The set of condition types which apply to all spec.source variations are Installed and Progressing.<br />The Installed condition represents whether or not the bundle has been installed for this ClusterExtension.<br />When Installed is True and the Reason is Succeeded, the bundle has been successfully installed.<br />When Installed is False and the Reason is Failed, the bundle has failed to install.<br />The Progressing condition represents whether or not the ClusterExtension is advancing towards a new state.<br />When Progressing is True and the Reason is Succeeded, the ClusterExtension is making progress towards a new state.<br />When Progressing is True and the Reason is Retrying, the ClusterExtension has encountered an error that could be resolved on subsequent reconciliation attempts.<br />When Progressing is False and the Reason is Blocked, the ClusterExtension has encountered an error that requires manual intervention for recovery.<br /><opcon:experimental:description><br />When Progressing is True and Reason is RollingOut, the ClusterExtension has one or more ClusterExtensionRevisions in active roll out.<br /></opcon:experimental:description><br />When the ClusterExtension is sourced from a catalog, if may also communicate a deprecation condition.<br />These are indications from a package owner to guide users away from a particular package, channel, or bundle.<br />BundleDeprecated is set if the requested bundle version is marked deprecated in the catalog.<br />ChannelDeprecated is set if the requested channel is marked deprecated in the catalog.<br />PackageDeprecated is set if the requested package is marked deprecated in the catalog.<br />Deprecated is a rollup condition that is present when any of the deprecated conditions are present. | | |
| `install` _[ClusterExtensionInstallStatus](#clusterextensioninstallstatus)_ | install is a representation of the current installation status for this ClusterExtension. | | |
| `activeRevisions` _[RevisionStatus](#revisionstatus) array_ | <opcon:experimental> | | |



Expand Down Expand Up @@ -435,6 +436,23 @@ _Appears in:_
| `ref` _string_ | ref contains the resolved image digest-based reference.<br />The digest format is used so users can use other tooling to fetch the exact<br />OCI manifests that were used to extract the catalog contents. | | MaxLength: 1000 <br />Required: \{\} <br /> |


#### RevisionStatus







_Appears in:_
- [ClusterExtensionStatus](#clusterextensionstatus)

| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `name` _string_ | | | |
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#condition-v1-meta) array_ | | | |


#### ServiceAccountReference


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ spec:
- jsonPath: .status.install.bundle.version
name: Version
type: string
- jsonPath: .status.conditions[?(@.type=='Installed')].status
name: Installed
- jsonPath: .status.conditions[?(@.type=='Available')].status
name: Available
type: string
- jsonPath: .status.conditions[?(@.type=='Progressing')].status
name: Progressing
Expand Down Expand Up @@ -506,6 +506,78 @@ spec:
description: status is an optional field that defines the observed state
of the ClusterExtension.
properties:
activeRevisions:
items:
properties:
conditions:
items:
description: Condition contains details for one aspect of
the current state of this API Resource.
properties:
lastTransitionTime:
description: |-
lastTransitionTime is the last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
message is a human readable message indicating details about the transition.
This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: |-
observedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: |-
reason contains a programmatic identifier indicating the reason for the condition's last transition.
Producers of specific condition types may define expected values and meanings for this field,
and whether the values are considered a guaranteed API.
The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False,
Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
name:
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
conditions:
description: |-
The set of condition types which apply to all spec.source variations are Installed and Progressing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ spec:
- jsonPath: .status.install.bundle.version
name: Version
type: string
- jsonPath: .status.conditions[?(@.type=='Installed')].status
name: Installed
- jsonPath: .status.conditions[?(@.type=='Available')].status
name: Available
type: string
- jsonPath: .status.conditions[?(@.type=='Progressing')].status
name: Progressing
Expand Down
2 changes: 0 additions & 2 deletions internal/operator-controller/applier/boxcutter.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,6 @@ func (bc *Boxcutter) apply(ctx context.Context, contentFS fs.FS, ext *ocv1.Clust
default:
return false, progressingCondition.Message, nil
}
} else if availableCondition != nil && availableCondition.Status != metav1.ConditionTrue {
return false, "", errors.New(availableCondition.Message)
} else if succeededCondition != nil && succeededCondition.Status != metav1.ConditionTrue {
return false, succeededCondition.Message, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import (
"slices"

apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
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"
Expand Down Expand Up @@ -58,12 +60,14 @@ func (d *BoxcutterRevisionStatesGetter) GetRevisionStates(ctx context.Context, e
continue
}

// TODO: the setting of these annotations (happens in boxcutter applier when we pass in "revisionAnnotations")
// TODO: the setting of these annotations (happens in boxcutter applier when we pass in "storageLabels")
// 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],
RevName: rev.Name,
Package: rev.Labels[labels.PackageNameKey],
Image: rev.Annotations[labels.BundleReferenceKey],
Conditions: rev.Status.Conditions,
BundleMetadata: ocv1.BundleMetadata{
Name: rev.Annotations[labels.BundleNameKey],
Version: rev.Annotations[labels.BundleVersionKey],
Expand Down Expand Up @@ -93,3 +97,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)
storeLbls := 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, storeLbls); 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
}

// Repopulate active revisions to avoid duplicates
ext.Status.ActiveRevisions = nil

// 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 {
apimeta.SetStatusCondition(&ext.Status.Conditions, *cnd)
}
}
ext.Status.Install = &ocv1.ClusterExtensionInstallStatus{
Bundle: i.BundleMetadata,
}
ext.Status.ActiveRevisions = []ocv1.RevisionStatus{{Name: i.RevName}}
}
for idx, r := range state.revisionStates.RollingOut {
rs := ocv1.RevisionStatus{Name: r.RevName}
// Mirror Progressing condition from the latest active revision
if idx == len(state.revisionStates.RollingOut)-1 {
pcnd := apimeta.FindStatusCondition(r.Conditions, ocv1.ClusterExtensionRevisionTypeProgressing)
if pcnd != nil {
apimeta.SetStatusCondition(&ext.Status.Conditions, *pcnd)
}
acnd := apimeta.FindStatusCondition(r.Conditions, ocv1.ClusterExtensionRevisionTypeAvailable)
if acnd != nil && pcnd != nil && pcnd.Status == metav1.ConditionFalse && acnd.Status != metav1.ConditionTrue {
apimeta.SetStatusCondition(&ext.Status.Conditions, *acnd)
}
}
ext.Status.ActiveRevisions = append(ext.Status.ActiveRevisions, rs)
}

setInstalledStatusFromRevisionStates(ext, state.revisionStates)
return nil, nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,11 @@ func clusterExtensionRequestsForCatalog(c client.Reader, logger logr.Logger) crh
}

type RevisionMetadata struct {
RevName string
Package string
Image string
ocv1.BundleMetadata
Conditions []metav1.Condition
}

type RevisionStates struct {
Expand Down
Loading
Loading