Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
gibizer committed Oct 4, 2024
1 parent 48f7fb3 commit 77350a0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
44 changes: 42 additions & 2 deletions controllers/nova_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,12 +829,52 @@ func (r *NovaReconciler) ensureCellDeleted(
return err
}

err = DeleteDatabaseAndAccountFinalizers(ctx, h, dbName, accountName, instance.ObjectMeta.Namespace)
err = mariadbv1.DeleteDatabaseAndAccountFinalizers(
ctx, h, dbName, accountName, instance.Namespace)
if err != nil {
return err
}

account := &mariadbv1.MariaDBAccount{
ObjectMeta: metav1.ObjectMeta{
Name: accountName,
Namespace: instance.Namespace,
},
}
// NOTE(gibi): this might be controversial as we cannot be sure if
// Nova got a pre-created account from outside or created its own.
// Today it is always the nova controller who creates the Account but
// it might change in the future.
// Still as we need to delete the MariaDBDatabase we need to get rid
// of the Account. Also that Account in that DB will be pointless
// if the DB is gone.
err = r.Client.Delete(ctx, account)
if err != nil {
return err
}
Log.Info("Cell isn't defined in the nova, so deleted cell", "cell", cell)
Log.Info("Deleted MariaDBAccount", "account", account)

// NOTE(gibi): This is also controversial as we don't know if the account
// secret was created by us by falling back to create the MariaDBAccount.
// Still MariaDBAccount cleanup does not delete the secret so we have to.
err = secret.DeleteSecretsWithName(ctx, h, account.Spec.Secret, instance.Namespace)
if err != nil && !k8s_errors.IsNotFound(err) {
return err
}

database := &mariadbv1.MariaDBDatabase{
ObjectMeta: metav1.ObjectMeta{
Name: dbName,
Namespace: instance.Namespace,
},
}
err = r.Client.Delete(ctx, database)
if err != nil && !k8s_errors.IsNotFound(err) {
return err
}
Log.Info("Deleted MariaDBDatabase", "database", database)

Log.Info("Cell isn't defined in the Nova CR any more, so deleted cell", "cell", cell)
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ replace github.com/openstack-k8s-operators/nova-operator/api => ./api
// mschuppert: map to latest commit from release-4.16 tag
// must consistent within modules and service operators
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 //allow-merging

replace github.com/openstack-k8s-operators/mariadb-operator/api => github.com/zzzeek/mariadb-operator/api v0.3.1-0.20240917193141-8598d28fb998
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.2024092
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20240925091112-d0fa8e528283/go.mod h1:t4Bbcsmzn1Z/0TlAN6Tsr3NXsB7M7EX5bCszfPSXZq4=
github.com/openstack-k8s-operators/lib-common/modules/test v0.4.1-0.20240925091112-d0fa8e528283 h1:tOltAleFLxk3d7Ia8ktGGxCtVIrqqUTUfx/tcfE/zq4=
github.com/openstack-k8s-operators/lib-common/modules/test v0.4.1-0.20240925091112-d0fa8e528283/go.mod h1:LV0jo5etIsGyINpmB37i4oWR8zU6ApIuh7fsqGGA41o=
github.com/openstack-k8s-operators/mariadb-operator/api v0.4.1-0.20240926100023-0398f9bb0ba5 h1:bNvL9IdLLefFB2C/bGL0QNZvn0lL4gwxgsQFaHg59AM=
github.com/openstack-k8s-operators/mariadb-operator/api v0.4.1-0.20240926100023-0398f9bb0ba5/go.mod h1:13K91HQShjM0y1zVTupCybaTpWJYzOhMPd+rJUpxIg8=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -114,6 +112,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zzzeek/mariadb-operator/api v0.3.1-0.20240917193141-8598d28fb998 h1:n9puB4ZYAEpX4e8GT9TRiKh6biACndHew4dM5xszUiA=
github.com/zzzeek/mariadb-operator/api v0.3.1-0.20240917193141-8598d28fb998/go.mod h1:nu9jPHDKVIrsU2GnrCXH/iW+qf0c3wKwJcHs7zJhK6s=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
Expand Down

0 comments on commit 77350a0

Please sign in to comment.