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

Bug 1833195: delete bundle objects after CSV gets deleted #1516

Merged

Conversation

exdx
Copy link
Member

@exdx exdx commented May 12, 2020

Description of the change:
OLM now supports secrets and configmaps in the bundle. These should have ownerrefs associated with the CSV in the bundle. When the CSV is deleted, these objects should be deleted as well. Since they are namespaced scoped, the kube gc will delete them automatically.

Motivation for the change:

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /docs
  • Commit messages sensible and descriptive

@openshift-ci-robot
Copy link
Collaborator

@exdx: This pull request references Bugzilla bug 1833195, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1833195: delete bundle objects after CSV gets deleted

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels May 12, 2020
@exdx exdx requested review from ecordell, njhale and awgreene May 12, 2020 20:25
@exdx
Copy link
Member Author

exdx commented May 12, 2020

/retest

1 similar comment
@awgreene
Copy link
Member

/retest

Copy link
Member

@awgreene awgreene left a comment

Choose a reason for hiding this comment

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

Nice work @exdx - a few questions/nits.

test/e2e/gc_e2e_test.go Outdated Show resolved Hide resolved
test/e2e/gc_e2e_test.go Outdated Show resolved Hide resolved
test/e2e/gc_e2e_test.go Outdated Show resolved Hide resolved
test/e2e/gc_e2e_test.go Show resolved Hide resolved
test/e2e/gc_e2e_test.go Outdated Show resolved Hide resolved
test/e2e/gc_e2e_test.go Outdated Show resolved Hide resolved
Copy link
Member

@awgreene awgreene left a comment

Choose a reason for hiding this comment

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

Great work @exdx - one non-blocking comment.

@awgreene
Copy link
Member

Unit tests are failing.

@exdx
Copy link
Member Author

exdx commented May 14, 2020

Unit tests are failing.

didn't check things again after rebasing off master 🤦

@exdx exdx force-pushed the fix/bug-1833195 branch 2 times, most recently from f58008c to 362fcff Compare May 14, 2020 22:11
Copy link
Member

@ecordell ecordell left a comment

Choose a reason for hiding this comment

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

Can you add tests for upgrades?

What happens if:

  • I have a configmap in version 1 and an updated version of the same configmap in version 2
  • I have a configmap in version 1 and a different (name) configmap in version 2

(the old should be deleted and the new should be created in both cases, but we should have tests to verify the behavior).

We should improve our docs here as well - unlike "managed" resources (deployment, rbac created from permissions block), we don't directly update / pivot ownerrefs for these "unmanaged" resources. That could be a tripping point for some.

test/e2e/gc_e2e_test.go Outdated Show resolved Hide resolved
test/e2e/gc_e2e_test.go Outdated Show resolved Hide resolved
test/e2e/gc_e2e_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@harishsurf harishsurf left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your efforts to write tests in ginkgo Dan! The test looks good. I left you some minor comments.

test/e2e/gc_e2e_test.go Show resolved Hide resolved
test/e2e/gc_e2e_test.go Outdated Show resolved Hide resolved
test/e2e/gc_e2e_test.go Outdated Show resolved Hide resolved
test/e2e/gc_e2e_test.go Outdated Show resolved Hide resolved
@exdx exdx force-pushed the fix/bug-1833195 branch 2 times, most recently from 84f6ca2 to aadf21a Compare May 15, 2020 19:10
@exdx exdx requested a review from ecordell May 15, 2020 19:10
@exdx
Copy link
Member Author

exdx commented May 15, 2020

Added two additional e2e tests for the 2 upgrade scenarios @ecordell mentioned.

Also added the ownership code to service objects in the bundle as well for consistency across all bundle objects OLM resolves.

@exdx
Copy link
Member Author

exdx commented May 18, 2020

/retest

@exdx
Copy link
Member Author

exdx commented May 19, 2020

Tests should pass once Quay is back in a healthy state

@exdx
Copy link
Member Author

exdx commented May 20, 2020

/retest

@ecordell
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 20, 2020
Copy link
Contributor

@benluddy benluddy left a comment

Choose a reason for hiding this comment

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

LGTM. I left a few nits on the tests but I don't think they need to block fixing this bug.

/approve

Eventually(func() error {
_, err = fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker)
return err
}).Should(BeNil())
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, but the error matchers, like Succeed, would also report if the actual value doesn't have an error type. The message in the test output will be a bit nicer, too.

https://onsi.github.io/gomega/#asserting-on-errors

Expect(err).ToNot(HaveOccurred(), "could not create catalog source")

// Create a Subscription for package
_ = createSubscriptionForCatalog(operatorClient, source.GetNamespace(), subName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the cleanup func need to be called in an AfterEach if it's non-nil?

Comment on lines +461 to +470
Eventually(func() bool {
cfg, err := kubeClient.GetConfigMap(testNamespace, configmapName)
if err != nil {
return false
}
// check data in configmap to ensure it is the new data (configmap was updated in the newer bundle)
// new value in the configmap is "updated-very-much"
data := cfg.Data["special.how"]
return data == "updated-very-much"
}).Should(BeTrue())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think both Expect and Eventually/Consistently can handle multiple return values and implicitly fail if anything after the first return value is non-nil, which would let you write this:

Suggested change
Eventually(func() bool {
cfg, err := kubeClient.GetConfigMap(testNamespace, configmapName)
if err != nil {
return false
}
// check data in configmap to ensure it is the new data (configmap was updated in the newer bundle)
// new value in the configmap is "updated-very-much"
data := cfg.Data["special.how"]
return data == "updated-very-much"
}).Should(BeTrue())
Eventually(func() (string, error) {
cfg, err := kubeClient.GetConfigMap(testNamespace, configmapName)
if err != nil {
return "", err
}
return cfg.Data["special.how"], nil
}).Should(Equal("updated-very-much"))

Copy link
Member Author

Choose a reason for hiding this comment

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

nice

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: awgreene, benluddy, exdx

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 21, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 2159df5 into operator-framework:master May 21, 2020
@openshift-ci-robot
Copy link
Collaborator

@exdx: All pull requests linked via external trackers have merged: operator-framework/operator-lifecycle-manager#1516. Bugzilla bug 1833195 has been moved to the MODIFIED state.

In response to this:

Bug 1833195: delete bundle objects after CSV gets deleted

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants