Skip to content

Commit e5f35f2

Browse files
committed
use bundle name and version instead of image in (cluster)extension status
Signed-off-by: Joe Lanford <[email protected]>
1 parent d4bffc4 commit e5f35f2

10 files changed

+200
-114
lines changed

api/v1alpha1/clusterextension_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ func init() {
122122
// ClusterExtensionStatus defines the observed state of ClusterExtension
123123
type ClusterExtensionStatus struct {
124124
// +optional
125-
InstalledBundleResource string `json:"installedBundleResource,omitempty"`
125+
InstalledBundle *BundleMetadata `json:"installedBundle,omitempty"`
126126
// +optional
127-
ResolvedBundleResource string `json:"resolvedBundleResource,omitempty"`
127+
ResolvedBundle *BundleMetadata `json:"resolvedBundle,omitempty"`
128128

129129
// +patchMergeKey=type
130130
// +patchStrategy=merge

api/v1alpha1/extension_types.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ type ExtensionStatus struct {
9595
Paused bool `json:"paused"`
9696

9797
// +optional
98-
InstalledBundleResource string `json:"installedBundleResource,omitempty"`
98+
InstalledBundle *BundleMetadata `json:"installedBundle,omitempty"`
9999
// +optional
100-
ResolvedBundleResource string `json:"resolvedBundleResource,omitempty"`
100+
ResolvedBundle *BundleMetadata `json:"resolvedBundle,omitempty"`
101101

102102
// +patchMergeKey=type
103103
// +patchStrategy=merge
@@ -106,6 +106,11 @@ type ExtensionStatus struct {
106106
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
107107
}
108108

109+
type BundleMetadata struct {
110+
Name string `json:"name"`
111+
Version string `json:"version"`
112+
}
113+
109114
//+kubebuilder:object:root=true
110115
//+kubebuilder:subresource:status
111116
//+kubebuilder:printcolumn:name="Paused",type=string,JSONPath=`.status.paused`,description="The current reconciliation state of this extension"

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,26 @@ spec:
144144
x-kubernetes-list-map-keys:
145145
- type
146146
x-kubernetes-list-type: map
147-
installedBundleResource:
148-
type: string
149-
resolvedBundleResource:
150-
type: string
147+
installedBundle:
148+
properties:
149+
name:
150+
type: string
151+
version:
152+
type: string
153+
required:
154+
- name
155+
- version
156+
type: object
157+
resolvedBundle:
158+
properties:
159+
name:
160+
type: string
161+
version:
162+
type: string
163+
required:
164+
- name
165+
- version
166+
type: object
151167
type: object
152168
type: object
153169
served: true

config/crd/bases/olm.operatorframework.io_extensions.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,30 @@ spec:
185185
x-kubernetes-list-map-keys:
186186
- type
187187
x-kubernetes-list-type: map
188-
installedBundleResource:
189-
type: string
188+
installedBundle:
189+
properties:
190+
name:
191+
type: string
192+
version:
193+
type: string
194+
required:
195+
- name
196+
- version
197+
type: object
190198
paused:
191199
description: paused indicates the current reconciliation state of
192200
this extension
193201
type: boolean
194-
resolvedBundleResource:
195-
type: string
202+
resolvedBundle:
203+
properties:
204+
name:
205+
type: string
206+
version:
207+
type: string
208+
required:
209+
- name
210+
- version
211+
type: object
196212
required:
197213
- paused
198214
type: object

internal/controllers/clusterextension_controller.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
118118
// gather vars for resolution
119119
vars, err := r.variables(ctx)
120120
if err != nil {
121-
ext.Status.InstalledBundleResource = ""
121+
ext.Status.InstalledBundle = nil
122122
setInstalledStatusConditionUnknown(&ext.Status.Conditions, "installation has not been attempted due to failure to gather data for resolution", ext.GetGeneration())
123-
ext.Status.ResolvedBundleResource = ""
123+
ext.Status.ResolvedBundle = nil
124124
setResolvedStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration())
125125

126126
setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted due to failure to gather data for resolution", ext.GetGeneration())
@@ -130,9 +130,9 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
130130
// run resolution
131131
selection, err := r.Resolver.Solve(vars)
132132
if err != nil {
133-
ext.Status.InstalledBundleResource = ""
133+
ext.Status.InstalledBundle = nil
134134
setInstalledStatusConditionUnknown(&ext.Status.Conditions, "installation has not been attempted as resolution failed", ext.GetGeneration())
135-
ext.Status.ResolvedBundleResource = ""
135+
ext.Status.ResolvedBundle = nil
136136
setResolvedStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration())
137137

138138
setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as resolution failed", ext.GetGeneration())
@@ -143,17 +143,17 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
143143
// ClusterExtension's desired package name.
144144
bundle, err := r.bundleFromSolution(selection, ext.Spec.PackageName)
145145
if err != nil {
146-
ext.Status.InstalledBundleResource = ""
146+
ext.Status.InstalledBundle = nil
147147
setInstalledStatusConditionUnknown(&ext.Status.Conditions, "installation has not been attempted as resolution failed", ext.GetGeneration())
148-
ext.Status.ResolvedBundleResource = ""
148+
ext.Status.ResolvedBundle = nil
149149
setResolvedStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration())
150150

151151
setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as resolution failed", ext.GetGeneration())
152152
return ctrl.Result{}, err
153153
}
154154

155155
// Now we can set the Resolved Condition, and the resolvedBundleSource field to the bundle.Image value.
156-
ext.Status.ResolvedBundleResource = bundle.Image
156+
ext.Status.ResolvedBundle = bundleMetadataFor(bundle)
157157
setResolvedStatusConditionSuccess(&ext.Status.Conditions, fmt.Sprintf("resolved to %q", bundle.Image), ext.GetGeneration())
158158

159159
// TODO: Question - Should we set the deprecation statuses after we have successfully resolved instead of after a successful installation?
@@ -175,7 +175,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
175175
dep := r.GenerateExpectedBundleDeployment(*ext, bundle.Image, bundleProvisioner)
176176
if err := r.ensureBundleDeployment(ctx, dep); err != nil {
177177
// originally Reason: ocv1alpha1.ReasonInstallationFailed
178-
ext.Status.InstalledBundleResource = ""
178+
ext.Status.InstalledBundle = nil
179179
setInstalledStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration())
180180
setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as installation has failed", ext.GetGeneration())
181181
return ctrl.Result{}, err
@@ -185,15 +185,15 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
185185
existingTypedBundleDeployment := &rukpakv1alpha2.BundleDeployment{}
186186
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(dep.UnstructuredContent(), existingTypedBundleDeployment); err != nil {
187187
// originally Reason: ocv1alpha1.ReasonInstallationStatusUnknown
188-
ext.Status.InstalledBundleResource = ""
188+
ext.Status.InstalledBundle = nil
189189
setInstalledStatusConditionUnknown(&ext.Status.Conditions, err.Error(), ext.GetGeneration())
190190
setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as installation has failed", ext.GetGeneration())
191191
return ctrl.Result{}, err
192192
}
193193

194-
// Let's set the proper Installed condition and InstalledBundleResource field based on the
194+
// Let's set the proper Installed condition and InstalledBundle field based on the
195195
// existing BundleDeployment object status.
196-
mapBDStatusToInstalledCondition(existingTypedBundleDeployment, ext)
196+
mapBDStatusToInstalledCondition(existingTypedBundleDeployment, ext, bundle)
197197

198198
SetDeprecationStatus(ext, bundle)
199199

@@ -218,16 +218,16 @@ func (r *ClusterExtensionReconciler) variables(ctx context.Context) ([]deppy.Var
218218
return GenerateVariables(allBundles, clusterExtensionList.Items, bundleDeploymentList.Items)
219219
}
220220

221-
func mapBDStatusToInstalledCondition(existingTypedBundleDeployment *rukpakv1alpha2.BundleDeployment, ext *ocv1alpha1.ClusterExtension) {
221+
func mapBDStatusToInstalledCondition(existingTypedBundleDeployment *rukpakv1alpha2.BundleDeployment, ext *ocv1alpha1.ClusterExtension, bundle *catalogmetadata.Bundle) {
222222
bundleDeploymentReady := apimeta.FindStatusCondition(existingTypedBundleDeployment.Status.Conditions, rukpakv1alpha2.TypeInstalled)
223223
if bundleDeploymentReady == nil {
224-
ext.Status.InstalledBundleResource = ""
224+
ext.Status.InstalledBundle = nil
225225
setInstalledStatusConditionUnknown(&ext.Status.Conditions, "bundledeployment status is unknown", ext.GetGeneration())
226226
return
227227
}
228228

229229
if bundleDeploymentReady.Status != metav1.ConditionTrue {
230-
ext.Status.InstalledBundleResource = ""
230+
ext.Status.InstalledBundle = nil
231231
setInstalledStatusConditionFailed(
232232
&ext.Status.Conditions,
233233
fmt.Sprintf("bundledeployment not ready: %s", bundleDeploymentReady.Message),
@@ -236,25 +236,25 @@ func mapBDStatusToInstalledCondition(existingTypedBundleDeployment *rukpakv1alph
236236
return
237237
}
238238

239+
installedBundle := bundleMetadataFor(bundle)
239240
bundleDeploymentSource := existingTypedBundleDeployment.Spec.Source
240241
switch bundleDeploymentSource.Type {
241242
case rukpakv1alpha2.SourceTypeImage:
242-
ext.Status.InstalledBundleResource = bundleDeploymentSource.Image.Ref
243+
ext.Status.InstalledBundle = installedBundle
243244
setInstalledStatusConditionSuccess(
244245
&ext.Status.Conditions,
245246
fmt.Sprintf("installed from %q", bundleDeploymentSource.Image.Ref),
246247
ext.GetGeneration(),
247248
)
248249
case rukpakv1alpha2.SourceTypeGit:
250+
ext.Status.InstalledBundle = installedBundle
249251
resource := bundleDeploymentSource.Git.Repository + "@" + bundleDeploymentSource.Git.Ref.Commit
250-
ext.Status.InstalledBundleResource = resource
251252
setInstalledStatusConditionSuccess(
252253
&ext.Status.Conditions,
253254
fmt.Sprintf("installed from %q", resource),
254255
ext.GetGeneration(),
255256
)
256257
default:
257-
ext.Status.InstalledBundleResource = ""
258258
setInstalledStatusConditionUnknown(
259259
&ext.Status.Conditions,
260260
fmt.Sprintf("unknown bundledeployment source type %q", bundleDeploymentSource.Type),

0 commit comments

Comments
 (0)