Skip to content

Commit

Permalink
Remove the final bits of references to the old catalogd Package and B…
Browse files Browse the repository at this point in the history
…undleMetadata APIs (#372)

Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
  • Loading branch information
joelanford committed Aug 29, 2023
1 parent 9d07bb1 commit db08a62
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 55 deletions.
7 changes: 0 additions & 7 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ rules:
verbs:
- list
- watch
- apiGroups:
- catalogd.operatorframework.io
resources:
- packages
verbs:
- list
- watch
- apiGroups:
- core.rukpak.io
resources:
Expand Down
1 change: 0 additions & 1 deletion internal/controllers/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ type OperatorReconciler struct {

//+kubebuilder:rbac:groups=core.rukpak.io,resources=bundledeployments,verbs=get;list;watch;create;update;patch

//+kubebuilder:rbac:groups=catalogd.operatorframework.io,resources=packages,verbs=list;watch
//+kubebuilder:rbac:groups=catalogd.operatorframework.io,resources=catalogs,verbs=list;watch
//+kubebuilder:rbac:groups=catalogd.operatorframework.io,resources=catalogmetadata,verbs=list;watch

Expand Down
21 changes: 3 additions & 18 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,15 @@ var _ = BeforeSuite(func() {
operatorCatalog, err = createTestCatalog(ctx, testCatalogName, getCatalogImageRef())
Expect(err).ToNot(HaveOccurred())

// TODO: REMOVE THIS. This should not be necessary if we have idiomatic APIs. Kubernetes is supposed
// to be eventually consistent. Waits for preconditions like this hide bugs.
Eventually(func(g Gomega) {
err := c.Get(ctx, types.NamespacedName{Name: operatorCatalog.Name}, operatorCatalog)
g.Expect(err).ToNot(HaveOccurred())
cond := apimeta.FindStatusCondition(operatorCatalog.Status.Conditions, catalogd.TypeUnpacked)
g.Expect(cond).ToNot(BeNil())
g.Expect(cond.Status).To(Equal(metav1.ConditionTrue))
g.Expect(cond.Reason).To(Equal(catalogd.ReasonUnpackSuccessful))

// Ensure some packages exist before continuing so the
// operators don't get stuck in a bad state
pList := &catalogd.PackageList{}
err = c.List(ctx, pList)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(pList.Items).To(HaveLen(2))
}).Should(Succeed())
})

Expand All @@ -95,23 +90,13 @@ var _ = AfterSuite(func() {
}).Should(Succeed())

// speed up delete without waiting for gc
Expect(c.DeleteAllOf(ctx, &catalogd.Package{})).To(Succeed())
Expect(c.DeleteAllOf(ctx, &catalogd.BundleMetadata{})).To(Succeed())
Expect(c.DeleteAllOf(ctx, &catalogd.CatalogMetadata{})).To(Succeed())

Eventually(func(g Gomega) {
// ensure resource cleanup
packages := &catalogd.PackageList{}
g.Expect(c.List(ctx, packages)).To(Succeed())
g.Expect(packages.Items).To(BeEmpty())

bmd := &catalogd.BundleMetadataList{}
g.Expect(c.List(ctx, bmd)).To(Succeed())
g.Expect(bmd.Items).To(BeEmpty())

cmd := &catalogd.CatalogMetadataList{}
g.Expect(c.List(ctx, cmd)).To(Succeed())
g.Expect(bmd.Items).To(BeEmpty())
g.Expect(cmd.Items).To(BeEmpty())
}).Should(Succeed())
})

Expand Down
3 changes: 2 additions & 1 deletion test/e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
"github.com/operator-framework/operator-registry/alpha/declcfg"
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -127,7 +128,7 @@ var _ = Describe("Operator Install", func() {

Eventually(func(g Gomega) {
// target package should not be present on cluster
err := c.Get(ctx, types.NamespacedName{Name: pkgName}, &catalogd.Package{})
err := c.Get(ctx, types.NamespacedName{Name: fmt.Sprintf("%s-%s-%s", operatorCatalog.Name, declcfg.SchemaPackage, pkgName)}, &catalogd.CatalogMetadata{})
g.Expect(errors.IsNotFound(err)).To(BeTrue())
}).Should(Succeed())

Expand Down
30 changes: 2 additions & 28 deletions test/operator-framework-e2e/operator_framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,14 +825,8 @@ func createCatalogCheckResources(operatorCatalog *catalogd.Catalog, catalogDInfo
g.Expect(err).ToNot(HaveOccurred())
}, 2*time.Minute, 1).Should(Succeed())

// checking if the packages are created
Eventually(func(g Gomega) {
err = validatePackageCreation(operatorCatalog, catalogDInfo.operatorName)
g.Expect(err).ToNot(HaveOccurred())
}, 2*time.Minute, 1).Should(Succeed())

// checking if the bundle metadatas are created
By("Eventually checking if bundle metadata is created")
// checking if the catalog metadatas are created
By("Eventually checking if catalog metadata is created")
Eventually(func(g Gomega) {
validateCatalogMetadataCreation(g, operatorCatalog, catalogDInfo.operatorName, bundleVersions)
}).Should(Succeed())
Expand Down Expand Up @@ -866,26 +860,6 @@ func checkOperatorOperationsSuccess(operator *operatorv1alpha1.Operator, pkgName
}).Should(Succeed())
}

// Checks if the packages are created from the catalog and returns error if not.
// The expected pkgName is taken as input and is compared against the packages collected whose catalog name
// matches the catalog under consideration.
func validatePackageCreation(operatorCatalog *catalogd.Catalog, pkgName string) error {
var pkgCollected string
pList := &catalogd.PackageList{}
if err := c.List(ctx, pList); err != nil {
return fmt.Errorf("Error retrieving the packages after %v catalog instance creation: %v", operatorCatalog.Name, err)
}
for _, pack := range pList.Items {
if pack.Spec.Catalog.Name == operatorCatalog.Name {
pkgCollected = pack.Spec.Name
}
}
if pkgCollected != pkgName {
return fmt.Errorf("Package %v for the catalog %v is not created", pkgName, operatorCatalog.Name)
}
return nil
}

// Checks if the CatalogMetadata was created from the catalog and returns error if not.
// The expected pkgNames and their versions are taken as input. This is then compared against the collected bundle versions.
// The collected bundle versions are formed by reading the version from "olm.package" property type whose catalog name
Expand Down

0 comments on commit db08a62

Please sign in to comment.