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

fix: Use Cascading Deletion in a Cluster #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion pkg/controller/postgres/postgres_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (r *ReconcilePostgres) Reconcile(request reconcile.Request) (_ reconcile.Re
func (r *ReconcilePostgres) addFinalizer(reqLogger logr.Logger, m *dbv1alpha1.Postgres) error {
if len(m.GetFinalizers()) < 1 && m.GetDeletionTimestamp() == nil {
reqLogger.Info("adding Finalizer for Postgres")
m.SetFinalizers([]string{"finalizer.db.movetokube.com"})
m.SetFinalizers([]string{"foregroundDeletion"})
}
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/postgres/postgres_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var _ = Describe("ReconcilePostgres", func() {
Name: name,
Namespace: namespace,
DeletionTimestamp: &now,
Finalizers: []string{"finalizer.db.movetokube.com"},
Finalizers: []string{"foregroundDeletion"},
},
Spec: v1alpha1.PostgresSpec{
Database: name,
Expand Down Expand Up @@ -200,7 +200,7 @@ var _ = Describe("ReconcilePostgres", func() {
foundPostgres := &v1alpha1.Postgres{}
err = cl.Get(context.TODO(), types.NamespacedName{Name: name, Namespace: namespace}, foundPostgres)
Expect(err).To(BeNil())
Expect(foundPostgres.GetFinalizers()[0]).To(Equal("finalizer.db.movetokube.com"))
Expect(foundPostgres.GetFinalizers()[0]).To(Equal("foregroundDeletion"))
})

})
Expand Down Expand Up @@ -401,7 +401,7 @@ var _ = Describe("ReconcilePostgres", func() {
})

It("should set a finalizer", func() {
expectedFinalizer := "finalizer.db.movetokube.com"
expectedFinalizer := "foregroundDeletion"
// Call Reconcile
_, err := rp.Reconcile(req)
// No error should be returned
Expand Down Expand Up @@ -707,7 +707,7 @@ var _ = Describe("ReconcilePostgres", func() {
// Expected method calls
// customers schema errors
pg.EXPECT().CreateSchema(name, name+"-group", "customers", gomock.Any()).Return(fmt.Errorf("Could not create schema")).Times(1)
pg.EXPECT().SetSchemaPrivileges(name, name+"-group", gomock.Any(), "customers", gomock.Any(), gomock.Any() ,gomock.Any()).Return(nil).Times(0)
pg.EXPECT().SetSchemaPrivileges(name, name+"-group", gomock.Any(), "customers", gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(0)
// stores schema
pg.EXPECT().CreateSchema(name, name+"-group", "stores", gomock.Any()).Return(nil).Times(1)
pg.EXPECT().SetSchemaPrivileges(name, name+"-group", name+"-reader", "stores", gomock.Any(), false, gomock.Any()).Return(nil).Times(1)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/postgresuser/postgresuser_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (r *ReconcilePostgresUser) Reconcile(request reconcile.Request) (reconcile.
func (r *ReconcilePostgresUser) addFinalizer(reqLogger logr.Logger, m *dbv1alpha1.PostgresUser) error {
if len(m.GetFinalizers()) < 1 && m.GetDeletionTimestamp() == nil {
reqLogger.Info("adding Finalizer for Postgres")
m.SetFinalizers([]string{"finalizer.db.movetokube.com"})
m.SetFinalizers([]string{"foregroundDeletion"})

// Update CR
err := r.client.Update(context.TODO(), m)
Expand Down