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

Operator should not delete CRDs #172

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions controllers/default_test.go
Copy link
Member

Choose a reason for hiding this comment

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

The AfterEach for this set of tests should delete the *.shipwright.io CRD instances. I think the tests previously relied on the delete behavior to tear down the CRD instance each time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adambkaplan Should we care about not deleteing the CRDs on tear down if the cluster is been stopped/deleed

Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ var _ = g.Describe("Reconcile default ShipwrightBuild installation", func() {
test.EventuallyRemoved(ctx, k8sClient, expectedDeployment)
})

// TODO: Do not delete the CRDs! This is something only a cluster admin should do.
g.It("deletes the custom resource definitions for the Shipwright build APIs", func(ctx g.SpecContext) {
// Deteling the build instance should not delete CRDS
g.It("should not delete the custom resource definitions for the Shipwright build APIs", func(ctx g.SpecContext) {
test.CRDEventuallyExists(ctx, k8sClient, "builds.shipwright.io")
test.CRDEventuallyExists(ctx, k8sClient, "buildruns.shipwright.io")
test.CRDEventuallyExists(ctx, k8sClient, "buildstrategies.shipwright.io")
Expand All @@ -244,10 +244,10 @@ var _ = g.Describe("Reconcile default ShipwrightBuild installation", func() {
o.Expect(err).NotTo(o.HaveOccurred())

// Verify - check the behavior
test.CRDEventuallyRemoved(ctx, k8sClient, "builds.shipwright.io")
test.CRDEventuallyRemoved(ctx, k8sClient, "buildruns.shipwright.io")
test.CRDEventuallyRemoved(ctx, k8sClient, "buildstrategies.shipwright.io")
test.CRDEventuallyRemoved(ctx, k8sClient, "clusterbuildstrategies.shipwright.io")
test.CRDEventuallyExists(ctx, k8sClient, "builds.shipwright.io")
test.CRDEventuallyExists(ctx, k8sClient, "buildruns.shipwright.io")
test.CRDEventuallyExists(ctx, k8sClient, "buildstrategies.shipwright.io")
test.CRDEventuallyExists(ctx, k8sClient, "clusterbuildstrategies.shipwright.io")
Comment on lines +247 to +250
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should introduce a wait period before checking that the CRDs still exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adambkaplan The test is passing without the wait period, we do the same for the deployment and rbac and those tests had been working since the begining.
https://github.com/shipwright-io/operator/blob/main/controllers/default_test.go#L222

})
})

Expand Down
2 changes: 1 addition & 1 deletion controllers/shipwrightbuild_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (r *ShipwrightBuildReconciler) Reconcile(ctx context.Context, req ctrl.Requ
}

logger.Info("Deleting manifests...")
if err := manifest.Delete(); err != nil {
if err := manifest.Filter(manifestival.NoCRDs).Delete(); err != nil {
logger.Error(err, "deleting manifest's resources")
return RequeueWithError(err)
}
Expand Down
Loading