Skip to content

Commit 8041cc4

Browse files
Clean ups after bumping Rukapk (#928)
This PR makes the following changes: 1. Removes the use of a separate handler, given rukpak has now externalized its implementation. 2. Removes the unpacking status, which is no longer required with the use of direct registry client. Signed-off-by: Varsha Prasad Narsing <[email protected]>
1 parent 543dc15 commit 8041cc4

File tree

8 files changed

+11
-154
lines changed

8 files changed

+11
-154
lines changed

api/v1alpha1/clusterextension_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ const (
110110
ReasonUnpackPending = "UnpackPending"
111111
ReasonUnpackSuccess = "UnpackSuccess"
112112
ReasonUnpackFailed = "UnpackFailed"
113-
ReasonUnpacking = "Unpacking"
114113

115114
ReasonErrorGettingReleaseState = "ErrorGettingReleaseState"
116115
ReasonCreateDynamicWatchFailed = "CreateDynamicWatchFailed"
@@ -142,7 +141,6 @@ func init() {
142141
ReasonHasValidBundleUnknown,
143142
ReasonUnpackPending,
144143
ReasonUnpackSuccess,
145-
ReasonUnpacking,
146144
ReasonUnpackFailed,
147145
ReasonErrorGettingReleaseState,
148146
ReasonCreateDynamicWatchFailed,

cmd/manager/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ import (
4141

4242
helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"
4343
"github.com/operator-framework/rukpak/pkg/finalizer"
44+
registryv1handler "github.com/operator-framework/rukpak/pkg/handler"
45+
"github.com/operator-framework/rukpak/pkg/provisioner/registry"
4446
"github.com/operator-framework/rukpak/pkg/source"
4547
"github.com/operator-framework/rukpak/pkg/storage"
4648

4749
"github.com/operator-framework/operator-controller/api/v1alpha1"
4850
"github.com/operator-framework/operator-controller/internal/catalogmetadata/cache"
4951
catalogclient "github.com/operator-framework/operator-controller/internal/catalogmetadata/client"
5052
"github.com/operator-framework/operator-controller/internal/controllers"
51-
"github.com/operator-framework/operator-controller/internal/handler"
5253
"github.com/operator-framework/operator-controller/internal/labels"
5354
"github.com/operator-framework/operator-controller/internal/version"
5455
"github.com/operator-framework/operator-controller/pkg/features"
@@ -198,8 +199,8 @@ func main() {
198199
ActionClientGetter: acg,
199200
Unpacker: unpacker,
200201
Storage: localStorage,
201-
Handler: handler.HandlerFunc(handler.HandleClusterExtension),
202202
InstalledBundleGetter: &controllers.DefaultInstalledBundleGetter{ActionClientGetter: acg},
203+
Handler: registryv1handler.HandlerFunc(registry.HandleBundleDeployment),
203204
}).SetupWithManager(mgr); err != nil {
204205
setupLog.Error(err, "unable to create controller", "controller", "ClusterExtension")
205206
os.Exit(1)

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/operator-framework/catalogd v0.12.0
1414
github.com/operator-framework/helm-operator-plugins v0.2.2-0.20240520180534-f463c36fedf9
1515
github.com/operator-framework/operator-registry v1.43.1
16-
github.com/operator-framework/rukpak v0.22.0
16+
github.com/operator-framework/rukpak v0.23.1
1717
github.com/spf13/pflag v1.0.5
1818
github.com/stretchr/testify v1.9.0
1919
go.uber.org/zap v1.27.0
@@ -26,7 +26,6 @@ require (
2626
k8s.io/component-base v0.30.1
2727
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
2828
sigs.k8s.io/controller-runtime v0.18.3
29-
sigs.k8s.io/yaml v1.4.0
3029
)
3130

3231
require (
@@ -248,4 +247,5 @@ require (
248247
sigs.k8s.io/kustomize/api v0.15.0 // indirect
249248
sigs.k8s.io/kustomize/kyaml v0.15.0 // indirect
250249
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
250+
sigs.k8s.io/yaml v1.4.0 // indirect
251251
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,8 @@ github.com/operator-framework/operator-lib v0.14.0 h1:er+BgZymZD1im2wytLJiPLZpGA
483483
github.com/operator-framework/operator-lib v0.14.0/go.mod h1:wUu4Xb9xzXnIpglvaZ3yucTMSlqGXHIoUEH9+5gWiu0=
484484
github.com/operator-framework/operator-registry v1.43.1 h1:ACahVHGIL/hINBXd3RKWqSFR5SmSM6L5/n9xXqpR51s=
485485
github.com/operator-framework/operator-registry v1.43.1/go.mod h1:qhssAIYWXDIW+nTg0C5i4iD9zpMtiXtfXqGUuUmGz5c=
486-
github.com/operator-framework/rukpak v0.22.0 h1:1Msvw6w833nDapAX9N9whoIqJ2p+BKCmPs1Sh/G+W3U=
487-
github.com/operator-framework/rukpak v0.22.0/go.mod h1:DrQRNduAm0DWRSXpFhz8FA5g2GrJJ88sWpG5GiWmvPU=
486+
github.com/operator-framework/rukpak v0.23.1 h1:lam6+wysaVjZVpMdtl7DUbc+8ibCdlCfp+nB62K0aSU=
487+
github.com/operator-framework/rukpak v0.23.1/go.mod h1:DrQRNduAm0DWRSXpFhz8FA5g2GrJJ88sWpG5GiWmvPU=
488488
github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU=
489489
github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w=
490490
github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks=

internal/controllers/clusterextension_controller.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import (
6363
"github.com/operator-framework/operator-registry/alpha/declcfg"
6464
"github.com/operator-framework/operator-registry/alpha/property"
6565
rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2"
66+
registryv1handler "github.com/operator-framework/rukpak/pkg/handler"
6667
helmpredicate "github.com/operator-framework/rukpak/pkg/helm-operator-plugins/predicate"
6768
rukpaksource "github.com/operator-framework/rukpak/pkg/source"
6869
"github.com/operator-framework/rukpak/pkg/storage"
@@ -73,7 +74,6 @@ import (
7374
catalogfilter "github.com/operator-framework/operator-controller/internal/catalogmetadata/filter"
7475
catalogsort "github.com/operator-framework/operator-controller/internal/catalogmetadata/sort"
7576
"github.com/operator-framework/operator-controller/internal/conditionsets"
76-
"github.com/operator-framework/operator-controller/internal/handler"
7777
"github.com/operator-framework/operator-controller/internal/labels"
7878
)
7979

@@ -85,7 +85,7 @@ type ClusterExtensionReconciler struct {
8585
Unpacker rukpaksource.Unpacker
8686
ActionClientGetter helmclient.ActionClientGetter
8787
Storage storage.Storage
88-
Handler handler.Handler
88+
Handler registryv1handler.Handler
8989
dynamicWatchMutex sync.RWMutex
9090
dynamicWatchGVKs map[schema.GroupVersionKind]struct{}
9191
controller crcontroller.Controller
@@ -248,11 +248,6 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
248248
setHasValidBundleUnknown(ext, "unpack pending")
249249
setInstalledStatusConditionUnknown(ext, "installation has not been attempted as unpack is pending")
250250

251-
return ctrl.Result{}, nil
252-
case rukpaksource.StateUnpacking:
253-
setStatusUnpacking(ext, unpackResult.Message)
254-
setHasValidBundleUnknown(ext, "unpack pending")
255-
setInstalledStatusConditionUnknown(ext, "installation has not been attempted as unpack is pending")
256251
return ctrl.Result{}, nil
257252
case rukpaksource.StateUnpacked:
258253
// TODO: Add finalizer to clean the stored bundles, after https://github.com/operator-framework/rukpak/pull/897
@@ -274,7 +269,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
274269
return ctrl.Result{}, err
275270
}
276271

277-
chrt, values, err := r.Handler.Handle(ctx, bundleFS, ext)
272+
chrt, values, err := r.Handler.Handle(ctx, bundleFS, bd)
278273
if err != nil {
279274
setInstalledStatusConditionFailed(ext, err.Error())
280275
return ctrl.Result{}, err
@@ -533,6 +528,7 @@ func (r *ClusterExtensionReconciler) generateBundleDeploymentForUnpack(bundlePat
533528
UID: ce.UID,
534529
},
535530
Spec: rukpakv1alpha2.BundleDeploymentSpec{
531+
InstallNamespace: ce.Spec.InstallNamespace,
536532
Source: rukpakv1alpha2.BundleSource{
537533
Type: rukpakv1alpha2.SourceTypeImage,
538534
Image: &rukpakv1alpha2.ImageSource{

internal/controllers/common_controller.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,6 @@ func setStatusUnpackPending(ext *ocv1alpha1.ClusterExtension, message string) {
152152
})
153153
}
154154

155-
// TODO: verify if we need to update the installBundle status or leave it as is.
156-
func setStatusUnpacking(ext *ocv1alpha1.ClusterExtension, message string) {
157-
ext.Status.InstalledBundle = nil
158-
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
159-
Type: ocv1alpha1.TypeUnpacked,
160-
Status: metav1.ConditionFalse,
161-
Reason: ocv1alpha1.ReasonUnpacking,
162-
Message: message,
163-
ObservedGeneration: ext.GetGeneration(),
164-
})
165-
}
166-
167155
func setStatusUnpacked(ext *ocv1alpha1.ClusterExtension, message string) {
168156
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
169157
Type: ocv1alpha1.TypeUnpacked,

internal/handler/interfaces.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

internal/handler/registry.go

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)