Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UICatalogEntry pruning ALM-438 #269

Merged
merged 3 commits into from
Feb 9, 2018

Conversation

ecordell
Copy link
Member

@ecordell ecordell commented Feb 7, 2018

This adds pruning logic for UICatalogEntries

  • Any UICatalogEntries without ownerreferences are deleted
  • For each CatalogSource,
    • Find all UICatalogEntries owned by the CatalogSource
    • Parse the CatalogSource configmap to pull out which packages should exist
    • Create or update any entries from the CatalogSource
    • Any entries owned by the CatalogSource but not updated or created is pruned

@ecordell ecordell changed the title UICatalogEntry pruning UICatalogEntry pruning ALM-438 Feb 7, 2018
@alecmerdler
Copy link
Member

I have a work-in-progress branch for Console that eliminates the need for UICatalogEntry-v1s, so this may not be needed.

@ecordell
Copy link
Member Author

ecordell commented Feb 7, 2018

@alecmerdler awesome, let's keep this around just in case, and we'll close it when/if the console branch is merged

@ecordell
Copy link
Member Author

ecordell commented Feb 7, 2018

This has some catalog fixes that we'll need to include even if we're not using uicatalogentries

@@ -40,7 +41,7 @@ var installPlanFailedChecker = func(fip *installplanv1alpha1.InstallPlan) bool {
return fip.Status.Phase == installplanv1alpha1.InstallPlanPhaseFailed
}

func FetchUICatalogEntries(t *testing.T, c opClient.Interface, count int) (*opClient.CustomResourceList, error) {
func fetchUICatalogEntries(t *testing.T, c opClient.Interface, count int) (*opClient.CustomResourceList, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

c := newKubeClient(t)

// Load old configmap (contains packages A and B)
oldFile, err := os.Open("e2e/data/catalog.old.yaml")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this an absolute path, or explicitly relative?

_, err = fetchUICatalogEntry(t, c, "package-c")
require.NoError(t, err)

// B should've been updated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it's hard to tell where set up ends and tests begin. Maybe comments delineating?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments

@@ -17,6 +18,8 @@ import (

type UICatalogEntryInterface interface {
UpdateEntry(csv *v1alpha1.UICatalogEntry) (*v1alpha1.UICatalogEntry, error)
ListEntries(namespace string) (*v1alpha1.UICatalogEntryList, error)
Delete(name, namespace string, options *metav1.DeleteOptions) error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most places have the order namespace, name. Can we keep it consistent by changing the order here?

// Sync creates UICatalogEntry CRDs for each package in the catalog. Fails immediately on error.
func (store *CustomResourceCatalogStore) Sync(catalog Source) ([]*v1alpha1.UICatalogEntry, error) {
// Sync creates UICatalogEntry CRDs for each package in the catalog and removes old ones. Fails immediately on error.
func (store *CustomResourceCatalogStore) Sync(catalog Source, source *catalogv1alpha1.CatalogSource) ([]*v1alpha1.UICatalogEntry, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about passing in owners []metav1.OwnerReference instead of source to keep it more generic and clean? It'd remove the need to import catalogv1alpha1 as well.

existingMap[existing.Name] = existing
}

// prune things not controlled by any source
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we? seems like unexpected behavior if you manually create one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we upgrade from tectonic helium, all existing uicatalogentries won't have any owners, so this will clean them up and replace with owned versions.

}
}
for _, new := range newEntries {
newMap[new.Name] = new
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since new is a keyword (as is new(map[string]string)), even though it's not showing an error, can it be renamed to something else?

Copy link
Member

@alecmerdler alecmerdler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ecordell ecordell merged commit 3e3f5d6 into operator-framework:master Feb 9, 2018
njhale pushed a commit to njhale/operator-lifecycle-manager that referenced this pull request Sep 10, 2018
ecordell added a commit to ecordell/operator-lifecycle-manager that referenced this pull request Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants