From 61c33db953a75d9c414a6efa9634c31ba25910d3 Mon Sep 17 00:00:00 2001 From: Varsha Prasad Narsing Date: Thu, 6 Jun 2024 08:11:40 -0700 Subject: [PATCH] rebase with main Signed-off-by: Varsha Prasad Narsing --- .../controllers/clusterextension_controller.go | 18 +++++++++++++----- .../registry-v1/build-push-e2e-bundle.sh | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/internal/controllers/clusterextension_controller.go b/internal/controllers/clusterextension_controller.go index d3f2c244..cf4e4c0a 100644 --- a/internal/controllers/clusterextension_controller.go +++ b/internal/controllers/clusterextension_controller.go @@ -41,6 +41,7 @@ import ( apimeta "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" @@ -257,10 +258,10 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp setStatusUnpackFailed(ext, err.Error()) return ctrl.Result{}, err } - setStatusUnpacked(ext, unpackResult.Message) + setStatusUnpacked(ext, fmt.Sprintf("unpack successful: %v", unpackResult.Message)) default: - setStatusUnpackFailed(ext, err.Error()) - return ctrl.Result{}, err + setStatusUnpackFailed(ext, fmt.Sprintf("unpack successful: %v", unpackResult.Message)) + return ctrl.Result{}, fmt.Errorf("unexpected unpack status: %v", err) } bundleFS, err := r.Storage.Load(ctx, ext) @@ -331,11 +332,18 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp } for _, obj := range relObjects { + uMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj) + if err != nil { + setInstalledStatusConditionFailed(ext, fmt.Sprintf("%s:%v", rukpakv1alpha2.ReasonCreateDynamicWatchFailed, err)) + return ctrl.Result{}, err + } + + unstructuredObj := &unstructured.Unstructured{Object: uMap} if err := func() error { r.dynamicWatchMutex.Lock() defer r.dynamicWatchMutex.Unlock() - _, isWatched := r.dynamicWatchGVKs[obj.GetObjectKind().GroupVersionKind()] + _, isWatched := r.dynamicWatchGVKs[unstructuredObj.GroupVersionKind()] if !isWatched { if err := r.controller.Watch( source.Kind( @@ -354,7 +362,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp return nil }(); err != nil { ext.Status.InstalledBundle = nil - setInstalledStatusConditionFailed(ext, fmt.Sprintf("%s:%v", ocv1alpha1.ReasonCreateDynamicWatchFailed, err)) + setInstalledStatusConditionFailed(ext, fmt.Sprintf("%s:%v", rukpakv1alpha2.ReasonCreateDynamicWatchFailed, err)) return ctrl.Result{}, err } } diff --git a/testdata/bundles/registry-v1/build-push-e2e-bundle.sh b/testdata/bundles/registry-v1/build-push-e2e-bundle.sh index aca3e95c..a2e77c17 100755 --- a/testdata/bundles/registry-v1/build-push-e2e-bundle.sh +++ b/testdata/bundles/registry-v1/build-push-e2e-bundle.sh @@ -32,7 +32,7 @@ echo "${namespace}" "${tag}" kubectl create configmap -n "${namespace}" --from-file="${bundle_dir}/Dockerfile" operator-controller-e2e-${bundle_name}.root tgz="${bundle_dir}/manifests.tgz" -tar czf "${tgz}" -C "${bundle_dir}/" manifests metadata +gtar czf "${tgz}" -C "${bundle_dir}/" manifests metadata kubectl create configmap -n "${namespace}" --from-file="${tgz}" operator-controller-${bundle_name}.manifests rm "${tgz}"