Skip to content

Commit

Permalink
rebase with main
Browse files Browse the repository at this point in the history
Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
  • Loading branch information
varshaprasad96 authored and tmshort committed Jun 7, 2024
1 parent 9724c1d commit 96ffa18
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/operator-framework/helm-operator-plugins v0.2.2-0.20240520180534-f463c36fedf9
github.com/operator-framework/operator-registry v1.43.1
github.com/operator-framework/rukpak v0.21.2-0.20240529184017-f5b290a5851f
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
go.uber.org/zap v1.27.0
Expand Down Expand Up @@ -197,6 +196,7 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
Expand Down
17 changes: 13 additions & 4 deletions internal/controllers/clusterextension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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", ocv1alpha1.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(
Expand All @@ -350,6 +358,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
); err != nil {
return err
}
r.dynamicWatchGVKs[obj.GetObjectKind().GroupVersionKind()] = struct{}{}
}
return nil
}(); err != nil {
Expand Down
9 changes: 4 additions & 5 deletions internal/controllers/clusterextension_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/operator-framework/operator-registry/alpha/declcfg"
"github.com/operator-framework/operator-registry/alpha/property"
rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2"
"github.com/operator-framework/rukpak/pkg/source"

ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
Expand Down Expand Up @@ -180,10 +179,10 @@ func TestClusterExtensionChannelVersionExists(t *testing.T) {
require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message)

t.Log("By checking the expected unpacked conditions")
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, rukpakv1alpha2.TypeUnpacked)
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
require.NotNil(t, unpackedCond)
require.Equal(t, metav1.ConditionFalse, unpackedCond.Status)
require.Equal(t, rukpakv1alpha2.ReasonUnpackPending, unpackedCond.Reason)
require.Equal(t, ocv1alpha1.ReasonUnpackPending, unpackedCond.Reason)

require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
}
Expand Down Expand Up @@ -238,10 +237,10 @@ func TestClusterExtensionChannelExistsNoVersion(t *testing.T) {
require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake2.0.0\"", resolvedCond.Message)

t.Log("By checking the expected unpacked conditions")
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, rukpakv1alpha2.TypeUnpacked)
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
require.NotNil(t, unpackedCond)
require.Equal(t, metav1.ConditionFalse, unpackedCond.Status)
require.Equal(t, rukpakv1alpha2.ReasonUnpackPending, unpackedCond.Reason)
require.Equal(t, ocv1alpha1.ReasonUnpackPending, unpackedCond.Reason)

verifyInvariants(ctx, t, reconciler.Client, clusterExtension)
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
Expand Down
2 changes: 0 additions & 2 deletions pkg/scheme/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
clientgoscheme "k8s.io/client-go/kubernetes/scheme"

catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2"

ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
)
Expand All @@ -18,7 +17,6 @@ var Scheme = runtime.NewScheme()
func init() {
utilruntime.Must(clientgoscheme.AddToScheme(Scheme))
utilruntime.Must(ocv1alpha1.AddToScheme(Scheme))
utilruntime.Must(rukpakv1alpha2.AddToScheme(Scheme))
utilruntime.Must(catalogd.AddToScheme(Scheme))
utilruntime.Must(appsv1.AddToScheme(Scheme))
utilruntime.Must(corev1.AddToScheme(Scheme))
Expand Down

0 comments on commit 96ffa18

Please sign in to comment.